xref: /linux/drivers/net/ethernet/intel/ixgbevf/vf.h (revision 32c74949b4e37f80ab74d9b497ffb3749cfcb85a)
1dee1ad47SJeff Kirsher /*******************************************************************************
2dee1ad47SJeff Kirsher 
3dee1ad47SJeff Kirsher   Intel 82599 Virtual Function driver
406380db6SMark Rustad   Copyright(c) 1999 - 2014 Intel Corporation.
5dee1ad47SJeff Kirsher 
6dee1ad47SJeff Kirsher   This program is free software; you can redistribute it and/or modify it
7dee1ad47SJeff Kirsher   under the terms and conditions of the GNU General Public License,
8dee1ad47SJeff Kirsher   version 2, as published by the Free Software Foundation.
9dee1ad47SJeff Kirsher 
10dee1ad47SJeff Kirsher   This program is distributed in the hope it will be useful, but WITHOUT
11dee1ad47SJeff Kirsher   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12dee1ad47SJeff Kirsher   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13dee1ad47SJeff Kirsher   more details.
14dee1ad47SJeff Kirsher 
15dee1ad47SJeff Kirsher   You should have received a copy of the GNU General Public License along with
16dee1ad47SJeff Kirsher   this program; if not, write to the Free Software Foundation, Inc.,
17dee1ad47SJeff Kirsher   51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18dee1ad47SJeff Kirsher 
19dee1ad47SJeff Kirsher   The full GNU General Public License is included in this distribution in
20dee1ad47SJeff Kirsher   the file called "COPYING".
21dee1ad47SJeff Kirsher 
22dee1ad47SJeff Kirsher   Contact Information:
23dee1ad47SJeff Kirsher   e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24dee1ad47SJeff Kirsher   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25dee1ad47SJeff Kirsher 
26dee1ad47SJeff Kirsher *******************************************************************************/
27dee1ad47SJeff Kirsher 
28dee1ad47SJeff Kirsher #ifndef __IXGBE_VF_H__
29dee1ad47SJeff Kirsher #define __IXGBE_VF_H__
30dee1ad47SJeff Kirsher 
31dee1ad47SJeff Kirsher #include <linux/pci.h>
32dee1ad47SJeff Kirsher #include <linux/delay.h>
33dee1ad47SJeff Kirsher #include <linux/interrupt.h>
34dee1ad47SJeff Kirsher #include <linux/if_ether.h>
35dee1ad47SJeff Kirsher #include <linux/netdevice.h>
36dee1ad47SJeff Kirsher 
37dee1ad47SJeff Kirsher #include "defines.h"
38dee1ad47SJeff Kirsher #include "regs.h"
39dee1ad47SJeff Kirsher #include "mbx.h"
40dee1ad47SJeff Kirsher 
41dee1ad47SJeff Kirsher struct ixgbe_hw;
42dee1ad47SJeff Kirsher 
43dee1ad47SJeff Kirsher /* iterator type for walking multicast address lists */
44dee1ad47SJeff Kirsher typedef u8* (*ixgbe_mc_addr_itr) (struct ixgbe_hw *hw, u8 **mc_addr_ptr,
45dee1ad47SJeff Kirsher 				  u32 *vmdq);
46dee1ad47SJeff Kirsher struct ixgbe_mac_operations {
47dee1ad47SJeff Kirsher 	s32 (*init_hw)(struct ixgbe_hw *);
48dee1ad47SJeff Kirsher 	s32 (*reset_hw)(struct ixgbe_hw *);
49dee1ad47SJeff Kirsher 	s32 (*start_hw)(struct ixgbe_hw *);
50dee1ad47SJeff Kirsher 	s32 (*clear_hw_cntrs)(struct ixgbe_hw *);
51dee1ad47SJeff Kirsher 	enum ixgbe_media_type (*get_media_type)(struct ixgbe_hw *);
52dee1ad47SJeff Kirsher 	u32 (*get_supported_physical_layer)(struct ixgbe_hw *);
53dee1ad47SJeff Kirsher 	s32 (*get_mac_addr)(struct ixgbe_hw *, u8 *);
54dee1ad47SJeff Kirsher 	s32 (*stop_adapter)(struct ixgbe_hw *);
55dee1ad47SJeff Kirsher 	s32 (*get_bus_info)(struct ixgbe_hw *);
56dee1ad47SJeff Kirsher 
57dee1ad47SJeff Kirsher 	/* Link */
58dee1ad47SJeff Kirsher 	s32 (*setup_link)(struct ixgbe_hw *, ixgbe_link_speed, bool, bool);
59dee1ad47SJeff Kirsher 	s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *, bool);
60dee1ad47SJeff Kirsher 	s32 (*get_link_capabilities)(struct ixgbe_hw *, ixgbe_link_speed *,
61dee1ad47SJeff Kirsher 				     bool *);
62dee1ad47SJeff Kirsher 
63dee1ad47SJeff Kirsher 	/* RAR, Multicast, VLAN */
64dee1ad47SJeff Kirsher 	s32 (*set_rar)(struct ixgbe_hw *, u32, u8 *, u32);
65dee1ad47SJeff Kirsher 	s32 (*set_uc_addr)(struct ixgbe_hw *, u32, u8 *);
66dee1ad47SJeff Kirsher 	s32 (*init_rx_addrs)(struct ixgbe_hw *);
67dee1ad47SJeff Kirsher 	s32 (*update_mc_addr_list)(struct ixgbe_hw *, struct net_device *);
68dee1ad47SJeff Kirsher 	s32 (*enable_mc)(struct ixgbe_hw *);
69dee1ad47SJeff Kirsher 	s32 (*disable_mc)(struct ixgbe_hw *);
70dee1ad47SJeff Kirsher 	s32 (*clear_vfta)(struct ixgbe_hw *);
71dee1ad47SJeff Kirsher 	s32 (*set_vfta)(struct ixgbe_hw *, u32, u32, bool);
72dee1ad47SJeff Kirsher };
73dee1ad47SJeff Kirsher 
74dee1ad47SJeff Kirsher enum ixgbe_mac_type {
75dee1ad47SJeff Kirsher 	ixgbe_mac_unknown = 0,
76dee1ad47SJeff Kirsher 	ixgbe_mac_82599_vf,
77dee1ad47SJeff Kirsher 	ixgbe_mac_X540_vf,
78dee1ad47SJeff Kirsher 	ixgbe_num_macs
79dee1ad47SJeff Kirsher };
80dee1ad47SJeff Kirsher 
81dee1ad47SJeff Kirsher struct ixgbe_mac_info {
82dee1ad47SJeff Kirsher 	struct ixgbe_mac_operations ops;
83dee1ad47SJeff Kirsher 	u8 addr[6];
84dee1ad47SJeff Kirsher 	u8 perm_addr[6];
85dee1ad47SJeff Kirsher 
86dee1ad47SJeff Kirsher 	enum ixgbe_mac_type type;
87dee1ad47SJeff Kirsher 
88dee1ad47SJeff Kirsher 	s32  mc_filter_type;
89dee1ad47SJeff Kirsher 
90dee1ad47SJeff Kirsher 	bool get_link_status;
91dee1ad47SJeff Kirsher 	u32  max_tx_queues;
92dee1ad47SJeff Kirsher 	u32  max_rx_queues;
93dee1ad47SJeff Kirsher 	u32  max_msix_vectors;
94dee1ad47SJeff Kirsher };
95dee1ad47SJeff Kirsher 
96dee1ad47SJeff Kirsher struct ixgbe_mbx_operations {
97dee1ad47SJeff Kirsher 	s32 (*init_params)(struct ixgbe_hw *hw);
98dee1ad47SJeff Kirsher 	s32 (*read)(struct ixgbe_hw *, u32 *, u16);
99dee1ad47SJeff Kirsher 	s32 (*write)(struct ixgbe_hw *, u32 *, u16);
100dee1ad47SJeff Kirsher 	s32 (*read_posted)(struct ixgbe_hw *, u32 *, u16);
101dee1ad47SJeff Kirsher 	s32 (*write_posted)(struct ixgbe_hw *, u32 *, u16);
102dee1ad47SJeff Kirsher 	s32 (*check_for_msg)(struct ixgbe_hw *);
103dee1ad47SJeff Kirsher 	s32 (*check_for_ack)(struct ixgbe_hw *);
104dee1ad47SJeff Kirsher 	s32 (*check_for_rst)(struct ixgbe_hw *);
105dee1ad47SJeff Kirsher };
106dee1ad47SJeff Kirsher 
107dee1ad47SJeff Kirsher struct ixgbe_mbx_stats {
108dee1ad47SJeff Kirsher 	u32 msgs_tx;
109dee1ad47SJeff Kirsher 	u32 msgs_rx;
110dee1ad47SJeff Kirsher 
111dee1ad47SJeff Kirsher 	u32 acks;
112dee1ad47SJeff Kirsher 	u32 reqs;
113dee1ad47SJeff Kirsher 	u32 rsts;
114dee1ad47SJeff Kirsher };
115dee1ad47SJeff Kirsher 
116dee1ad47SJeff Kirsher struct ixgbe_mbx_info {
117dee1ad47SJeff Kirsher 	struct ixgbe_mbx_operations ops;
118dee1ad47SJeff Kirsher 	struct ixgbe_mbx_stats stats;
119dee1ad47SJeff Kirsher 	u32 timeout;
120dee1ad47SJeff Kirsher 	u32 udelay;
121dee1ad47SJeff Kirsher 	u32 v2p_mailbox;
122dee1ad47SJeff Kirsher 	u16 size;
123dee1ad47SJeff Kirsher };
124dee1ad47SJeff Kirsher 
125dee1ad47SJeff Kirsher struct ixgbe_hw {
126dee1ad47SJeff Kirsher 	void *back;
127dee1ad47SJeff Kirsher 
128dee1ad47SJeff Kirsher 	u8 __iomem *hw_addr;
129dee1ad47SJeff Kirsher 
130dee1ad47SJeff Kirsher 	struct ixgbe_mac_info mac;
131dee1ad47SJeff Kirsher 	struct ixgbe_mbx_info mbx;
132dee1ad47SJeff Kirsher 
133dee1ad47SJeff Kirsher 	u16 device_id;
134dee1ad47SJeff Kirsher 	u16 subsystem_vendor_id;
135dee1ad47SJeff Kirsher 	u16 subsystem_device_id;
136dee1ad47SJeff Kirsher 	u16 vendor_id;
137dee1ad47SJeff Kirsher 
138dee1ad47SJeff Kirsher 	u8  revision_id;
139dee1ad47SJeff Kirsher 	bool adapter_stopped;
14031186785SAlexander Duyck 
14131186785SAlexander Duyck 	int api_version;
142dee1ad47SJeff Kirsher };
143dee1ad47SJeff Kirsher 
144dee1ad47SJeff Kirsher struct ixgbevf_hw_stats {
145dee1ad47SJeff Kirsher 	u64 base_vfgprc;
146dee1ad47SJeff Kirsher 	u64 base_vfgptc;
147dee1ad47SJeff Kirsher 	u64 base_vfgorc;
148dee1ad47SJeff Kirsher 	u64 base_vfgotc;
149dee1ad47SJeff Kirsher 	u64 base_vfmprc;
150dee1ad47SJeff Kirsher 
151dee1ad47SJeff Kirsher 	u64 last_vfgprc;
152dee1ad47SJeff Kirsher 	u64 last_vfgptc;
153dee1ad47SJeff Kirsher 	u64 last_vfgorc;
154dee1ad47SJeff Kirsher 	u64 last_vfgotc;
155dee1ad47SJeff Kirsher 	u64 last_vfmprc;
156dee1ad47SJeff Kirsher 
157dee1ad47SJeff Kirsher 	u64 vfgprc;
158dee1ad47SJeff Kirsher 	u64 vfgptc;
159dee1ad47SJeff Kirsher 	u64 vfgorc;
160dee1ad47SJeff Kirsher 	u64 vfgotc;
161dee1ad47SJeff Kirsher 	u64 vfmprc;
162dee1ad47SJeff Kirsher 
163dee1ad47SJeff Kirsher 	u64 saved_reset_vfgprc;
164dee1ad47SJeff Kirsher 	u64 saved_reset_vfgptc;
165dee1ad47SJeff Kirsher 	u64 saved_reset_vfgorc;
166dee1ad47SJeff Kirsher 	u64 saved_reset_vfgotc;
167dee1ad47SJeff Kirsher 	u64 saved_reset_vfmprc;
168dee1ad47SJeff Kirsher };
169dee1ad47SJeff Kirsher 
170dee1ad47SJeff Kirsher struct ixgbevf_info {
171dee1ad47SJeff Kirsher 	enum ixgbe_mac_type		mac;
1723d8fe98fSStephen Hemminger 	const struct ixgbe_mac_operations *mac_ops;
173dee1ad47SJeff Kirsher };
174dee1ad47SJeff Kirsher 
175dbf8b0d8SMark Rustad #define IXGBE_FAILED_READ_REG 0xffffffffU
176dbf8b0d8SMark Rustad 
177dbf8b0d8SMark Rustad #define IXGBE_REMOVED(a) unlikely(!(a))
178dbf8b0d8SMark Rustad 
17906380db6SMark Rustad static inline void ixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 value)
18006380db6SMark Rustad {
181984b0ee3SMark Rustad 	u8 __iomem *reg_addr = ACCESS_ONCE(hw->hw_addr);
182984b0ee3SMark Rustad 
183984b0ee3SMark Rustad 	if (IXGBE_REMOVED(reg_addr))
184984b0ee3SMark Rustad 		return;
185984b0ee3SMark Rustad 	writel(value, reg_addr + reg);
18606380db6SMark Rustad }
18706380db6SMark Rustad #define IXGBE_WRITE_REG(h, r, v) ixgbe_write_reg(h, r, v)
18806380db6SMark Rustad 
189*32c74949SMark Rustad u32 ixgbevf_read_reg(struct ixgbe_hw *hw, u32 reg);
190*32c74949SMark Rustad #define IXGBE_READ_REG(h, r) ixgbevf_read_reg(h, r)
19106380db6SMark Rustad 
19206380db6SMark Rustad static inline void ixgbe_write_reg_array(struct ixgbe_hw *hw, u32 reg,
19306380db6SMark Rustad 					  u32 offset, u32 value)
19406380db6SMark Rustad {
19506380db6SMark Rustad 	ixgbe_write_reg(hw, reg + (offset << 2), value);
19606380db6SMark Rustad }
19706380db6SMark Rustad #define IXGBE_WRITE_REG_ARRAY(h, r, o, v) ixgbe_write_reg_array(h, r, o, v)
19806380db6SMark Rustad 
19906380db6SMark Rustad static inline u32 ixgbe_read_reg_array(struct ixgbe_hw *hw, u32 reg,
20006380db6SMark Rustad 					u32 offset)
20106380db6SMark Rustad {
202*32c74949SMark Rustad 	return ixgbevf_read_reg(hw, reg + (offset << 2));
20306380db6SMark Rustad }
20406380db6SMark Rustad #define IXGBE_READ_REG_ARRAY(h, r, o) ixgbe_read_reg_array(h, r, o)
20506380db6SMark Rustad 
206dd1fe113SAlexander Duyck void ixgbevf_rlpml_set_vf(struct ixgbe_hw *hw, u16 max_size);
20731186785SAlexander Duyck int ixgbevf_negotiate_api_version(struct ixgbe_hw *hw, int api);
20856e94095SAlexander Duyck int ixgbevf_get_queues(struct ixgbe_hw *hw, unsigned int *num_tcs,
20956e94095SAlexander Duyck 		       unsigned int *default_tc);
210dee1ad47SJeff Kirsher #endif /* __IXGBE_VF_H__ */
211dee1ad47SJeff Kirsher 
212