1/******************************************************************************
2
3  Copyright (c) 2001-2017, Intel Corporation
4  All rights reserved.
5
6  Redistribution and use in source and binary forms, with or without
7  modification, are permitted provided that the following conditions are met:
8
9   1. Redistributions of source code must retain the above copyright notice,
10      this list of conditions and the following disclaimer.
11
12   2. Redistributions in binary form must reproduce the above copyright
13      notice, this list of conditions and the following disclaimer in the
14      documentation and/or other materials provided with the distribution.
15
16   3. Neither the name of the Intel Corporation nor the names of its
17      contributors may be used to endorse or promote products derived from
18      this software without specific prior written permission.
19
20  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  POSSIBILITY OF SUCH DAMAGE.
31
32******************************************************************************/
33/*$FreeBSD: stable/10/sys/dev/ixgbe/ixv_vf.h 315333 2017-03-15 21:20:17Z erj $*/
34
35#ifndef _IXGBE_VF_H_
36#define _IXGBE_VF_H_
37
38#define IXGBE_VF_IRQ_CLEAR_MASK	7
39#define IXGBE_VF_MAX_TX_QUEUES	8
40#define IXGBE_VF_MAX_RX_QUEUES	8
41
42/* DCB define */
43#define IXGBE_VF_MAX_TRAFFIC_CLASS	8
44
45#define IXGBE_VFCTRL		0x00000
46#define IXGBE_VFSTATUS		0x00008
47#define IXGBE_VFLINKS		0x00010
48#define IXGBE_VFFRTIMER		0x00048
49#define IXGBE_VFRXMEMWRAP	0x03190
50#define IXGBE_VTEICR		0x00100
51#define IXGBE_VTEICS		0x00104
52#define IXGBE_VTEIMS		0x00108
53#define IXGBE_VTEIMC		0x0010C
54#define IXGBE_VTEIAC		0x00110
55#define IXGBE_VTEIAM		0x00114
56#define IXGBE_VTEITR(x)		(0x00820 + (4 * (x)))
57#define IXGBE_VTIVAR(x)		(0x00120 + (4 * (x)))
58#define IXGBE_VTIVAR_MISC	0x00140
59#define IXGBE_VTRSCINT(x)	(0x00180 + (4 * (x)))
60/* define IXGBE_VFPBACL  still says TBD in EAS */
61#define IXGBE_VFRDBAL(x)	(0x01000 + (0x40 * (x)))
62#define IXGBE_VFRDBAH(x)	(0x01004 + (0x40 * (x)))
63#define IXGBE_VFRDLEN(x)	(0x01008 + (0x40 * (x)))
64#define IXGBE_VFRDH(x)		(0x01010 + (0x40 * (x)))
65#define IXGBE_VFRDT(x)		(0x01018 + (0x40 * (x)))
66#define IXGBE_VFRXDCTL(x)	(0x01028 + (0x40 * (x)))
67#define IXGBE_VFSRRCTL(x)	(0x01014 + (0x40 * (x)))
68#define IXGBE_VFRSCCTL(x)	(0x0102C + (0x40 * (x)))
69#define IXGBE_VFPSRTYPE		0x00300
70#define IXGBE_VFTDBAL(x)	(0x02000 + (0x40 * (x)))
71#define IXGBE_VFTDBAH(x)	(0x02004 + (0x40 * (x)))
72#define IXGBE_VFTDLEN(x)	(0x02008 + (0x40 * (x)))
73#define IXGBE_VFTDH(x)		(0x02010 + (0x40 * (x)))
74#define IXGBE_VFTDT(x)		(0x02018 + (0x40 * (x)))
75#define IXGBE_VFTXDCTL(x)	(0x02028 + (0x40 * (x)))
76#define IXGBE_VFTDWBAL(x)	(0x02038 + (0x40 * (x)))
77#define IXGBE_VFTDWBAH(x)	(0x0203C + (0x40 * (x)))
78#define IXGBE_VFDCA_RXCTRL(x)	(0x0100C + (0x40 * (x)))
79#define IXGBE_VFDCA_TXCTRL(x)	(0x0200c + (0x40 * (x)))
80#define IXGBE_VFGPRC		0x0101C
81#define IXGBE_VFGPTC		0x0201C
82#define IXGBE_VFGORC_LSB	0x01020
83#define IXGBE_VFGORC_MSB	0x01024
84#define IXGBE_VFGOTC_LSB	0x02020
85#define IXGBE_VFGOTC_MSB	0x02024
86#define IXGBE_VFMPRC		0x01034
87#define IXGBE_VFMRQC		0x3000
88#define IXGBE_VFRSSRK(x)	(0x3100 + ((x) * 4))
89#define IXGBE_VFRETA(x)	(0x3200 + ((x) * 4))
90
91struct ixgbe_hw;
92
93#include "ixv_type.h"
94
95#include "ixv_mbx.h"
96
97struct ixgbe_mac_operations {
98	s32 (*init_hw)(struct ixgbe_hw *);
99	s32 (*reset_hw)(struct ixgbe_hw *);
100	s32 (*start_hw)(struct ixgbe_hw *);
101	s32 (*clear_hw_cntrs)(struct ixgbe_hw *);
102	enum ixgbe_media_type (*get_media_type)(struct ixgbe_hw *);
103	u32 (*get_supported_physical_layer)(struct ixgbe_hw *);
104	s32 (*get_mac_addr)(struct ixgbe_hw *, u8 *);
105	s32 (*stop_adapter)(struct ixgbe_hw *);
106	s32 (*get_bus_info)(struct ixgbe_hw *);
107	s32 (*negotiate_api_version)(struct ixgbe_hw *hw, int api);
108
109	/* Link */
110	s32 (*setup_link)(struct ixgbe_hw *, ixgbe_link_speed, bool);
111	s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *, bool);
112	s32 (*get_link_capabilities)(struct ixgbe_hw *, ixgbe_link_speed *,
113				     bool *);
114
115	/* RAR, Multicast, VLAN */
116	s32 (*set_rar)(struct ixgbe_hw *, u32, u8 *, u32, u32);
117	s32 (*set_uc_addr)(struct ixgbe_hw *, u32, u8 *);
118	s32 (*init_rx_addrs)(struct ixgbe_hw *);
119	s32 (*update_mc_addr_list)(struct ixgbe_hw *, u8 *, u32,
120				   ixgbe_mc_addr_itr, bool);
121	s32 (*update_xcast_mode)(struct ixgbe_hw *, int);
122	s32 (*enable_mc)(struct ixgbe_hw *);
123	s32 (*disable_mc)(struct ixgbe_hw *);
124	s32 (*clear_vfta)(struct ixgbe_hw *);
125	s32 (*set_vfta)(struct ixgbe_hw *, u32, u32, bool, bool);
126	s32 (*set_rlpml)(struct ixgbe_hw *, u16);
127};
128
129struct ixgbe_mac_info {
130	struct ixgbe_mac_operations ops;
131	u8 addr[6];
132	u8 perm_addr[6];
133
134	enum ixgbe_mac_type type;
135
136	s32  mc_filter_type;
137
138	bool get_link_status;
139	u32  max_tx_queues;
140	u32  max_rx_queues;
141	u32  max_msix_vectors;
142};
143
144struct ixgbe_mbx_operations {
145	void (*init_params)(struct ixgbe_hw *hw);
146	s32  (*read)(struct ixgbe_hw *, u32 *, u16,  u16);
147	s32  (*write)(struct ixgbe_hw *, u32 *, u16, u16);
148	s32  (*read_posted)(struct ixgbe_hw *, u32 *, u16,  u16);
149	s32  (*write_posted)(struct ixgbe_hw *, u32 *, u16, u16);
150	s32  (*check_for_msg)(struct ixgbe_hw *, u16);
151	s32  (*check_for_ack)(struct ixgbe_hw *, u16);
152	s32  (*check_for_rst)(struct ixgbe_hw *, u16);
153};
154
155struct ixgbe_mbx_stats {
156	u32 msgs_tx;
157	u32 msgs_rx;
158
159	u32 acks;
160	u32 reqs;
161	u32 rsts;
162};
163
164struct ixgbe_mbx_info {
165	struct ixgbe_mbx_operations ops;
166	struct ixgbe_mbx_stats stats;
167	u32 timeout;
168	u32 usec_delay;
169	u32 v2p_mailbox;
170	u16 size;
171};
172
173struct ixgbe_hw {
174	void *back;
175
176	u8 IOMEM *hw_addr;
177
178	struct ixgbe_mac_info mac;
179	struct ixgbe_mbx_info mbx;
180
181	u16 device_id;
182	u16 subsystem_vendor_id;
183	u16 subsystem_device_id;
184	u16 vendor_id;
185
186	u8  revision_id;
187	bool adapter_stopped;
188
189	int api_version;
190};
191
192struct ixgbevf_hw_stats {
193	u64 base_vfgprc;
194	u64 base_vfgptc;
195	u64 base_vfgorc;
196	u64 base_vfgotc;
197	u64 base_vfmprc;
198
199	u64 last_vfgprc;
200	u64 last_vfgptc;
201	u64 last_vfgorc;
202	u64 last_vfgotc;
203	u64 last_vfmprc;
204
205	u64 vfgprc;
206	u64 vfgptc;
207	u64 vfgorc;
208	u64 vfgotc;
209	u64 vfmprc;
210
211	u64 saved_reset_vfgprc;
212	u64 saved_reset_vfgptc;
213	u64 saved_reset_vfgorc;
214	u64 saved_reset_vfgotc;
215	u64 saved_reset_vfmprc;
216};
217
218s32 ixgbe_init_ops_vf(struct ixgbe_hw *hw);
219s32 ixgbe_init_hw_vf(struct ixgbe_hw *hw);
220s32 ixgbe_start_hw_vf(struct ixgbe_hw *hw);
221s32 ixgbe_reset_hw_vf(struct ixgbe_hw *hw);
222s32 ixgbe_stop_adapter_vf(struct ixgbe_hw *hw);
223u32 ixgbe_get_num_of_tx_queues_vf(struct ixgbe_hw *hw);
224u32 ixgbe_get_num_of_rx_queues_vf(struct ixgbe_hw *hw);
225s32 ixgbe_get_mac_addr_vf(struct ixgbe_hw *hw, u8 *mac_addr);
226s32 ixgbe_setup_mac_link_vf(struct ixgbe_hw *hw, ixgbe_link_speed speed,
227			    bool autoneg_wait_to_complete);
228s32 ixgbe_check_mac_link_vf(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
229			    bool *link_up, bool autoneg_wait_to_complete);
230s32 ixgbe_set_rar_vf(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
231		     u32 enable_addr);
232s32 ixgbevf_set_uc_addr_vf(struct ixgbe_hw *hw, u32 index, u8 *addr);
233s32 ixgbe_update_mc_addr_list_vf(struct ixgbe_hw *hw, u8 *mc_addr_list,
234				 u32 mc_addr_count, ixgbe_mc_addr_itr,
235				 bool clear);
236s32 ixgbevf_update_xcast_mode(struct ixgbe_hw *hw, int xcast_mode);
237s32 ixgbe_set_vfta_vf(struct ixgbe_hw *hw, u32 vlan, u32 vind,
238		      bool vlan_on, bool vlvf_bypass);
239s32 ixgbevf_rlpml_set_vf(struct ixgbe_hw *hw, u16 max_size);
240int ixgbevf_negotiate_api_version(struct ixgbe_hw *hw, int api);
241int ixgbevf_get_queues(struct ixgbe_hw *hw, unsigned int *num_tcs,
242		       unsigned int *default_tc);
243
244#endif /* __IXGBE_VF_H__ */
245