xref: /titanic_50/usr/src/uts/common/io/i40e/i40e_sw.h (revision 8d5069bc751f57c7f5fe5ef63afce1daa8ce219f)
1da5577f0SRobert Mustacchi /*
2da5577f0SRobert Mustacchi  * This file and its contents are supplied under the terms of the
3da5577f0SRobert Mustacchi  * Common Development and Distribution License ("CDDL"), version 1.0.
4da5577f0SRobert Mustacchi  * You may only use this file in accordance with the terms of version
5da5577f0SRobert Mustacchi  * 1.0 of the CDDL.
6da5577f0SRobert Mustacchi  *
7da5577f0SRobert Mustacchi  * A full copy of the text of the CDDL should have accompanied this
8da5577f0SRobert Mustacchi  * source.  A copy of the CDDL is also available via the Internet at
9da5577f0SRobert Mustacchi  * http://www.illumos.org/license/CDDL.
10da5577f0SRobert Mustacchi  */
11da5577f0SRobert Mustacchi 
12da5577f0SRobert Mustacchi /*
13da5577f0SRobert Mustacchi  * Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved.
14*8d5069bcSRyan Zezeski  * Copyright 2019 Joyent, Inc.
1505768666SPaul Winder  * Copyright 2017 Tegile Systems, Inc.  All rights reserved.
16da5577f0SRobert Mustacchi  */
17da5577f0SRobert Mustacchi 
18da5577f0SRobert Mustacchi /*
19da5577f0SRobert Mustacchi  * Please see i40e_main.c for an introduction to the device driver, its layout,
20da5577f0SRobert Mustacchi  * and more.
21da5577f0SRobert Mustacchi  */
22da5577f0SRobert Mustacchi 
23da5577f0SRobert Mustacchi #ifndef	_I40E_SW_H
24da5577f0SRobert Mustacchi #define	_I40E_SW_H
25da5577f0SRobert Mustacchi 
26da5577f0SRobert Mustacchi #ifdef __cplusplus
27da5577f0SRobert Mustacchi extern "C" {
28da5577f0SRobert Mustacchi #endif
29da5577f0SRobert Mustacchi 
30da5577f0SRobert Mustacchi #include <sys/types.h>
31da5577f0SRobert Mustacchi #include <sys/conf.h>
32da5577f0SRobert Mustacchi #include <sys/debug.h>
33da5577f0SRobert Mustacchi #include <sys/stropts.h>
34da5577f0SRobert Mustacchi #include <sys/stream.h>
35da5577f0SRobert Mustacchi #include <sys/strsun.h>
36da5577f0SRobert Mustacchi #include <sys/strlog.h>
37da5577f0SRobert Mustacchi #include <sys/kmem.h>
38da5577f0SRobert Mustacchi #include <sys/stat.h>
39da5577f0SRobert Mustacchi #include <sys/kstat.h>
40da5577f0SRobert Mustacchi #include <sys/modctl.h>
41da5577f0SRobert Mustacchi #include <sys/errno.h>
42da5577f0SRobert Mustacchi #include <sys/dlpi.h>
43da5577f0SRobert Mustacchi #include <sys/mac_provider.h>
44da5577f0SRobert Mustacchi #include <sys/mac_ether.h>
45da5577f0SRobert Mustacchi #include <sys/vlan.h>
46da5577f0SRobert Mustacchi #include <sys/ddi.h>
47da5577f0SRobert Mustacchi #include <sys/sunddi.h>
48da5577f0SRobert Mustacchi #include <sys/pci.h>
49da5577f0SRobert Mustacchi #include <sys/pcie.h>
50da5577f0SRobert Mustacchi #include <sys/sdt.h>
51da5577f0SRobert Mustacchi #include <sys/ethernet.h>
52da5577f0SRobert Mustacchi #include <sys/pattr.h>
53da5577f0SRobert Mustacchi #include <sys/strsubr.h>
54da5577f0SRobert Mustacchi #include <sys/netlb.h>
55da5577f0SRobert Mustacchi #include <sys/random.h>
56da5577f0SRobert Mustacchi #include <inet/common.h>
57da5577f0SRobert Mustacchi #include <inet/tcp.h>
58da5577f0SRobert Mustacchi #include <inet/ip.h>
59da5577f0SRobert Mustacchi #include <inet/mi.h>
60da5577f0SRobert Mustacchi #include <inet/nd.h>
61da5577f0SRobert Mustacchi #include <netinet/udp.h>
62da5577f0SRobert Mustacchi #include <netinet/sctp.h>
63da5577f0SRobert Mustacchi #include <sys/bitmap.h>
64da5577f0SRobert Mustacchi #include <sys/cpuvar.h>
65da5577f0SRobert Mustacchi #include <sys/ddifm.h>
66da5577f0SRobert Mustacchi #include <sys/fm/protocol.h>
67da5577f0SRobert Mustacchi #include <sys/fm/util.h>
68da5577f0SRobert Mustacchi #include <sys/disp.h>
69da5577f0SRobert Mustacchi #include <sys/fm/io/ddi.h>
70da5577f0SRobert Mustacchi #include <sys/list.h>
71da5577f0SRobert Mustacchi #include <sys/debug.h>
72da5577f0SRobert Mustacchi #include <sys/sdt.h>
73da5577f0SRobert Mustacchi #include "i40e_type.h"
74da5577f0SRobert Mustacchi #include "i40e_osdep.h"
75da5577f0SRobert Mustacchi #include "i40e_prototype.h"
76da5577f0SRobert Mustacchi #include "i40e_xregs.h"
77da5577f0SRobert Mustacchi 
78da5577f0SRobert Mustacchi #define	I40E_MODULE_NAME "i40e"
79da5577f0SRobert Mustacchi 
80da5577f0SRobert Mustacchi #define	I40E_ADAPTER_REGSET	1
81da5577f0SRobert Mustacchi 
82da5577f0SRobert Mustacchi /*
83da5577f0SRobert Mustacchi  * Configuration constants. Note that the hardware defines a minimum bound of 32
84da5577f0SRobert Mustacchi  * descriptors and requires that the programming of the descriptor lengths be
85da5577f0SRobert Mustacchi  * aligned in units of 32 descriptors.
86da5577f0SRobert Mustacchi  */
87da5577f0SRobert Mustacchi #define	I40E_MIN_TX_RING_SIZE	64
88da5577f0SRobert Mustacchi #define	I40E_MAX_TX_RING_SIZE	4096
89da5577f0SRobert Mustacchi #define	I40E_DEF_TX_RING_SIZE	1024
90da5577f0SRobert Mustacchi 
91da5577f0SRobert Mustacchi #define	I40E_MIN_RX_RING_SIZE	64
92da5577f0SRobert Mustacchi #define	I40E_MAX_RX_RING_SIZE	4096
93da5577f0SRobert Mustacchi #define	I40E_DEF_RX_RING_SIZE	1024
94da5577f0SRobert Mustacchi 
95da5577f0SRobert Mustacchi #define	I40E_DESC_ALIGN		32
96da5577f0SRobert Mustacchi 
97da5577f0SRobert Mustacchi /*
98da5577f0SRobert Mustacchi  * Sizes used for asynchronous processing of the adminq. We allocate a fixed
99da5577f0SRobert Mustacchi  * size buffer for each instance of the device during attach time, rather than
100da5577f0SRobert Mustacchi  * allocating and freeing one during interrupt processing.
101da5577f0SRobert Mustacchi  *
102da5577f0SRobert Mustacchi  * We also define the descriptor size of the admin queue here.
103da5577f0SRobert Mustacchi  */
104da5577f0SRobert Mustacchi #define	I40E_ADMINQ_BUFSZ	4096
105da5577f0SRobert Mustacchi #define	I40E_MAX_ADMINQ_SIZE	1024
106da5577f0SRobert Mustacchi #define	I40E_DEF_ADMINQ_SIZE	256
107da5577f0SRobert Mustacchi 
108da5577f0SRobert Mustacchi /*
109da5577f0SRobert Mustacchi  * Note, while the min and maximum values are based upon the sizing of the ring
110da5577f0SRobert Mustacchi  * itself, the default is taken from ixgbe without much thought. It's basically
111da5577f0SRobert Mustacchi  * been cargo culted. See i40e_transceiver.c for a bit more information.
112da5577f0SRobert Mustacchi  */
113da5577f0SRobert Mustacchi #define	I40E_MIN_RX_LIMIT_PER_INTR	16
114da5577f0SRobert Mustacchi #define	I40E_MAX_RX_LIMIT_PER_INTR	4096
115da5577f0SRobert Mustacchi #define	I40E_DEF_RX_LIMIT_PER_INTR	256
116da5577f0SRobert Mustacchi 
117da5577f0SRobert Mustacchi /*
118da5577f0SRobert Mustacchi  * Valid MTU ranges. Note that the XL710's maximum payload is actually 9728.
119da5577f0SRobert Mustacchi  * However, we need to adjust for the ETHERFCSL (4 bytes) and the Ethernet VLAN
120da5577f0SRobert Mustacchi  * header size (18 bytes) to get the actual maximum frame we can use. If
121da5577f0SRobert Mustacchi  * different adapters end up with different sizes, we should make this value a
122da5577f0SRobert Mustacchi  * bit more dynamic.
123da5577f0SRobert Mustacchi  */
124da5577f0SRobert Mustacchi #define	I40E_MAX_MTU	9706
125da5577f0SRobert Mustacchi #define	I40E_MIN_MTU	ETHERMIN
126da5577f0SRobert Mustacchi #define	I40E_DEF_MTU	ETHERMTU
127da5577f0SRobert Mustacchi 
128da5577f0SRobert Mustacchi /*
129da5577f0SRobert Mustacchi  * Interrupt throttling related values. Interrupt throttling values are defined
130da5577f0SRobert Mustacchi  * in two microsecond increments. Note that a value of zero basically says do no
131da5577f0SRobert Mustacchi  * ITR activity. A helpful way to think about these is that setting the ITR to a
132da5577f0SRobert Mustacchi  * value will allow a certain number of interrupts per second.
133da5577f0SRobert Mustacchi  *
134da5577f0SRobert Mustacchi  * Our default values for RX allow 20k interrupts per second while our default
135da5577f0SRobert Mustacchi  * values for TX allow for 5k interrupts per second. For other class interrupts,
136da5577f0SRobert Mustacchi  * we limit ourselves to a rate of 2k/s.
137da5577f0SRobert Mustacchi  */
138da5577f0SRobert Mustacchi #define	I40E_MIN_ITR		0x0000
139da5577f0SRobert Mustacchi #define	I40E_MAX_ITR		0x0FF0
140da5577f0SRobert Mustacchi #define	I40E_DEF_RX_ITR		0x0019
141da5577f0SRobert Mustacchi #define	I40E_DEF_TX_ITR		0x0064
142da5577f0SRobert Mustacchi #define	I40E_DEF_OTHER_ITR	0x00FA
143da5577f0SRobert Mustacchi 
144da5577f0SRobert Mustacchi /*
145da5577f0SRobert Mustacchi  * Indexes into the three ITR registers that we have.
146da5577f0SRobert Mustacchi  */
147da5577f0SRobert Mustacchi typedef enum i40e_itr_index {
148da5577f0SRobert Mustacchi 	I40E_ITR_INDEX_RX	= 0x0,
149da5577f0SRobert Mustacchi 	I40E_ITR_INDEX_TX	= 0x1,
150da5577f0SRobert Mustacchi 	I40E_ITR_INDEX_OTHER	= 0x2,
151da5577f0SRobert Mustacchi 	I40E_ITR_INDEX_NONE 	= 0x3
152da5577f0SRobert Mustacchi } i40e_itr_index_t;
153da5577f0SRobert Mustacchi 
154da5577f0SRobert Mustacchi /*
155*8d5069bcSRyan Zezeski  * The hardware claims to support LSO up to 256 KB, but due to the limitations
156*8d5069bcSRyan Zezeski  * imposed by the IP header for non-jumbo frames, we cap it at 64 KB.
157da5577f0SRobert Mustacchi  */
158*8d5069bcSRyan Zezeski #define	I40E_LSO_MAXLEN	(64 * 1024)
159da5577f0SRobert Mustacchi 
160da5577f0SRobert Mustacchi #define	I40E_CYCLIC_PERIOD NANOSEC	/* 1 second */
161da5577f0SRobert Mustacchi #define	I40E_DRAIN_RX_WAIT	(500 * MILLISEC)	/* In us */
162da5577f0SRobert Mustacchi 
163da5577f0SRobert Mustacchi /*
164da5577f0SRobert Mustacchi  * All the other queue types for are defined by the common code. However, this
165da5577f0SRobert Mustacchi  * is the constant to indicate that it's terminated.
166da5577f0SRobert Mustacchi  */
167da5577f0SRobert Mustacchi #define	I40E_QUEUE_TYPE_EOL	0x7FF
168da5577f0SRobert Mustacchi 
169da5577f0SRobert Mustacchi /*
170da5577f0SRobert Mustacchi  * See the comments in i40e_transceiver.c as to the purpose of this value and
171da5577f0SRobert Mustacchi  * how it's used to ensure that the IP header is eventually aligned when it's
172da5577f0SRobert Mustacchi  * received by the OS.
173da5577f0SRobert Mustacchi  */
174da5577f0SRobert Mustacchi #define	I40E_BUF_IPHDR_ALIGNMENT	2
175da5577f0SRobert Mustacchi 
176da5577f0SRobert Mustacchi /*
177*8d5069bcSRyan Zezeski  * The XL710 controller has a total of eight buffers available for the
178*8d5069bcSRyan Zezeski  * transmission of any single frame. This is defined in 8.4.1 - Transmit
179da5577f0SRobert Mustacchi  * Packet in System Memory.
180da5577f0SRobert Mustacchi  */
181da5577f0SRobert Mustacchi #define	I40E_TX_MAX_COOKIE	8
182da5577f0SRobert Mustacchi 
183da5577f0SRobert Mustacchi /*
184*8d5069bcSRyan Zezeski  * An LSO frame can be as large as 64KB, so we allow a DMA bind to span more
185*8d5069bcSRyan Zezeski  * cookies than a non-LSO frame.  The key here to is to select a value such
186*8d5069bcSRyan Zezeski  * that once the HW has chunked up the LSO frame into MSS-sized segments that no
187*8d5069bcSRyan Zezeski  * single segment spans more than 8 cookies (see comments for
188*8d5069bcSRyan Zezeski  * I40E_TX_MAX_COOKIE)
189*8d5069bcSRyan Zezeski  */
190*8d5069bcSRyan Zezeski #define	I40E_TX_LSO_MAX_COOKIE	32
191*8d5069bcSRyan Zezeski 
192*8d5069bcSRyan Zezeski /*
193da5577f0SRobert Mustacchi  * Sizing to determine the amount of available descriptors at which we'll
194da5577f0SRobert Mustacchi  * consider ourselves blocked. Also, when we have these available, we'll then
195da5577f0SRobert Mustacchi  * consider ourselves available to transmit to MAC again. Strictly speaking, the
196da5577f0SRobert Mustacchi  * MAX is based on the ring size. The default sizing is based on ixgbe.
197da5577f0SRobert Mustacchi  */
198da5577f0SRobert Mustacchi #define	I40E_MIN_TX_BLOCK_THRESH	I40E_TX_MAX_COOKIE
199da5577f0SRobert Mustacchi #define	I40E_DEF_TX_BLOCK_THRESH	I40E_MIN_TX_BLOCK_THRESH
200da5577f0SRobert Mustacchi 
201da5577f0SRobert Mustacchi /*
202da5577f0SRobert Mustacchi  * Sizing for DMA thresholds. These are used to indicate whether or not we
203da5577f0SRobert Mustacchi  * should perform a bcopy or a DMA binding of a given message block. The range
204da5577f0SRobert Mustacchi  * allows for setting things such that we'll always do a bcopy (a high value) or
205da5577f0SRobert Mustacchi  * always perform a DMA binding (a low value).
206da5577f0SRobert Mustacchi  */
207da5577f0SRobert Mustacchi #define	I40E_MIN_RX_DMA_THRESH		0
208da5577f0SRobert Mustacchi #define	I40E_DEF_RX_DMA_THRESH		256
209da5577f0SRobert Mustacchi #define	I40E_MAX_RX_DMA_THRESH		INT32_MAX
210da5577f0SRobert Mustacchi 
211da5577f0SRobert Mustacchi #define	I40E_MIN_TX_DMA_THRESH		0
212da5577f0SRobert Mustacchi #define	I40E_DEF_TX_DMA_THRESH		256
213da5577f0SRobert Mustacchi #define	I40E_MAX_TX_DMA_THRESH		INT32_MAX
214da5577f0SRobert Mustacchi 
215da5577f0SRobert Mustacchi /*
216*8d5069bcSRyan Zezeski  * The max size of each individual tx buffer is 16KB - 1.
217*8d5069bcSRyan Zezeski  * See table 8-17
218*8d5069bcSRyan Zezeski  */
219*8d5069bcSRyan Zezeski #define	I40E_MAX_TX_BUFSZ		0x0000000000003FFFull
220*8d5069bcSRyan Zezeski 
221*8d5069bcSRyan Zezeski /*
222da5577f0SRobert Mustacchi  * Resource sizing counts. There are various aspects of hardware where we may
223da5577f0SRobert Mustacchi  * have some variable number of elements that we need to handle. Such as the
224da5577f0SRobert Mustacchi  * hardware capabilities and switch capacities. We cannot know a priori how many
225da5577f0SRobert Mustacchi  * elements to do, so instead we take a starting guess and then will grow it up
226da5577f0SRobert Mustacchi  * to an upper bound on a number of elements, to limit memory consumption in
227da5577f0SRobert Mustacchi  * case of a hardware bug.
228da5577f0SRobert Mustacchi  */
229da5577f0SRobert Mustacchi #define	I40E_HW_CAP_DEFAULT	40
230da5577f0SRobert Mustacchi #define	I40E_SWITCH_CAP_DEFAULT	25
231da5577f0SRobert Mustacchi 
232da5577f0SRobert Mustacchi /*
233da5577f0SRobert Mustacchi  * Host Memory Context related constants.
234da5577f0SRobert Mustacchi  */
235da5577f0SRobert Mustacchi #define	I40E_HMC_RX_CTX_UNIT		128
236da5577f0SRobert Mustacchi #define	I40E_HMC_RX_DBUFF_MIN		1024
237da5577f0SRobert Mustacchi #define	I40E_HMC_RX_DBUFF_MAX		(16 * 1024 - 128)
238da5577f0SRobert Mustacchi #define	I40E_HMC_RX_DTYPE_NOSPLIT	0
239da5577f0SRobert Mustacchi #define	I40E_HMC_RX_DSIZE_32BYTE	1
240da5577f0SRobert Mustacchi #define	I40E_HMC_RX_CRCSTRIP_ENABLE	1
241da5577f0SRobert Mustacchi #define	I40E_HMC_RX_FC_DISABLE		0
242da5577f0SRobert Mustacchi #define	I40E_HMC_RX_L2TAGORDER		1
243da5577f0SRobert Mustacchi #define	I40E_HMC_RX_HDRSPLIT_DISABLE	0
244da5577f0SRobert Mustacchi #define	I40E_HMC_RX_INVLAN_DONTSTRIP	0
245da5577f0SRobert Mustacchi #define	I40E_HMC_RX_TPH_DISABLE		0
246da5577f0SRobert Mustacchi #define	I40E_HMC_RX_LOWRXQ_NOINTR	0
247da5577f0SRobert Mustacchi #define	I40E_HMC_RX_PREFENA		1
248da5577f0SRobert Mustacchi 
249da5577f0SRobert Mustacchi #define	I40E_HMC_TX_CTX_UNIT		128
250da5577f0SRobert Mustacchi #define	I40E_HMC_TX_NEW_CONTEXT		1
251da5577f0SRobert Mustacchi #define	I40E_HMC_TX_FC_DISABLE		0
252da5577f0SRobert Mustacchi #define	I40E_HMC_TX_TS_DISABLE		0
253da5577f0SRobert Mustacchi #define	I40E_HMC_TX_FD_DISABLE		0
254da5577f0SRobert Mustacchi #define	I40E_HMC_TX_ALT_VLAN_DISABLE	0
255da5577f0SRobert Mustacchi #define	I40E_HMC_TX_WB_ENABLE		1
256da5577f0SRobert Mustacchi #define	I40E_HMC_TX_TPH_DISABLE		0
257da5577f0SRobert Mustacchi 
258da5577f0SRobert Mustacchi /*
259da5577f0SRobert Mustacchi  * This defines the error mask that we care about from rx descriptors. Currently
260da5577f0SRobert Mustacchi  * we're only concerned with the general errors and oversize errors.
261da5577f0SRobert Mustacchi  */
262da5577f0SRobert Mustacchi #define	I40E_RX_ERR_BITS	((1 << I40E_RX_DESC_ERROR_RXE_SHIFT) | \
263da5577f0SRobert Mustacchi 	(1 << I40E_RX_DESC_ERROR_OVERSIZE_SHIFT))
264da5577f0SRobert Mustacchi 
265da5577f0SRobert Mustacchi /*
266da5577f0SRobert Mustacchi  * Property sizing macros for firmware versions, etc. They need to be large
267da5577f0SRobert Mustacchi  * enough to hold 32-bit quantities transformed to strings as %d.%d or %x.
268da5577f0SRobert Mustacchi  */
269da5577f0SRobert Mustacchi #define	I40E_DDI_PROP_LEN	64
270da5577f0SRobert Mustacchi 
271da5577f0SRobert Mustacchi /*
272*8d5069bcSRyan Zezeski  * Place an artificial limit on the max number of groups. The X710
273*8d5069bcSRyan Zezeski  * series supports up to 384 VSIs to be partitioned across PFs as the
274*8d5069bcSRyan Zezeski  * driver sees fit. But until we support more interrupts this seems
275*8d5069bcSRyan Zezeski  * like a good place to start.
276da5577f0SRobert Mustacchi  */
277*8d5069bcSRyan Zezeski #define	I40E_GROUP_MAX		32
278da5577f0SRobert Mustacchi 
279da5577f0SRobert Mustacchi #define	I40E_GROUP_NOMSIX	1
280da5577f0SRobert Mustacchi #define	I40E_TRQPAIR_NOMSIX	1
281da5577f0SRobert Mustacchi 
282da5577f0SRobert Mustacchi /*
283da5577f0SRobert Mustacchi  * It seems reasonable to cast this to void because the only reason that we
284da5577f0SRobert Mustacchi  * should be getting a DDI_FAILURE is due to the fact that we specify addresses
285da5577f0SRobert Mustacchi  * out of range. Because we specify no offset or address, it shouldn't happen.
286da5577f0SRobert Mustacchi  */
287da5577f0SRobert Mustacchi #ifdef	DEBUG
288da5577f0SRobert Mustacchi #define	I40E_DMA_SYNC(handle, flag)	ASSERT0(ddi_dma_sync( \
289da5577f0SRobert Mustacchi 					    (handle)->dmab_dma_handle, 0, 0, \
290da5577f0SRobert Mustacchi 					    (flag)))
291da5577f0SRobert Mustacchi #else	/* !DEBUG */
292da5577f0SRobert Mustacchi #define	I40E_DMA_SYNC(handle, flag)	((void) ddi_dma_sync( \
293da5577f0SRobert Mustacchi 					    (handle)->dmab_dma_handle, 0, 0, \
294da5577f0SRobert Mustacchi 					    (flag)))
295da5577f0SRobert Mustacchi #endif	/* DEBUG */
296da5577f0SRobert Mustacchi 
297da5577f0SRobert Mustacchi /*
298da5577f0SRobert Mustacchi  * Constants related to ring startup and teardown. These refer to the amount of
299da5577f0SRobert Mustacchi  * time that we're willing to wait for a ring to spin up and spin down.
300da5577f0SRobert Mustacchi  */
301da5577f0SRobert Mustacchi #define	I40E_RING_WAIT_NTRIES	10
302da5577f0SRobert Mustacchi #define	I40E_RING_WAIT_PAUSE	10	/* ms */
303da5577f0SRobert Mustacchi 
304da5577f0SRobert Mustacchi /*
305422542c1SRobert Mustacchi  * Printed Board Assembly (PBA) length. These are derived from Table 6-2.
306422542c1SRobert Mustacchi  */
307422542c1SRobert Mustacchi #define	I40E_PBANUM_LENGTH	12
308422542c1SRobert Mustacchi #define	I40E_PBANUM_STRLEN	13
309422542c1SRobert Mustacchi 
310422542c1SRobert Mustacchi /*
311a7f9b000SRobert Mustacchi  * Define the maximum number of queues for a traffic class. These values come
312a7f9b000SRobert Mustacchi  * from the 'Number and offset of queue pairs per TCs' section of the 'Add VSI
313a7f9b000SRobert Mustacchi  * Command Buffer' table. For the 710 controller family this is table 7-62
314a7f9b000SRobert Mustacchi  * (r2.5) and for the 722 this is table 38-216 (r2.0).
315422542c1SRobert Mustacchi  */
316a7f9b000SRobert Mustacchi #define	I40E_710_MAX_TC_QUEUES	64
317a7f9b000SRobert Mustacchi #define	I40E_722_MAX_TC_QUEUES	128
318a7f9b000SRobert Mustacchi 
319a7f9b000SRobert Mustacchi /*
320a7f9b000SRobert Mustacchi  * Define the size of the HLUT table size. The HLUT table can either be 128 or
321a7f9b000SRobert Mustacchi  * 512 bytes. We always set the table size to be 512 bytes in i40e_chip_start().
322a7f9b000SRobert Mustacchi  * Note, this should not be confused with the common code's macro
323a7f9b000SRobert Mustacchi  * I40E_HASH_LUT_SIZE_512 which is the bit pattern needed to tell the card to
324a7f9b000SRobert Mustacchi  * use a 512 byte HLUT.
325a7f9b000SRobert Mustacchi  */
326a7f9b000SRobert Mustacchi #define	I40E_HLUT_TABLE_SIZE	512
327422542c1SRobert Mustacchi 
328422542c1SRobert Mustacchi /*
329da5577f0SRobert Mustacchi  * Bit flags for attach_progress
330da5577f0SRobert Mustacchi  */
331da5577f0SRobert Mustacchi typedef enum i40e_attach_state {
332da5577f0SRobert Mustacchi 	I40E_ATTACH_PCI_CONFIG	= 0x0001,	/* PCI config setup */
333da5577f0SRobert Mustacchi 	I40E_ATTACH_REGS_MAP	= 0x0002,	/* Registers mapped */
334da5577f0SRobert Mustacchi 	I40E_ATTACH_PROPS	= 0x0004,	/* Properties initialized */
335da5577f0SRobert Mustacchi 	I40E_ATTACH_ALLOC_INTR	= 0x0008,	/* Interrupts allocated */
336da5577f0SRobert Mustacchi 	I40E_ATTACH_ALLOC_RINGSLOCKS	= 0x0010, /* Rings & locks allocated */
337da5577f0SRobert Mustacchi 	I40E_ATTACH_ADD_INTR	= 0x0020,	/* Intr handlers added */
338da5577f0SRobert Mustacchi 	I40E_ATTACH_COMMON_CODE	= 0x0040, 	/* Intel code initialized */
339da5577f0SRobert Mustacchi 	I40E_ATTACH_INIT	= 0x0080,	/* Device initialized */
340da5577f0SRobert Mustacchi 	I40E_ATTACH_STATS	= 0x0200,	/* Kstats created */
341da5577f0SRobert Mustacchi 	I40E_ATTACH_MAC		= 0x0800,	/* MAC registered */
342da5577f0SRobert Mustacchi 	I40E_ATTACH_ENABLE_INTR	= 0x1000,	/* DDI interrupts enabled */
343da5577f0SRobert Mustacchi 	I40E_ATTACH_FM_INIT	= 0x2000,	/* FMA initialized */
344da5577f0SRobert Mustacchi 	I40E_ATTACH_LINK_TIMER	= 0x4000,	/* link check timer */
345da5577f0SRobert Mustacchi } i40e_attach_state_t;
346da5577f0SRobert Mustacchi 
347da5577f0SRobert Mustacchi 
348da5577f0SRobert Mustacchi /*
349da5577f0SRobert Mustacchi  * State flags that what's going on in in the device. Some of these state flags
350da5577f0SRobert Mustacchi  * indicate some aspirational work that needs to happen in the driver.
351da5577f0SRobert Mustacchi  *
352da5577f0SRobert Mustacchi  * I40E_UNKNOWN:	The device has yet to be started.
353da5577f0SRobert Mustacchi  * I40E_INITIALIZED:	The device has been fully attached.
354da5577f0SRobert Mustacchi  * I40E_STARTED:	The device has come out of the GLDV3 start routine.
355da5577f0SRobert Mustacchi  * I40E_SUSPENDED:	The device is suspended and I/O among other things
356da5577f0SRobert Mustacchi  * 			should not occur. This happens because of an actual
357da5577f0SRobert Mustacchi  * 			DDI_SUSPEND or interrupt adjustments.
358da5577f0SRobert Mustacchi  * I40E_STALL:		The tx stall detection logic has found a stall.
359da5577f0SRobert Mustacchi  * I40E_OVERTEMP:	The device has encountered a temperature alarm.
360da5577f0SRobert Mustacchi  * I40E_INTR_ADJUST:	Our interrupts are being manipulated and therefore we
361da5577f0SRobert Mustacchi  * 			shouldn't be manipulating their state.
362da5577f0SRobert Mustacchi  * I40E_ERROR:		We've detected an FM error and degraded the device.
363da5577f0SRobert Mustacchi  */
364da5577f0SRobert Mustacchi typedef enum i40e_state {
365da5577f0SRobert Mustacchi 	I40E_UNKNOWN		= 0x00,
366da5577f0SRobert Mustacchi 	I40E_INITIALIZED	= 0x01,
367da5577f0SRobert Mustacchi 	I40E_STARTED		= 0x02,
368da5577f0SRobert Mustacchi 	I40E_SUSPENDED		= 0x04,
369da5577f0SRobert Mustacchi 	I40E_STALL		= 0x08,
370da5577f0SRobert Mustacchi 	I40E_OVERTEMP		= 0x20,
371da5577f0SRobert Mustacchi 	I40E_INTR_ADJUST	= 0x40,
372da5577f0SRobert Mustacchi 	I40E_ERROR		= 0x80
373da5577f0SRobert Mustacchi } i40e_state_t;
374da5577f0SRobert Mustacchi 
375da5577f0SRobert Mustacchi 
376da5577f0SRobert Mustacchi /*
377da5577f0SRobert Mustacchi  * Definitions for common Intel things that we use and some slightly more usable
378da5577f0SRobert Mustacchi  * names.
379da5577f0SRobert Mustacchi  */
380da5577f0SRobert Mustacchi typedef struct i40e_hw i40e_hw_t;
381da5577f0SRobert Mustacchi typedef struct i40e_aqc_switch_resource_alloc_element_resp i40e_switch_rsrc_t;
382da5577f0SRobert Mustacchi 
383da5577f0SRobert Mustacchi /*
384da5577f0SRobert Mustacchi  * Handles and addresses of DMA buffers.
385da5577f0SRobert Mustacchi  */
386da5577f0SRobert Mustacchi typedef struct i40e_dma_buffer {
387da5577f0SRobert Mustacchi 	caddr_t		dmab_address;		/* Virtual address */
388da5577f0SRobert Mustacchi 	uint64_t	dmab_dma_address;	/* DMA (Hardware) address */
389da5577f0SRobert Mustacchi 	ddi_acc_handle_t dmab_acc_handle;	/* Data access handle */
390da5577f0SRobert Mustacchi 	ddi_dma_handle_t dmab_dma_handle;	/* DMA handle */
391da5577f0SRobert Mustacchi 	size_t		dmab_size;		/* Buffer size */
392da5577f0SRobert Mustacchi 	size_t		dmab_len;		/* Data length in the buffer */
393da5577f0SRobert Mustacchi } i40e_dma_buffer_t;
394da5577f0SRobert Mustacchi 
395da5577f0SRobert Mustacchi /*
396da5577f0SRobert Mustacchi  * RX Control Block
397da5577f0SRobert Mustacchi  */
398da5577f0SRobert Mustacchi typedef struct i40e_rx_control_block {
399da5577f0SRobert Mustacchi 	mblk_t			*rcb_mp;
400da5577f0SRobert Mustacchi 	uint32_t		rcb_ref;
401da5577f0SRobert Mustacchi 	i40e_dma_buffer_t	rcb_dma;
402da5577f0SRobert Mustacchi 	frtn_t			rcb_free_rtn;
403da5577f0SRobert Mustacchi 	struct i40e_rx_data	*rcb_rxd;
404da5577f0SRobert Mustacchi } i40e_rx_control_block_t;
405da5577f0SRobert Mustacchi 
406da5577f0SRobert Mustacchi typedef enum {
407da5577f0SRobert Mustacchi 	I40E_TX_NONE,
408da5577f0SRobert Mustacchi 	I40E_TX_COPY,
409*8d5069bcSRyan Zezeski 	I40E_TX_DMA,
410*8d5069bcSRyan Zezeski 	I40E_TX_DESC,
411da5577f0SRobert Mustacchi } i40e_tx_type_t;
412da5577f0SRobert Mustacchi 
413da5577f0SRobert Mustacchi typedef struct i40e_tx_desc i40e_tx_desc_t;
414*8d5069bcSRyan Zezeski typedef struct i40e_tx_context_desc i40e_tx_context_desc_t;
415da5577f0SRobert Mustacchi typedef union i40e_32byte_rx_desc i40e_rx_desc_t;
416da5577f0SRobert Mustacchi 
417*8d5069bcSRyan Zezeski struct i40e_dma_bind_info {
418*8d5069bcSRyan Zezeski 	caddr_t dbi_paddr;
419*8d5069bcSRyan Zezeski 	size_t dbi_len;
420*8d5069bcSRyan Zezeski };
421*8d5069bcSRyan Zezeski 
422da5577f0SRobert Mustacchi typedef struct i40e_tx_control_block {
423da5577f0SRobert Mustacchi 	struct i40e_tx_control_block	*tcb_next;
424da5577f0SRobert Mustacchi 	mblk_t				*tcb_mp;
425da5577f0SRobert Mustacchi 	i40e_tx_type_t			tcb_type;
426da5577f0SRobert Mustacchi 	ddi_dma_handle_t		tcb_dma_handle;
427*8d5069bcSRyan Zezeski 	ddi_dma_handle_t		tcb_lso_dma_handle;
428da5577f0SRobert Mustacchi 	i40e_dma_buffer_t		tcb_dma;
429*8d5069bcSRyan Zezeski 	struct i40e_dma_bind_info	*tcb_bind_info;
430*8d5069bcSRyan Zezeski 	uint_t				tcb_bind_ncookies;
431*8d5069bcSRyan Zezeski 	boolean_t			tcb_used_lso;
432da5577f0SRobert Mustacchi } i40e_tx_control_block_t;
433da5577f0SRobert Mustacchi 
434da5577f0SRobert Mustacchi /*
435da5577f0SRobert Mustacchi  * Receive ring data (used below).
436da5577f0SRobert Mustacchi  */
437da5577f0SRobert Mustacchi typedef struct i40e_rx_data {
438da5577f0SRobert Mustacchi 	struct i40e	*rxd_i40e;
439da5577f0SRobert Mustacchi 
440da5577f0SRobert Mustacchi 	/*
441da5577f0SRobert Mustacchi 	 * RX descriptor ring definitions
442da5577f0SRobert Mustacchi 	 */
443da5577f0SRobert Mustacchi 	i40e_dma_buffer_t rxd_desc_area;	/* DMA buffer of rx desc ring */
444da5577f0SRobert Mustacchi 	i40e_rx_desc_t *rxd_desc_ring;		/* Rx desc ring */
445da5577f0SRobert Mustacchi 	uint32_t rxd_desc_next;			/* Index of next rx desc */
446da5577f0SRobert Mustacchi 
447da5577f0SRobert Mustacchi 	/*
448da5577f0SRobert Mustacchi 	 * RX control block list definitions
449da5577f0SRobert Mustacchi 	 */
450da5577f0SRobert Mustacchi 	kmutex_t		rxd_free_lock;	/* Lock to protect free data */
451da5577f0SRobert Mustacchi 	i40e_rx_control_block_t	*rxd_rcb_area;	/* Array of control blocks */
452da5577f0SRobert Mustacchi 	i40e_rx_control_block_t	**rxd_work_list; /* Work list of rcbs */
453da5577f0SRobert Mustacchi 	i40e_rx_control_block_t	**rxd_free_list; /* Free list of rcbs */
454da5577f0SRobert Mustacchi 	uint32_t		rxd_rcb_free;	/* Number of free rcbs */
455da5577f0SRobert Mustacchi 
456da5577f0SRobert Mustacchi 	/*
457da5577f0SRobert Mustacchi 	 * RX software ring settings
458da5577f0SRobert Mustacchi 	 */
459da5577f0SRobert Mustacchi 	uint32_t	rxd_ring_size;		/* Rx descriptor ring size */
460da5577f0SRobert Mustacchi 	uint32_t	rxd_free_list_size;	/* Rx free list size */
461da5577f0SRobert Mustacchi 
462da5577f0SRobert Mustacchi 	/*
463da5577f0SRobert Mustacchi 	 * RX outstanding data. This is used to keep track of outstanding loaned
464da5577f0SRobert Mustacchi 	 * descriptors after we've shut down receiving information. Note these
465da5577f0SRobert Mustacchi 	 * are protected by the i40e_t`i40e_rx_pending_lock.
466da5577f0SRobert Mustacchi 	 */
467da5577f0SRobert Mustacchi 	uint32_t	rxd_rcb_pending;
468da5577f0SRobert Mustacchi 	boolean_t	rxd_shutdown;
469da5577f0SRobert Mustacchi } i40e_rx_data_t;
470da5577f0SRobert Mustacchi 
471da5577f0SRobert Mustacchi /*
472da5577f0SRobert Mustacchi  * Structures for unicast and multicast addresses. Note that we keep the VSI id
473da5577f0SRobert Mustacchi  * around for unicast addresses, since they may belong to different VSIs.
474da5577f0SRobert Mustacchi  * However, since all multicast addresses belong to the default VSI, we don't
475da5577f0SRobert Mustacchi  * duplicate that information.
476da5577f0SRobert Mustacchi  */
477da5577f0SRobert Mustacchi typedef struct i40e_uaddr {
478da5577f0SRobert Mustacchi 	uint8_t iua_mac[ETHERADDRL];
479da5577f0SRobert Mustacchi 	int	iua_vsi;
480da5577f0SRobert Mustacchi } i40e_uaddr_t;
481da5577f0SRobert Mustacchi 
482da5577f0SRobert Mustacchi typedef struct i40e_maddr {
483da5577f0SRobert Mustacchi 	uint8_t ima_mac[ETHERADDRL];
484da5577f0SRobert Mustacchi } i40e_maddr_t;
485da5577f0SRobert Mustacchi 
486da5577f0SRobert Mustacchi /*
487da5577f0SRobert Mustacchi  * Collection of RX statistics on a given queue.
488da5577f0SRobert Mustacchi  */
489da5577f0SRobert Mustacchi typedef struct i40e_rxq_stat {
490da5577f0SRobert Mustacchi 	/*
491da5577f0SRobert Mustacchi 	 * The i40e hardware does not maintain statistics on a per-ring basis,
492da5577f0SRobert Mustacchi 	 * only on a per-PF and per-VSI level. As such, to satisfy the GLDv3, we
493da5577f0SRobert Mustacchi 	 * need to maintain our own stats for packets and bytes.
494da5577f0SRobert Mustacchi 	 */
495da5577f0SRobert Mustacchi 	kstat_named_t	irxs_bytes;	/* Bytes in on queue */
496da5577f0SRobert Mustacchi 	kstat_named_t	irxs_packets;	/* Packets in on queue */
497da5577f0SRobert Mustacchi 
498da5577f0SRobert Mustacchi 	/*
499da5577f0SRobert Mustacchi 	 * The following set of stats cover non-checksum data path issues.
500da5577f0SRobert Mustacchi 	 */
501da5577f0SRobert Mustacchi 	kstat_named_t	irxs_rx_desc_error;	/* Error bit set on desc */
502da5577f0SRobert Mustacchi 	kstat_named_t	irxs_rx_copy_nomem;	/* allocb failure for copy */
503da5577f0SRobert Mustacchi 	kstat_named_t	irxs_rx_intr_limit;	/* Hit i40e_rx_limit_per_intr */
504da5577f0SRobert Mustacchi 	kstat_named_t	irxs_rx_bind_norcb;	/* No replacement rcb free */
505da5577f0SRobert Mustacchi 	kstat_named_t	irxs_rx_bind_nomp;	/* No mblk_t in bind rcb */
506da5577f0SRobert Mustacchi 
507da5577f0SRobert Mustacchi 	/*
508da5577f0SRobert Mustacchi 	 * The following set of statistics covers rx checksum related activity.
509da5577f0SRobert Mustacchi 	 * These are all primarily set in i40e_rx_hcksum. If rx checksum
510da5577f0SRobert Mustacchi 	 * activity is disabled, then these should all be zero.
511da5577f0SRobert Mustacchi 	 */
512da5577f0SRobert Mustacchi 	kstat_named_t	irxs_hck_v4hdrok;	/* Valid IPv4 Header */
513da5577f0SRobert Mustacchi 	kstat_named_t	irxs_hck_l4hdrok;	/* Valid L4 Header */
514da5577f0SRobert Mustacchi 	kstat_named_t	irxs_hck_unknown;	/* !pinfo.known */
515da5577f0SRobert Mustacchi 	kstat_named_t	irxs_hck_nol3l4p;	/* Missing L3L4P bit in desc */
516da5577f0SRobert Mustacchi 	kstat_named_t	irxs_hck_iperr;		/* IPE error bit set */
517da5577f0SRobert Mustacchi 	kstat_named_t	irxs_hck_eiperr;	/* EIPE error bit set */
518da5577f0SRobert Mustacchi 	kstat_named_t	irxs_hck_l4err;		/* L4E error bit set */
519da5577f0SRobert Mustacchi 	kstat_named_t	irxs_hck_v6skip;	/* IPv6 case hw fails on */
520da5577f0SRobert Mustacchi 	kstat_named_t	irxs_hck_set;		/* Total times we set cksum */
521da5577f0SRobert Mustacchi 	kstat_named_t	irxs_hck_miss;		/* Times with zero cksum bits */
522da5577f0SRobert Mustacchi } i40e_rxq_stat_t;
523da5577f0SRobert Mustacchi 
524da5577f0SRobert Mustacchi /*
525da5577f0SRobert Mustacchi  * Collection of TX Statistics on a given queue
526da5577f0SRobert Mustacchi  */
527da5577f0SRobert Mustacchi typedef struct i40e_txq_stat {
528da5577f0SRobert Mustacchi 	kstat_named_t	itxs_bytes;		/* Bytes out on queue */
529da5577f0SRobert Mustacchi 	kstat_named_t	itxs_packets;		/* Packets out on queue */
530da5577f0SRobert Mustacchi 	kstat_named_t	itxs_descriptors;	/* Descriptors issued */
531da5577f0SRobert Mustacchi 	kstat_named_t	itxs_recycled;		/* Descriptors reclaimed */
532*8d5069bcSRyan Zezeski 	kstat_named_t	itxs_force_copy;	/* non-TSO force copy */
533*8d5069bcSRyan Zezeski 	kstat_named_t	itxs_tso_force_copy;	/* TSO force copy */
534da5577f0SRobert Mustacchi 	/*
535da5577f0SRobert Mustacchi 	 * Various failure conditions.
536da5577f0SRobert Mustacchi 	 */
537da5577f0SRobert Mustacchi 	kstat_named_t	itxs_hck_meoifail;	/* ether offload failures */
538da5577f0SRobert Mustacchi 	kstat_named_t	itxs_hck_nol2info;	/* Missing l2 info */
539da5577f0SRobert Mustacchi 	kstat_named_t	itxs_hck_nol3info;	/* Missing l3 info */
540da5577f0SRobert Mustacchi 	kstat_named_t	itxs_hck_nol4info;	/* Missing l4 info */
541da5577f0SRobert Mustacchi 	kstat_named_t	itxs_hck_badl3;		/* Not IPv4/IPv6 */
542da5577f0SRobert Mustacchi 	kstat_named_t	itxs_hck_badl4;		/* Bad L4 Paylaod */
543*8d5069bcSRyan Zezeski 	kstat_named_t	itxs_lso_nohck;		/* Missing offloads for LSO */
544*8d5069bcSRyan Zezeski 	kstat_named_t	itxs_bind_fails;	/* DMA bind failures */
545*8d5069bcSRyan Zezeski 	kstat_named_t	itxs_tx_short;		/* Tx chain too short */
546da5577f0SRobert Mustacchi 
547da5577f0SRobert Mustacchi 	kstat_named_t	itxs_err_notcb;		/* No tcb's available */
548da5577f0SRobert Mustacchi 	kstat_named_t	itxs_err_nodescs;	/* No tcb's available */
549da5577f0SRobert Mustacchi 	kstat_named_t	itxs_err_context;	/* Total context failures */
550da5577f0SRobert Mustacchi 
551da5577f0SRobert Mustacchi 	kstat_named_t	itxs_num_unblocked;	/* Number of MAC unblocks */
552da5577f0SRobert Mustacchi } i40e_txq_stat_t;
553da5577f0SRobert Mustacchi 
554da5577f0SRobert Mustacchi /*
555da5577f0SRobert Mustacchi  * An instance of an XL710 transmit/receive queue pair. This currently
556da5577f0SRobert Mustacchi  * represents a combination of both a transmit and receive ring, though they
557da5577f0SRobert Mustacchi  * should really be split apart into separate logical structures. Unfortunately,
558da5577f0SRobert Mustacchi  * during initial work we mistakenly joined them together.
559da5577f0SRobert Mustacchi  */
560da5577f0SRobert Mustacchi typedef struct i40e_trqpair {
561da5577f0SRobert Mustacchi 	struct i40e *itrq_i40e;
562da5577f0SRobert Mustacchi 
563da5577f0SRobert Mustacchi 	/* Receive-side structures. */
564da5577f0SRobert Mustacchi 	kmutex_t itrq_rx_lock;
565da5577f0SRobert Mustacchi 	mac_ring_handle_t itrq_macrxring; /* Receive ring handle. */
566da5577f0SRobert Mustacchi 	i40e_rx_data_t *itrq_rxdata;	/* Receive ring rx data. */
567da5577f0SRobert Mustacchi 	uint64_t itrq_rxgen;		/* Generation number for mac/GLDv3. */
568da5577f0SRobert Mustacchi 	uint32_t itrq_index;		/* Queue index in the PF */
569da5577f0SRobert Mustacchi 	uint32_t itrq_rx_intrvec;	/* Receive interrupt vector. */
57005768666SPaul Winder 	boolean_t itrq_intr_poll;	/* True when polling */
571da5577f0SRobert Mustacchi 
572da5577f0SRobert Mustacchi 	/* Receive-side stats. */
573da5577f0SRobert Mustacchi 	i40e_rxq_stat_t	itrq_rxstat;
574da5577f0SRobert Mustacchi 	kstat_t	*itrq_rxkstat;
575da5577f0SRobert Mustacchi 
576da5577f0SRobert Mustacchi 	/* Transmit-side structures. */
577da5577f0SRobert Mustacchi 	kmutex_t itrq_tx_lock;
578da5577f0SRobert Mustacchi 	mac_ring_handle_t itrq_mactxring; /* Transmit ring handle. */
579da5577f0SRobert Mustacchi 	uint32_t itrq_tx_intrvec;	/* Transmit interrupt vector. */
580da5577f0SRobert Mustacchi 	boolean_t itrq_tx_blocked;	/* Does MAC think we're blocked? */
581da5577f0SRobert Mustacchi 
582da5577f0SRobert Mustacchi 	/*
583da5577f0SRobert Mustacchi 	 * TX data sizing
584da5577f0SRobert Mustacchi 	 */
585da5577f0SRobert Mustacchi 	uint32_t		itrq_tx_ring_size;
586da5577f0SRobert Mustacchi 	uint32_t		itrq_tx_free_list_size;
587da5577f0SRobert Mustacchi 
588da5577f0SRobert Mustacchi 	/*
589da5577f0SRobert Mustacchi 	 * TX descriptor ring data
590da5577f0SRobert Mustacchi 	 */
591da5577f0SRobert Mustacchi 	i40e_dma_buffer_t	itrq_desc_area;	/* DMA buffer of tx desc ring */
592da5577f0SRobert Mustacchi 	i40e_tx_desc_t		*itrq_desc_ring; /* TX Desc ring */
593da5577f0SRobert Mustacchi 	volatile uint32_t 	*itrq_desc_wbhead; /* TX write-back index */
594da5577f0SRobert Mustacchi 	uint32_t		itrq_desc_head;	/* Last index hw freed */
595da5577f0SRobert Mustacchi 	uint32_t		itrq_desc_tail;	/* Index of next free desc */
596da5577f0SRobert Mustacchi 	uint32_t		itrq_desc_free;	/* Number of free descriptors */
597da5577f0SRobert Mustacchi 
598da5577f0SRobert Mustacchi 	/*
599da5577f0SRobert Mustacchi 	 * TX control block (tcb) data
600da5577f0SRobert Mustacchi 	 */
601da5577f0SRobert Mustacchi 	kmutex_t		itrq_tcb_lock;
602da5577f0SRobert Mustacchi 	i40e_tx_control_block_t	*itrq_tcb_area;	/* Array of control blocks */
603da5577f0SRobert Mustacchi 	i40e_tx_control_block_t	**itrq_tcb_work_list;	/* In use tcb */
604da5577f0SRobert Mustacchi 	i40e_tx_control_block_t	**itrq_tcb_free_list;	/* Available tcb */
605da5577f0SRobert Mustacchi 	uint32_t		itrq_tcb_free;	/* Count of free tcb */
606da5577f0SRobert Mustacchi 
607da5577f0SRobert Mustacchi 	/* Transmit-side stats. */
608da5577f0SRobert Mustacchi 	i40e_txq_stat_t		itrq_txstat;
609da5577f0SRobert Mustacchi 	kstat_t			*itrq_txkstat;
610da5577f0SRobert Mustacchi 
611da5577f0SRobert Mustacchi } i40e_trqpair_t;
612da5577f0SRobert Mustacchi 
613da5577f0SRobert Mustacchi /*
614da5577f0SRobert Mustacchi  * VSI statistics.
615da5577f0SRobert Mustacchi  *
616da5577f0SRobert Mustacchi  * This mirrors the i40e_eth_stats structure but transforms it into a kstat.
617da5577f0SRobert Mustacchi  * Note that the stock statistic structure also includes entries for tx
618da5577f0SRobert Mustacchi  * discards. However, this is not actually implemented for the VSI (see Table
619da5577f0SRobert Mustacchi  * 7-221), hence why we don't include the member which would always have a value
620da5577f0SRobert Mustacchi  * of zero. This choice was made to minimize confusion to someone looking at
621da5577f0SRobert Mustacchi  * these, as a value of zero does not necessarily equate to the fact that it's
622da5577f0SRobert Mustacchi  * not implemented.
623da5577f0SRobert Mustacchi  */
624da5577f0SRobert Mustacchi typedef struct i40e_vsi_stats {
625da5577f0SRobert Mustacchi 	uint64_t ivs_rx_bytes;			/* gorc */
626da5577f0SRobert Mustacchi 	uint64_t ivs_rx_unicast;		/* uprc */
627da5577f0SRobert Mustacchi 	uint64_t ivs_rx_multicast;		/* mprc */
628da5577f0SRobert Mustacchi 	uint64_t ivs_rx_broadcast;		/* bprc */
629da5577f0SRobert Mustacchi 	uint64_t ivs_rx_discards;		/* rdpc */
630da5577f0SRobert Mustacchi 	uint64_t ivs_rx_unknown_protocol;	/* rupp */
631da5577f0SRobert Mustacchi 	uint64_t ivs_tx_bytes;			/* gotc */
632da5577f0SRobert Mustacchi 	uint64_t ivs_tx_unicast;		/* uptc */
633da5577f0SRobert Mustacchi 	uint64_t ivs_tx_multicast;		/* mptc */
634da5577f0SRobert Mustacchi 	uint64_t ivs_tx_broadcast;		/* bptc */
635da5577f0SRobert Mustacchi 	uint64_t ivs_tx_errors;			/* tepc */
636da5577f0SRobert Mustacchi } i40e_vsi_stats_t;
637da5577f0SRobert Mustacchi 
638da5577f0SRobert Mustacchi typedef struct i40e_vsi_kstats {
639da5577f0SRobert Mustacchi 	kstat_named_t	ivk_rx_bytes;
640da5577f0SRobert Mustacchi 	kstat_named_t	ivk_rx_unicast;
641da5577f0SRobert Mustacchi 	kstat_named_t	ivk_rx_multicast;
642da5577f0SRobert Mustacchi 	kstat_named_t	ivk_rx_broadcast;
643da5577f0SRobert Mustacchi 	kstat_named_t	ivk_rx_discards;
644da5577f0SRobert Mustacchi 	kstat_named_t	ivk_rx_unknown_protocol;
645da5577f0SRobert Mustacchi 	kstat_named_t	ivk_tx_bytes;
646da5577f0SRobert Mustacchi 	kstat_named_t	ivk_tx_unicast;
647da5577f0SRobert Mustacchi 	kstat_named_t	ivk_tx_multicast;
648da5577f0SRobert Mustacchi 	kstat_named_t	ivk_tx_broadcast;
649da5577f0SRobert Mustacchi 	kstat_named_t	ivk_tx_errors;
650da5577f0SRobert Mustacchi } i40e_vsi_kstats_t;
651da5577f0SRobert Mustacchi 
652da5577f0SRobert Mustacchi /*
653da5577f0SRobert Mustacchi  * For pf statistics, we opt not to use the standard statistics as defined by
654da5577f0SRobert Mustacchi  * the Intel common code. This also currently combines statistics that are
655da5577f0SRobert Mustacchi  * global across the entire device.
656da5577f0SRobert Mustacchi  */
657da5577f0SRobert Mustacchi typedef struct i40e_pf_stats {
658da5577f0SRobert Mustacchi 	uint64_t ips_rx_bytes;			/* gorc */
659da5577f0SRobert Mustacchi 	uint64_t ips_rx_unicast;		/* uprc */
660da5577f0SRobert Mustacchi 	uint64_t ips_rx_multicast;		/* mprc */
661da5577f0SRobert Mustacchi 	uint64_t ips_rx_broadcast;		/* bprc */
662da5577f0SRobert Mustacchi 	uint64_t ips_tx_bytes;			/* gotc */
663da5577f0SRobert Mustacchi 	uint64_t ips_tx_unicast;		/* uptc */
664da5577f0SRobert Mustacchi 	uint64_t ips_tx_multicast;		/* mptc */
665da5577f0SRobert Mustacchi 	uint64_t ips_tx_broadcast;		/* bptc */
666da5577f0SRobert Mustacchi 
667da5577f0SRobert Mustacchi 	uint64_t ips_rx_size_64;		/* prc64 */
668da5577f0SRobert Mustacchi 	uint64_t ips_rx_size_127;		/* prc127 */
669da5577f0SRobert Mustacchi 	uint64_t ips_rx_size_255;		/* prc255 */
670da5577f0SRobert Mustacchi 	uint64_t ips_rx_size_511;		/* prc511 */
671da5577f0SRobert Mustacchi 	uint64_t ips_rx_size_1023;		/* prc1023 */
672da5577f0SRobert Mustacchi 	uint64_t ips_rx_size_1522;		/* prc1522 */
673da5577f0SRobert Mustacchi 	uint64_t ips_rx_size_9522;		/* prc9522 */
674da5577f0SRobert Mustacchi 
675da5577f0SRobert Mustacchi 	uint64_t ips_tx_size_64;		/* ptc64 */
676da5577f0SRobert Mustacchi 	uint64_t ips_tx_size_127;		/* ptc127 */
677da5577f0SRobert Mustacchi 	uint64_t ips_tx_size_255;		/* ptc255 */
678da5577f0SRobert Mustacchi 	uint64_t ips_tx_size_511;		/* ptc511 */
679da5577f0SRobert Mustacchi 	uint64_t ips_tx_size_1023;		/* ptc1023 */
680da5577f0SRobert Mustacchi 	uint64_t ips_tx_size_1522;		/* ptc1522 */
681da5577f0SRobert Mustacchi 	uint64_t ips_tx_size_9522;		/* ptc9522 */
682da5577f0SRobert Mustacchi 
683da5577f0SRobert Mustacchi 	uint64_t ips_link_xon_rx;		/* lxonrxc */
684da5577f0SRobert Mustacchi 	uint64_t ips_link_xoff_rx;		/* lxoffrxc */
685da5577f0SRobert Mustacchi 	uint64_t ips_link_xon_tx;		/* lxontxc */
686da5577f0SRobert Mustacchi 	uint64_t ips_link_xoff_tx;		/* lxofftxc */
687da5577f0SRobert Mustacchi 	uint64_t ips_priority_xon_rx[8];	/* pxonrxc[8] */
688da5577f0SRobert Mustacchi 	uint64_t ips_priority_xoff_rx[8];	/* pxoffrxc[8] */
689da5577f0SRobert Mustacchi 	uint64_t ips_priority_xon_tx[8];	/* pxontxc[8] */
690da5577f0SRobert Mustacchi 	uint64_t ips_priority_xoff_tx[8];	/* pxofftxc[8] */
691da5577f0SRobert Mustacchi 	uint64_t ips_priority_xon_2_xoff[8];	/* rxon2offcnt[8] */
692da5577f0SRobert Mustacchi 
693da5577f0SRobert Mustacchi 	uint64_t ips_crc_errors;		/* crcerrs */
694da5577f0SRobert Mustacchi 	uint64_t ips_illegal_bytes;		/* illerrc */
695da5577f0SRobert Mustacchi 	uint64_t ips_mac_local_faults;		/* mlfc */
696da5577f0SRobert Mustacchi 	uint64_t ips_mac_remote_faults;		/* mrfc */
697da5577f0SRobert Mustacchi 	uint64_t ips_rx_length_errors;		/* rlec */
698da5577f0SRobert Mustacchi 	uint64_t ips_rx_undersize;		/* ruc */
699da5577f0SRobert Mustacchi 	uint64_t ips_rx_fragments;		/* rfc */
700da5577f0SRobert Mustacchi 	uint64_t ips_rx_oversize;		/* roc */
701da5577f0SRobert Mustacchi 	uint64_t ips_rx_jabber;			/* rjc */
702da5577f0SRobert Mustacchi 	uint64_t ips_rx_discards;		/* rdpc */
703da5577f0SRobert Mustacchi 	uint64_t ips_rx_vm_discards;		/* ldpc */
704da5577f0SRobert Mustacchi 	uint64_t ips_rx_short_discards;		/* mspdc */
705da5577f0SRobert Mustacchi 	uint64_t ips_tx_dropped_link_down;	/* tdold */
706da5577f0SRobert Mustacchi 	uint64_t ips_rx_unknown_protocol;	/* rupp */
707da5577f0SRobert Mustacchi 	uint64_t ips_rx_err1;			/* rxerr1 */
708da5577f0SRobert Mustacchi 	uint64_t ips_rx_err2;			/* rxerr2 */
709da5577f0SRobert Mustacchi } i40e_pf_stats_t;
710da5577f0SRobert Mustacchi 
711da5577f0SRobert Mustacchi typedef struct i40e_pf_kstats {
712da5577f0SRobert Mustacchi 	kstat_named_t ipk_rx_bytes;		/* gorc */
713da5577f0SRobert Mustacchi 	kstat_named_t ipk_rx_unicast;		/* uprc */
714da5577f0SRobert Mustacchi 	kstat_named_t ipk_rx_multicast;		/* mprc */
715da5577f0SRobert Mustacchi 	kstat_named_t ipk_rx_broadcast;		/* bprc */
716da5577f0SRobert Mustacchi 	kstat_named_t ipk_tx_bytes;		/* gotc */
717da5577f0SRobert Mustacchi 	kstat_named_t ipk_tx_unicast;		/* uptc */
718da5577f0SRobert Mustacchi 	kstat_named_t ipk_tx_multicast;		/* mptc */
719da5577f0SRobert Mustacchi 	kstat_named_t ipk_tx_broadcast;		/* bptc */
720da5577f0SRobert Mustacchi 
721da5577f0SRobert Mustacchi 	kstat_named_t ipk_rx_size_64;		/* prc64 */
722da5577f0SRobert Mustacchi 	kstat_named_t ipk_rx_size_127;		/* prc127 */
723da5577f0SRobert Mustacchi 	kstat_named_t ipk_rx_size_255;		/* prc255 */
724da5577f0SRobert Mustacchi 	kstat_named_t ipk_rx_size_511;		/* prc511 */
725da5577f0SRobert Mustacchi 	kstat_named_t ipk_rx_size_1023;		/* prc1023 */
726da5577f0SRobert Mustacchi 	kstat_named_t ipk_rx_size_1522;		/* prc1522 */
727da5577f0SRobert Mustacchi 	kstat_named_t ipk_rx_size_9522;		/* prc9522 */
728da5577f0SRobert Mustacchi 
729da5577f0SRobert Mustacchi 	kstat_named_t ipk_tx_size_64;		/* ptc64 */
730da5577f0SRobert Mustacchi 	kstat_named_t ipk_tx_size_127;		/* ptc127 */
731da5577f0SRobert Mustacchi 	kstat_named_t ipk_tx_size_255;		/* ptc255 */
732da5577f0SRobert Mustacchi 	kstat_named_t ipk_tx_size_511;		/* ptc511 */
733da5577f0SRobert Mustacchi 	kstat_named_t ipk_tx_size_1023;		/* ptc1023 */
734da5577f0SRobert Mustacchi 	kstat_named_t ipk_tx_size_1522;		/* ptc1522 */
735da5577f0SRobert Mustacchi 	kstat_named_t ipk_tx_size_9522;		/* ptc9522 */
736da5577f0SRobert Mustacchi 
737da5577f0SRobert Mustacchi 	kstat_named_t ipk_link_xon_rx;		/* lxonrxc */
738da5577f0SRobert Mustacchi 	kstat_named_t ipk_link_xoff_rx;		/* lxoffrxc */
739da5577f0SRobert Mustacchi 	kstat_named_t ipk_link_xon_tx;		/* lxontxc */
740da5577f0SRobert Mustacchi 	kstat_named_t ipk_link_xoff_tx;		/* lxofftxc */
741da5577f0SRobert Mustacchi 	kstat_named_t ipk_priority_xon_rx[8];	/* pxonrxc[8] */
742da5577f0SRobert Mustacchi 	kstat_named_t ipk_priority_xoff_rx[8];	/* pxoffrxc[8] */
743da5577f0SRobert Mustacchi 	kstat_named_t ipk_priority_xon_tx[8];	/* pxontxc[8] */
744da5577f0SRobert Mustacchi 	kstat_named_t ipk_priority_xoff_tx[8];	/* pxofftxc[8] */
745da5577f0SRobert Mustacchi 	kstat_named_t ipk_priority_xon_2_xoff[8];	/* rxon2offcnt[8] */
746da5577f0SRobert Mustacchi 
747da5577f0SRobert Mustacchi 	kstat_named_t ipk_crc_errors;		/* crcerrs */
748da5577f0SRobert Mustacchi 	kstat_named_t ipk_illegal_bytes;	/* illerrc */
749da5577f0SRobert Mustacchi 	kstat_named_t ipk_mac_local_faults;	/* mlfc */
750da5577f0SRobert Mustacchi 	kstat_named_t ipk_mac_remote_faults;	/* mrfc */
751da5577f0SRobert Mustacchi 	kstat_named_t ipk_rx_length_errors;	/* rlec */
752da5577f0SRobert Mustacchi 	kstat_named_t ipk_rx_undersize;		/* ruc */
753da5577f0SRobert Mustacchi 	kstat_named_t ipk_rx_fragments;		/* rfc */
754da5577f0SRobert Mustacchi 	kstat_named_t ipk_rx_oversize;		/* roc */
755da5577f0SRobert Mustacchi 	kstat_named_t ipk_rx_jabber;		/* rjc */
756da5577f0SRobert Mustacchi 	kstat_named_t ipk_rx_discards;		/* rdpc */
757da5577f0SRobert Mustacchi 	kstat_named_t ipk_rx_vm_discards;	/* ldpc */
758da5577f0SRobert Mustacchi 	kstat_named_t ipk_rx_short_discards;	/* mspdc */
759da5577f0SRobert Mustacchi 	kstat_named_t ipk_tx_dropped_link_down;	/* tdold */
760da5577f0SRobert Mustacchi 	kstat_named_t ipk_rx_unknown_protocol;	/* rupp */
761da5577f0SRobert Mustacchi 	kstat_named_t ipk_rx_err1;		/* rxerr1 */
762da5577f0SRobert Mustacchi 	kstat_named_t ipk_rx_err2;		/* rxerr2 */
763da5577f0SRobert Mustacchi } i40e_pf_kstats_t;
764da5577f0SRobert Mustacchi 
765da5577f0SRobert Mustacchi /*
766da5577f0SRobert Mustacchi  * Resources that are pooled and specific to a given i40e_t.
767da5577f0SRobert Mustacchi  */
768da5577f0SRobert Mustacchi typedef struct i40e_func_rsrc {
769da5577f0SRobert Mustacchi 	uint_t	ifr_nrx_queue;
770da5577f0SRobert Mustacchi 	uint_t	ifr_nrx_queue_used;
771da5577f0SRobert Mustacchi 	uint_t	ifr_ntx_queue;
772da5577f0SRobert Mustacchi 	uint_t	ifr_trx_queue_used;
773da5577f0SRobert Mustacchi 	uint_t	ifr_nvsis;
774da5577f0SRobert Mustacchi 	uint_t	ifr_nvsis_used;
775da5577f0SRobert Mustacchi 	uint_t	ifr_nmacfilt;
776da5577f0SRobert Mustacchi 	uint_t	ifr_nmacfilt_used;
777da5577f0SRobert Mustacchi 	uint_t	ifr_nmcastfilt;
778da5577f0SRobert Mustacchi 	uint_t	ifr_nmcastfilt_used;
779da5577f0SRobert Mustacchi } i40e_func_rsrc_t;
780da5577f0SRobert Mustacchi 
781*8d5069bcSRyan Zezeski typedef struct i40e_vsi {
782*8d5069bcSRyan Zezeski 	uint16_t		iv_seid;
783*8d5069bcSRyan Zezeski 	uint16_t		iv_number;
784*8d5069bcSRyan Zezeski 	kstat_t			*iv_kstats;
785*8d5069bcSRyan Zezeski 	i40e_vsi_stats_t	iv_stats;
786*8d5069bcSRyan Zezeski 	uint16_t		iv_stats_id;
787*8d5069bcSRyan Zezeski } i40e_vsi_t;
788*8d5069bcSRyan Zezeski 
789*8d5069bcSRyan Zezeski /*
790*8d5069bcSRyan Zezeski  * While irg_index and irg_grp_hdl aren't used anywhere, they are
791*8d5069bcSRyan Zezeski  * still useful for debugging.
792*8d5069bcSRyan Zezeski  */
793*8d5069bcSRyan Zezeski typedef struct i40e_rx_group {
794*8d5069bcSRyan Zezeski 	uint32_t		irg_index;    /* index in i40e_rx_groups[] */
795*8d5069bcSRyan Zezeski 	uint16_t		irg_vsi_seid; /* SEID of VSI for this group */
796*8d5069bcSRyan Zezeski 	mac_group_handle_t	irg_grp_hdl;  /* handle to mac_group_t */
797*8d5069bcSRyan Zezeski 	struct i40e		*irg_i40e;    /* ref to i40e_t */
798*8d5069bcSRyan Zezeski } i40e_rx_group_t;
799*8d5069bcSRyan Zezeski 
800da5577f0SRobert Mustacchi /*
801da5577f0SRobert Mustacchi  * Main i40e per-instance state.
802da5577f0SRobert Mustacchi  */
803da5577f0SRobert Mustacchi typedef struct i40e {
804da5577f0SRobert Mustacchi 	list_node_t	i40e_glink;		/* Global list link */
805da5577f0SRobert Mustacchi 	list_node_t	i40e_dlink;		/* Device list link */
806da5577f0SRobert Mustacchi 	kmutex_t	i40e_general_lock;	/* General device lock */
807da5577f0SRobert Mustacchi 
808da5577f0SRobert Mustacchi 	/*
809da5577f0SRobert Mustacchi 	 * General Data and management
810da5577f0SRobert Mustacchi 	 */
811da5577f0SRobert Mustacchi 	dev_info_t	*i40e_dip;
812da5577f0SRobert Mustacchi 	int		i40e_instance;
813da5577f0SRobert Mustacchi 	int		i40e_fm_capabilities;
814da5577f0SRobert Mustacchi 	uint_t		i40e_state;
815da5577f0SRobert Mustacchi 	i40e_attach_state_t i40e_attach_progress;
816da5577f0SRobert Mustacchi 	mac_handle_t	i40e_mac_hdl;
817da5577f0SRobert Mustacchi 	ddi_periodic_t	i40e_periodic_id;
818da5577f0SRobert Mustacchi 
819da5577f0SRobert Mustacchi 	/*
820da5577f0SRobert Mustacchi 	 * Pointers to common code data structures and memory for the common
821da5577f0SRobert Mustacchi 	 * code.
822da5577f0SRobert Mustacchi 	 */
823da5577f0SRobert Mustacchi 	struct i40e_hw				i40e_hw_space;
824da5577f0SRobert Mustacchi 	struct i40e_osdep			i40e_osdep_space;
825da5577f0SRobert Mustacchi 	struct i40e_aq_get_phy_abilities_resp	i40e_phy;
826da5577f0SRobert Mustacchi 	void 					*i40e_aqbuf;
827da5577f0SRobert Mustacchi 
828*8d5069bcSRyan Zezeski #define	I40E_DEF_VSI_IDX	0
829*8d5069bcSRyan Zezeski #define	I40E_DEF_VSI(i40e)	((i40e)->i40e_vsis[I40E_DEF_VSI_IDX])
830*8d5069bcSRyan Zezeski #define	I40E_DEF_VSI_SEID(i40e)	(I40E_DEF_VSI(i40e).iv_seid)
831*8d5069bcSRyan Zezeski 
832da5577f0SRobert Mustacchi 	/*
833da5577f0SRobert Mustacchi 	 * Device state, switch information, and resources.
834da5577f0SRobert Mustacchi 	 */
835*8d5069bcSRyan Zezeski 	i40e_vsi_t		i40e_vsis[I40E_GROUP_MAX];
836*8d5069bcSRyan Zezeski 	uint16_t		i40e_mac_seid;	 /* SEID of physical MAC */
837*8d5069bcSRyan Zezeski 	uint16_t		i40e_veb_seid;	 /* switch atop MAC (SEID) */
838*8d5069bcSRyan Zezeski 	uint16_t		i40e_vsi_avail;	 /* VSIs avail to this PF */
839*8d5069bcSRyan Zezeski 	uint16_t		i40e_vsi_used;	 /* VSIs used by this PF */
840da5577f0SRobert Mustacchi 	struct i40e_device	*i40e_device;
841da5577f0SRobert Mustacchi 	i40e_func_rsrc_t	i40e_resources;
842da5577f0SRobert Mustacchi 	uint16_t		i40e_switch_rsrc_alloc;
843da5577f0SRobert Mustacchi 	uint16_t		i40e_switch_rsrc_actual;
844da5577f0SRobert Mustacchi 	i40e_switch_rsrc_t	*i40e_switch_rsrcs;
845da5577f0SRobert Mustacchi 	i40e_uaddr_t		*i40e_uaddrs;
846da5577f0SRobert Mustacchi 	i40e_maddr_t		*i40e_maddrs;
847da5577f0SRobert Mustacchi 	int			i40e_mcast_promisc_count;
848da5577f0SRobert Mustacchi 	boolean_t		i40e_promisc_on;
849da5577f0SRobert Mustacchi 	link_state_t		i40e_link_state;
850da5577f0SRobert Mustacchi 	uint32_t		i40e_link_speed;	/* In Mbps */
851da5577f0SRobert Mustacchi 	link_duplex_t		i40e_link_duplex;
852da5577f0SRobert Mustacchi 	uint_t			i40e_sdu;
853da5577f0SRobert Mustacchi 	uint_t			i40e_frame_max;
854da5577f0SRobert Mustacchi 
855da5577f0SRobert Mustacchi 	/*
856da5577f0SRobert Mustacchi 	 * Transmit and receive information, tunables, and MAC info.
857da5577f0SRobert Mustacchi 	 */
858da5577f0SRobert Mustacchi 	i40e_trqpair_t	*i40e_trqpairs;
859da5577f0SRobert Mustacchi 	boolean_t 	i40e_mr_enable;
860*8d5069bcSRyan Zezeski 	uint_t		i40e_num_trqpairs; /* total TRQPs (per PF) */
861*8d5069bcSRyan Zezeski 	uint_t		i40e_num_trqpairs_per_vsi; /* TRQPs per VSI */
862da5577f0SRobert Mustacchi 	uint_t		i40e_other_itr;
863da5577f0SRobert Mustacchi 
864*8d5069bcSRyan Zezeski 	i40e_rx_group_t	*i40e_rx_groups;
865*8d5069bcSRyan Zezeski 	uint_t		i40e_num_rx_groups;
866da5577f0SRobert Mustacchi 	int		i40e_num_rx_descs;
867da5577f0SRobert Mustacchi 	uint32_t	i40e_rx_ring_size;
868da5577f0SRobert Mustacchi 	uint32_t	i40e_rx_buf_size;
869da5577f0SRobert Mustacchi 	boolean_t	i40e_rx_hcksum_enable;
870da5577f0SRobert Mustacchi 	uint32_t	i40e_rx_dma_min;
871da5577f0SRobert Mustacchi 	uint32_t	i40e_rx_limit_per_intr;
872da5577f0SRobert Mustacchi 	uint_t		i40e_rx_itr;
873da5577f0SRobert Mustacchi 
874da5577f0SRobert Mustacchi 	int		i40e_num_tx_descs;
875da5577f0SRobert Mustacchi 	uint32_t	i40e_tx_ring_size;
876da5577f0SRobert Mustacchi 	uint32_t	i40e_tx_buf_size;
877da5577f0SRobert Mustacchi 	uint32_t	i40e_tx_block_thresh;
878da5577f0SRobert Mustacchi 	boolean_t	i40e_tx_hcksum_enable;
879*8d5069bcSRyan Zezeski 	boolean_t	i40e_tx_lso_enable;
880da5577f0SRobert Mustacchi 	uint32_t	i40e_tx_dma_min;
881da5577f0SRobert Mustacchi 	uint_t		i40e_tx_itr;
882da5577f0SRobert Mustacchi 
883da5577f0SRobert Mustacchi 	/*
884da5577f0SRobert Mustacchi 	 * Interrupt state
885da5577f0SRobert Mustacchi 	 */
886da5577f0SRobert Mustacchi 	uint_t		i40e_intr_pri;
887da5577f0SRobert Mustacchi 	uint_t		i40e_intr_force;
888da5577f0SRobert Mustacchi 	uint_t		i40e_intr_type;
889da5577f0SRobert Mustacchi 	int		i40e_intr_cap;
890da5577f0SRobert Mustacchi 	uint32_t	i40e_intr_count;
891da5577f0SRobert Mustacchi 	uint32_t	i40e_intr_count_max;
892da5577f0SRobert Mustacchi 	uint32_t	i40e_intr_count_min;
893da5577f0SRobert Mustacchi 	size_t		i40e_intr_size;
894da5577f0SRobert Mustacchi 	ddi_intr_handle_t *i40e_intr_handles;
895da5577f0SRobert Mustacchi 	ddi_cb_handle_t	i40e_callback_handle;
896da5577f0SRobert Mustacchi 
897da5577f0SRobert Mustacchi 	/*
898da5577f0SRobert Mustacchi 	 * DMA attributes. See i40e_transceiver.c for why we have copies of them
899da5577f0SRobert Mustacchi 	 * in the i40e_t.
900da5577f0SRobert Mustacchi 	 */
901da5577f0SRobert Mustacchi 	ddi_dma_attr_t		i40e_static_dma_attr;
902da5577f0SRobert Mustacchi 	ddi_dma_attr_t		i40e_txbind_dma_attr;
903*8d5069bcSRyan Zezeski 	ddi_dma_attr_t		i40e_txbind_lso_dma_attr;
904da5577f0SRobert Mustacchi 	ddi_device_acc_attr_t	i40e_desc_acc_attr;
905da5577f0SRobert Mustacchi 	ddi_device_acc_attr_t	i40e_buf_acc_attr;
906da5577f0SRobert Mustacchi 
907da5577f0SRobert Mustacchi 	/*
908da5577f0SRobert Mustacchi 	 * The following two fields are used to protect and keep track of
909da5577f0SRobert Mustacchi 	 * outstanding, loaned buffers to MAC. If we have these, we can't
910da5577f0SRobert Mustacchi 	 * detach as we have active DMA memory outstanding.
911da5577f0SRobert Mustacchi 	 */
912da5577f0SRobert Mustacchi 	kmutex_t	i40e_rx_pending_lock;
913da5577f0SRobert Mustacchi 	kcondvar_t	i40e_rx_pending_cv;
914da5577f0SRobert Mustacchi 	uint32_t	i40e_rx_pending;
915da5577f0SRobert Mustacchi 
916da5577f0SRobert Mustacchi 	/*
917da5577f0SRobert Mustacchi 	 * PF statistics and VSI statistics.
918da5577f0SRobert Mustacchi 	 */
919da5577f0SRobert Mustacchi 	kmutex_t		i40e_stat_lock;
920da5577f0SRobert Mustacchi 	kstat_t			*i40e_pf_kstat;
921da5577f0SRobert Mustacchi 	i40e_pf_stats_t		i40e_pf_stat;
922da5577f0SRobert Mustacchi 
923da5577f0SRobert Mustacchi 	/*
924da5577f0SRobert Mustacchi 	 * Misc. stats and counters that should maybe one day be kstats.
925da5577f0SRobert Mustacchi 	 */
926da5577f0SRobert Mustacchi 	uint64_t	i40e_s_link_status_errs;
927da5577f0SRobert Mustacchi 	uint32_t	i40e_s_link_status_lasterr;
928b142f83dSRobert Mustacchi 
929b142f83dSRobert Mustacchi 	/*
930b142f83dSRobert Mustacchi 	 * LED information. Note this state is only modified in
931b142f83dSRobert Mustacchi 	 * i40e_gld_set_led() which is protected by MAC's serializer lock.
932b142f83dSRobert Mustacchi 	 */
933b142f83dSRobert Mustacchi 	uint32_t	i40e_led_status;
934b142f83dSRobert Mustacchi 	boolean_t	i40e_led_saved;
935da5577f0SRobert Mustacchi } i40e_t;
936da5577f0SRobert Mustacchi 
937da5577f0SRobert Mustacchi /*
938da5577f0SRobert Mustacchi  * The i40e_device represents a PCI device which encapsulates multiple physical
939da5577f0SRobert Mustacchi  * functions which are represented as an i40e_t. This is used to track the use
940da5577f0SRobert Mustacchi  * of pooled resources throughout all of the various devices.
941da5577f0SRobert Mustacchi  */
942da5577f0SRobert Mustacchi typedef struct i40e_device {
943da5577f0SRobert Mustacchi 	list_node_t	id_link;
944da5577f0SRobert Mustacchi 	dev_info_t	*id_parent;
945da5577f0SRobert Mustacchi 	uint_t		id_pci_bus;
946da5577f0SRobert Mustacchi 	uint_t		id_pci_device;
947da5577f0SRobert Mustacchi 	uint_t		id_nfuncs;	/* Total number of functions */
948da5577f0SRobert Mustacchi 	uint_t		id_nreg;	/* Total number present */
949da5577f0SRobert Mustacchi 	list_t		id_i40e_list;	/* List of i40e_t's registered */
950da5577f0SRobert Mustacchi 	i40e_switch_rsrc_t	*id_rsrcs; /* Switch resources for this PF */
951da5577f0SRobert Mustacchi 	uint_t		id_rsrcs_alloc;	/* Total allocated resources */
952da5577f0SRobert Mustacchi 	uint_t		id_rsrcs_act;	/* Actual number of resources */
953da5577f0SRobert Mustacchi } i40e_device_t;
954da5577f0SRobert Mustacchi 
955da5577f0SRobert Mustacchi /* Values for the interrupt forcing on the NIC. */
956da5577f0SRobert Mustacchi #define	I40E_INTR_NONE			0
957da5577f0SRobert Mustacchi #define	I40E_INTR_MSIX			1
958da5577f0SRobert Mustacchi #define	I40E_INTR_MSI			2
959da5577f0SRobert Mustacchi #define	I40E_INTR_LEGACY		3
960da5577f0SRobert Mustacchi 
961da5577f0SRobert Mustacchi /* Hint that we don't want to do any polling... */
962da5577f0SRobert Mustacchi #define	I40E_POLL_NULL			-1
963da5577f0SRobert Mustacchi 
964da5577f0SRobert Mustacchi /*
965da5577f0SRobert Mustacchi  * Logging functions.
966da5577f0SRobert Mustacchi  */
967da5577f0SRobert Mustacchi /*PRINTFLIKE2*/
968da5577f0SRobert Mustacchi extern void i40e_error(i40e_t *, const char *, ...) __KPRINTFLIKE(2);
969da5577f0SRobert Mustacchi /*PRINTFLIKE2*/
970da5577f0SRobert Mustacchi extern void i40e_notice(i40e_t *, const char *, ...) __KPRINTFLIKE(2);
971da5577f0SRobert Mustacchi /*PRINTFLIKE2*/
972da5577f0SRobert Mustacchi extern void i40e_log(i40e_t *, const char *, ...) __KPRINTFLIKE(2);
973da5577f0SRobert Mustacchi 
974da5577f0SRobert Mustacchi /*
975da5577f0SRobert Mustacchi  * General link handling functions.
976da5577f0SRobert Mustacchi  */
977da5577f0SRobert Mustacchi extern void i40e_link_check(i40e_t *);
978da5577f0SRobert Mustacchi extern void i40e_update_mtu(i40e_t *);
979da5577f0SRobert Mustacchi 
980da5577f0SRobert Mustacchi /*
981da5577f0SRobert Mustacchi  * FMA functions.
982da5577f0SRobert Mustacchi  */
983da5577f0SRobert Mustacchi extern int i40e_check_acc_handle(ddi_acc_handle_t);
984da5577f0SRobert Mustacchi extern int i40e_check_dma_handle(ddi_dma_handle_t);
985da5577f0SRobert Mustacchi extern void i40e_fm_ereport(i40e_t *, char *);
986da5577f0SRobert Mustacchi 
987da5577f0SRobert Mustacchi /*
988da5577f0SRobert Mustacchi  * Interrupt handlers and interrupt handler setup.
989da5577f0SRobert Mustacchi  */
990da5577f0SRobert Mustacchi extern void i40e_intr_chip_init(i40e_t *);
991da5577f0SRobert Mustacchi extern void i40e_intr_chip_fini(i40e_t *);
992da5577f0SRobert Mustacchi extern uint_t i40e_intr_msix(void *, void *);
993da5577f0SRobert Mustacchi extern uint_t i40e_intr_msi(void *, void *);
994da5577f0SRobert Mustacchi extern uint_t i40e_intr_legacy(void *, void *);
995da5577f0SRobert Mustacchi extern void i40e_intr_io_enable_all(i40e_t *);
996da5577f0SRobert Mustacchi extern void i40e_intr_io_disable_all(i40e_t *);
997da5577f0SRobert Mustacchi extern void i40e_intr_io_clear_cause(i40e_t *);
9981b74b674SRobert Mustacchi extern void i40e_intr_rx_queue_disable(i40e_trqpair_t *);
9991b74b674SRobert Mustacchi extern void i40e_intr_rx_queue_enable(i40e_trqpair_t *);
1000da5577f0SRobert Mustacchi extern void i40e_intr_set_itr(i40e_t *, i40e_itr_index_t, uint_t);
1001da5577f0SRobert Mustacchi 
1002da5577f0SRobert Mustacchi /*
1003da5577f0SRobert Mustacchi  * Receive-side functions
1004da5577f0SRobert Mustacchi  */
1005da5577f0SRobert Mustacchi extern mblk_t *i40e_ring_rx(i40e_trqpair_t *, int);
1006da5577f0SRobert Mustacchi extern mblk_t *i40e_ring_rx_poll(void *, int);
1007da5577f0SRobert Mustacchi extern void i40e_rx_recycle(caddr_t);
1008da5577f0SRobert Mustacchi 
1009da5577f0SRobert Mustacchi /*
1010da5577f0SRobert Mustacchi  * Transmit-side functions
1011da5577f0SRobert Mustacchi  */
1012da5577f0SRobert Mustacchi mblk_t *i40e_ring_tx(void *, mblk_t *);
1013da5577f0SRobert Mustacchi extern void i40e_tx_recycle_ring(i40e_trqpair_t *);
1014da5577f0SRobert Mustacchi extern void i40e_tx_cleanup_ring(i40e_trqpair_t *);
1015da5577f0SRobert Mustacchi 
1016da5577f0SRobert Mustacchi /*
1017da5577f0SRobert Mustacchi  * Statistics functions.
1018da5577f0SRobert Mustacchi  */
1019da5577f0SRobert Mustacchi extern boolean_t i40e_stats_init(i40e_t *);
1020da5577f0SRobert Mustacchi extern void i40e_stats_fini(i40e_t *);
1021*8d5069bcSRyan Zezeski extern boolean_t i40e_stat_vsi_init(i40e_t *, uint_t);
1022*8d5069bcSRyan Zezeski extern void i40e_stat_vsi_fini(i40e_t *, uint_t);
1023da5577f0SRobert Mustacchi extern boolean_t i40e_stats_trqpair_init(i40e_trqpair_t *);
1024da5577f0SRobert Mustacchi extern void i40e_stats_trqpair_fini(i40e_trqpair_t *);
1025da5577f0SRobert Mustacchi extern int i40e_m_stat(void *, uint_t, uint64_t *);
1026da5577f0SRobert Mustacchi extern int i40e_rx_ring_stat(mac_ring_driver_t, uint_t, uint64_t *);
1027da5577f0SRobert Mustacchi extern int i40e_tx_ring_stat(mac_ring_driver_t, uint_t, uint64_t *);
1028da5577f0SRobert Mustacchi 
1029da5577f0SRobert Mustacchi /*
1030da5577f0SRobert Mustacchi  * MAC/GLDv3 functions, and functions called by MAC/GLDv3 support code.
1031da5577f0SRobert Mustacchi  */
1032da5577f0SRobert Mustacchi extern boolean_t i40e_register_mac(i40e_t *);
1033da5577f0SRobert Mustacchi extern boolean_t i40e_start(i40e_t *, boolean_t);
1034da5577f0SRobert Mustacchi extern void i40e_stop(i40e_t *, boolean_t);
1035da5577f0SRobert Mustacchi 
1036da5577f0SRobert Mustacchi /*
1037da5577f0SRobert Mustacchi  * DMA & buffer functions and attributes
1038da5577f0SRobert Mustacchi  */
1039da5577f0SRobert Mustacchi extern void i40e_init_dma_attrs(i40e_t *, boolean_t);
1040da5577f0SRobert Mustacchi extern boolean_t i40e_alloc_ring_mem(i40e_t *);
1041da5577f0SRobert Mustacchi extern void i40e_free_ring_mem(i40e_t *, boolean_t);
1042da5577f0SRobert Mustacchi 
1043da5577f0SRobert Mustacchi #ifdef __cplusplus
1044da5577f0SRobert Mustacchi }
1045da5577f0SRobert Mustacchi #endif
1046da5577f0SRobert Mustacchi 
1047da5577f0SRobert Mustacchi #endif /* _I40E_SW_H */
1048