blob: aa8cc8dc25d15af5bf72621a0afb66297bac18e5 [file] [log] [blame]
Greg Rose3047f902010-01-09 02:23:31 +00001/*******************************************************************************
2
3 Intel 82599 Virtual Function driver
Mark Rustad06380db2014-03-04 03:02:23 +00004 Copyright(c) 1999 - 2014 Intel Corporation.
Greg Rose3047f902010-01-09 02:23:31 +00005
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, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
21
22 Contact Information:
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25
26*******************************************************************************/
27
28#ifndef __IXGBE_VF_H__
29#define __IXGBE_VF_H__
30
31#include <linux/pci.h>
32#include <linux/delay.h>
33#include <linux/interrupt.h>
34#include <linux/if_ether.h>
Jiri Pirko5c58c472010-03-23 22:58:20 +000035#include <linux/netdevice.h>
Greg Rose3047f902010-01-09 02:23:31 +000036
37#include "defines.h"
38#include "regs.h"
39#include "mbx.h"
40
41struct ixgbe_hw;
42
43/* iterator type for walking multicast address lists */
44typedef u8* (*ixgbe_mc_addr_itr) (struct ixgbe_hw *hw, u8 **mc_addr_ptr,
45 u32 *vmdq);
46struct ixgbe_mac_operations {
47 s32 (*init_hw)(struct ixgbe_hw *);
48 s32 (*reset_hw)(struct ixgbe_hw *);
49 s32 (*start_hw)(struct ixgbe_hw *);
50 s32 (*clear_hw_cntrs)(struct ixgbe_hw *);
51 enum ixgbe_media_type (*get_media_type)(struct ixgbe_hw *);
Greg Rose3047f902010-01-09 02:23:31 +000052 s32 (*get_mac_addr)(struct ixgbe_hw *, u8 *);
53 s32 (*stop_adapter)(struct ixgbe_hw *);
54 s32 (*get_bus_info)(struct ixgbe_hw *);
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);
Greg Rose46ec20f2011-05-13 01:33:42 +000064 s32 (*set_uc_addr)(struct ixgbe_hw *, u32, u8 *);
Greg Rose3047f902010-01-09 02:23:31 +000065 s32 (*init_rx_addrs)(struct ixgbe_hw *);
Jiri Pirko5c58c472010-03-23 22:58:20 +000066 s32 (*update_mc_addr_list)(struct ixgbe_hw *, struct net_device *);
Greg Rose3047f902010-01-09 02:23:31 +000067 s32 (*enable_mc)(struct ixgbe_hw *);
68 s32 (*disable_mc)(struct ixgbe_hw *);
69 s32 (*clear_vfta)(struct ixgbe_hw *);
70 s32 (*set_vfta)(struct ixgbe_hw *, u32, u32, bool);
71};
72
73enum ixgbe_mac_type {
74 ixgbe_mac_unknown = 0,
75 ixgbe_mac_82599_vf,
Greg Rose2316aa22010-12-02 07:12:26 +000076 ixgbe_mac_X540_vf,
Greg Rose3047f902010-01-09 02:23:31 +000077 ixgbe_num_macs
78};
79
80struct ixgbe_mac_info {
81 struct ixgbe_mac_operations ops;
82 u8 addr[6];
83 u8 perm_addr[6];
84
85 enum ixgbe_mac_type type;
86
87 s32 mc_filter_type;
88
89 bool get_link_status;
90 u32 max_tx_queues;
91 u32 max_rx_queues;
92 u32 max_msix_vectors;
93};
94
95struct ixgbe_mbx_operations {
96 s32 (*init_params)(struct ixgbe_hw *hw);
97 s32 (*read)(struct ixgbe_hw *, u32 *, u16);
98 s32 (*write)(struct ixgbe_hw *, u32 *, u16);
99 s32 (*read_posted)(struct ixgbe_hw *, u32 *, u16);
100 s32 (*write_posted)(struct ixgbe_hw *, u32 *, u16);
101 s32 (*check_for_msg)(struct ixgbe_hw *);
102 s32 (*check_for_ack)(struct ixgbe_hw *);
103 s32 (*check_for_rst)(struct ixgbe_hw *);
104};
105
106struct ixgbe_mbx_stats {
107 u32 msgs_tx;
108 u32 msgs_rx;
109
110 u32 acks;
111 u32 reqs;
112 u32 rsts;
113};
114
115struct ixgbe_mbx_info {
116 struct ixgbe_mbx_operations ops;
117 struct ixgbe_mbx_stats stats;
118 u32 timeout;
119 u32 udelay;
120 u32 v2p_mailbox;
121 u16 size;
122};
123
124struct ixgbe_hw {
125 void *back;
126
127 u8 __iomem *hw_addr;
Greg Rose3047f902010-01-09 02:23:31 +0000128
129 struct ixgbe_mac_info mac;
130 struct ixgbe_mbx_info mbx;
131
132 u16 device_id;
133 u16 subsystem_vendor_id;
134 u16 subsystem_device_id;
135 u16 vendor_id;
136
137 u8 revision_id;
138 bool adapter_stopped;
Alexander Duyck31186782012-07-20 08:09:58 +0000139
140 int api_version;
Greg Rose3047f902010-01-09 02:23:31 +0000141};
142
143struct ixgbevf_hw_stats {
144 u64 base_vfgprc;
145 u64 base_vfgptc;
146 u64 base_vfgorc;
147 u64 base_vfgotc;
148 u64 base_vfmprc;
149
150 u64 last_vfgprc;
151 u64 last_vfgptc;
152 u64 last_vfgorc;
153 u64 last_vfgotc;
154 u64 last_vfmprc;
155
156 u64 vfgprc;
157 u64 vfgptc;
158 u64 vfgorc;
159 u64 vfgotc;
160 u64 vfmprc;
Greg Rose33bd9f62010-03-19 02:59:52 +0000161
162 u64 saved_reset_vfgprc;
163 u64 saved_reset_vfgptc;
164 u64 saved_reset_vfgorc;
165 u64 saved_reset_vfgotc;
166 u64 saved_reset_vfmprc;
Greg Rose3047f902010-01-09 02:23:31 +0000167};
168
169struct ixgbevf_info {
170 enum ixgbe_mac_type mac;
Stephen Hemminger3d8fe982012-01-18 22:13:34 +0000171 const struct ixgbe_mac_operations *mac_ops;
Greg Rose3047f902010-01-09 02:23:31 +0000172};
173
Mark Rustaddbf8b0d2014-03-04 03:02:34 +0000174#define IXGBE_FAILED_READ_REG 0xffffffffU
175
176#define IXGBE_REMOVED(a) unlikely(!(a))
177
Mark Rustad06380db2014-03-04 03:02:23 +0000178static inline void ixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 value)
179{
Mark Rustad984b0ee2014-03-04 03:02:40 +0000180 u8 __iomem *reg_addr = ACCESS_ONCE(hw->hw_addr);
181
182 if (IXGBE_REMOVED(reg_addr))
183 return;
184 writel(value, reg_addr + reg);
Mark Rustad06380db2014-03-04 03:02:23 +0000185}
186#define IXGBE_WRITE_REG(h, r, v) ixgbe_write_reg(h, r, v)
187
Mark Rustad32c74942014-03-18 07:03:35 +0000188u32 ixgbevf_read_reg(struct ixgbe_hw *hw, u32 reg);
189#define IXGBE_READ_REG(h, r) ixgbevf_read_reg(h, r)
Mark Rustad06380db2014-03-04 03:02:23 +0000190
191static inline void ixgbe_write_reg_array(struct ixgbe_hw *hw, u32 reg,
192 u32 offset, u32 value)
193{
194 ixgbe_write_reg(hw, reg + (offset << 2), value);
195}
196#define IXGBE_WRITE_REG_ARRAY(h, r, o, v) ixgbe_write_reg_array(h, r, o, v)
197
198static inline u32 ixgbe_read_reg_array(struct ixgbe_hw *hw, u32 reg,
199 u32 offset)
200{
Mark Rustad32c74942014-03-18 07:03:35 +0000201 return ixgbevf_read_reg(hw, reg + (offset << 2));
Mark Rustad06380db2014-03-04 03:02:23 +0000202}
203#define IXGBE_READ_REG_ARRAY(h, r, o) ixgbe_read_reg_array(h, r, o)
204
Alexander Duyckdd1fe112012-07-20 08:09:48 +0000205void ixgbevf_rlpml_set_vf(struct ixgbe_hw *hw, u16 max_size);
Alexander Duyck31186782012-07-20 08:09:58 +0000206int ixgbevf_negotiate_api_version(struct ixgbe_hw *hw, int api);
Alexander Duyck56e94092012-07-20 08:10:03 +0000207int ixgbevf_get_queues(struct ixgbe_hw *hw, unsigned int *num_tcs,
208 unsigned int *default_tc);
Greg Rose3047f902010-01-09 02:23:31 +0000209#endif /* __IXGBE_VF_H__ */
210