xref: /linux/drivers/net/ethernet/amd/xgbe/xgbe.h (revision 43e0dcf7084014258ed555690fd6653f689ec368)
1c5aa9e3bSLendacky, Thomas /*
2c5aa9e3bSLendacky, Thomas  * AMD 10Gb Ethernet driver
3c5aa9e3bSLendacky, Thomas  *
4c5aa9e3bSLendacky, Thomas  * This file is available to you under your choice of the following two
5c5aa9e3bSLendacky, Thomas  * licenses:
6c5aa9e3bSLendacky, Thomas  *
7c5aa9e3bSLendacky, Thomas  * License 1: GPLv2
8c5aa9e3bSLendacky, Thomas  *
9b3b71597SLendacky, Thomas  * Copyright (c) 2014-2016 Advanced Micro Devices, Inc.
10c5aa9e3bSLendacky, Thomas  *
11c5aa9e3bSLendacky, Thomas  * This file is free software; you may copy, redistribute and/or modify
12c5aa9e3bSLendacky, Thomas  * it under the terms of the GNU General Public License as published by
13c5aa9e3bSLendacky, Thomas  * the Free Software Foundation, either version 2 of the License, or (at
14c5aa9e3bSLendacky, Thomas  * your option) any later version.
15c5aa9e3bSLendacky, Thomas  *
16c5aa9e3bSLendacky, Thomas  * This file is distributed in the hope that it will be useful, but
17c5aa9e3bSLendacky, Thomas  * WITHOUT ANY WARRANTY; without even the implied warranty of
18c5aa9e3bSLendacky, Thomas  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19c5aa9e3bSLendacky, Thomas  * General Public License for more details.
20c5aa9e3bSLendacky, Thomas  *
21c5aa9e3bSLendacky, Thomas  * You should have received a copy of the GNU General Public License
22c5aa9e3bSLendacky, Thomas  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23c5aa9e3bSLendacky, Thomas  *
24c5aa9e3bSLendacky, Thomas  * This file incorporates work covered by the following copyright and
25c5aa9e3bSLendacky, Thomas  * permission notice:
26c5aa9e3bSLendacky, Thomas  *     The Synopsys DWC ETHER XGMAC Software Driver and documentation
27c5aa9e3bSLendacky, Thomas  *     (hereinafter "Software") is an unsupported proprietary work of Synopsys,
28c5aa9e3bSLendacky, Thomas  *     Inc. unless otherwise expressly agreed to in writing between Synopsys
29c5aa9e3bSLendacky, Thomas  *     and you.
30c5aa9e3bSLendacky, Thomas  *
31c5aa9e3bSLendacky, Thomas  *     The Software IS NOT an item of Licensed Software or Licensed Product
32c5aa9e3bSLendacky, Thomas  *     under any End User Software License Agreement or Agreement for Licensed
33c5aa9e3bSLendacky, Thomas  *     Product with Synopsys or any supplement thereto.  Permission is hereby
34c5aa9e3bSLendacky, Thomas  *     granted, free of charge, to any person obtaining a copy of this software
35c5aa9e3bSLendacky, Thomas  *     annotated with this license and the Software, to deal in the Software
36c5aa9e3bSLendacky, Thomas  *     without restriction, including without limitation the rights to use,
37c5aa9e3bSLendacky, Thomas  *     copy, modify, merge, publish, distribute, sublicense, and/or sell copies
38c5aa9e3bSLendacky, Thomas  *     of the Software, and to permit persons to whom the Software is furnished
39c5aa9e3bSLendacky, Thomas  *     to do so, subject to the following conditions:
40c5aa9e3bSLendacky, Thomas  *
41c5aa9e3bSLendacky, Thomas  *     The above copyright notice and this permission notice shall be included
42c5aa9e3bSLendacky, Thomas  *     in all copies or substantial portions of the Software.
43c5aa9e3bSLendacky, Thomas  *
44c5aa9e3bSLendacky, Thomas  *     THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
45c5aa9e3bSLendacky, Thomas  *     BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
46c5aa9e3bSLendacky, Thomas  *     TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
47c5aa9e3bSLendacky, Thomas  *     PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
48c5aa9e3bSLendacky, Thomas  *     BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
49c5aa9e3bSLendacky, Thomas  *     CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
50c5aa9e3bSLendacky, Thomas  *     SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
51c5aa9e3bSLendacky, Thomas  *     INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
52c5aa9e3bSLendacky, Thomas  *     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
53c5aa9e3bSLendacky, Thomas  *     ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
54c5aa9e3bSLendacky, Thomas  *     THE POSSIBILITY OF SUCH DAMAGE.
55c5aa9e3bSLendacky, Thomas  *
56c5aa9e3bSLendacky, Thomas  *
57c5aa9e3bSLendacky, Thomas  * License 2: Modified BSD
58c5aa9e3bSLendacky, Thomas  *
59b3b71597SLendacky, Thomas  * Copyright (c) 2014-2016 Advanced Micro Devices, Inc.
60c5aa9e3bSLendacky, Thomas  * All rights reserved.
61c5aa9e3bSLendacky, Thomas  *
62c5aa9e3bSLendacky, Thomas  * Redistribution and use in source and binary forms, with or without
63c5aa9e3bSLendacky, Thomas  * modification, are permitted provided that the following conditions are met:
64c5aa9e3bSLendacky, Thomas  *     * Redistributions of source code must retain the above copyright
65c5aa9e3bSLendacky, Thomas  *       notice, this list of conditions and the following disclaimer.
66c5aa9e3bSLendacky, Thomas  *     * Redistributions in binary form must reproduce the above copyright
67c5aa9e3bSLendacky, Thomas  *       notice, this list of conditions and the following disclaimer in the
68c5aa9e3bSLendacky, Thomas  *       documentation and/or other materials provided with the distribution.
69c5aa9e3bSLendacky, Thomas  *     * Neither the name of Advanced Micro Devices, Inc. nor the
70c5aa9e3bSLendacky, Thomas  *       names of its contributors may be used to endorse or promote products
71c5aa9e3bSLendacky, Thomas  *       derived from this software without specific prior written permission.
72c5aa9e3bSLendacky, Thomas  *
73c5aa9e3bSLendacky, Thomas  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
74c5aa9e3bSLendacky, Thomas  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
75c5aa9e3bSLendacky, Thomas  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
76c5aa9e3bSLendacky, Thomas  * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
77c5aa9e3bSLendacky, Thomas  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
78c5aa9e3bSLendacky, Thomas  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
79c5aa9e3bSLendacky, Thomas  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
80c5aa9e3bSLendacky, Thomas  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
81c5aa9e3bSLendacky, Thomas  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
82c5aa9e3bSLendacky, Thomas  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
83c5aa9e3bSLendacky, Thomas  *
84c5aa9e3bSLendacky, Thomas  * This file incorporates work covered by the following copyright and
85c5aa9e3bSLendacky, Thomas  * permission notice:
86c5aa9e3bSLendacky, Thomas  *     The Synopsys DWC ETHER XGMAC Software Driver and documentation
87c5aa9e3bSLendacky, Thomas  *     (hereinafter "Software") is an unsupported proprietary work of Synopsys,
88c5aa9e3bSLendacky, Thomas  *     Inc. unless otherwise expressly agreed to in writing between Synopsys
89c5aa9e3bSLendacky, Thomas  *     and you.
90c5aa9e3bSLendacky, Thomas  *
91c5aa9e3bSLendacky, Thomas  *     The Software IS NOT an item of Licensed Software or Licensed Product
92c5aa9e3bSLendacky, Thomas  *     under any End User Software License Agreement or Agreement for Licensed
93c5aa9e3bSLendacky, Thomas  *     Product with Synopsys or any supplement thereto.  Permission is hereby
94c5aa9e3bSLendacky, Thomas  *     granted, free of charge, to any person obtaining a copy of this software
95c5aa9e3bSLendacky, Thomas  *     annotated with this license and the Software, to deal in the Software
96c5aa9e3bSLendacky, Thomas  *     without restriction, including without limitation the rights to use,
97c5aa9e3bSLendacky, Thomas  *     copy, modify, merge, publish, distribute, sublicense, and/or sell copies
98c5aa9e3bSLendacky, Thomas  *     of the Software, and to permit persons to whom the Software is furnished
99c5aa9e3bSLendacky, Thomas  *     to do so, subject to the following conditions:
100c5aa9e3bSLendacky, Thomas  *
101c5aa9e3bSLendacky, Thomas  *     The above copyright notice and this permission notice shall be included
102c5aa9e3bSLendacky, Thomas  *     in all copies or substantial portions of the Software.
103c5aa9e3bSLendacky, Thomas  *
104c5aa9e3bSLendacky, Thomas  *     THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
105c5aa9e3bSLendacky, Thomas  *     BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
106c5aa9e3bSLendacky, Thomas  *     TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
107c5aa9e3bSLendacky, Thomas  *     PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
108c5aa9e3bSLendacky, Thomas  *     BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
109c5aa9e3bSLendacky, Thomas  *     CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
110c5aa9e3bSLendacky, Thomas  *     SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
111c5aa9e3bSLendacky, Thomas  *     INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
112c5aa9e3bSLendacky, Thomas  *     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
113c5aa9e3bSLendacky, Thomas  *     ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
114c5aa9e3bSLendacky, Thomas  *     THE POSSIBILITY OF SUCH DAMAGE.
115c5aa9e3bSLendacky, Thomas  */
116c5aa9e3bSLendacky, Thomas 
117c5aa9e3bSLendacky, Thomas #ifndef __XGBE_H__
118c5aa9e3bSLendacky, Thomas #define __XGBE_H__
119c5aa9e3bSLendacky, Thomas 
120c5aa9e3bSLendacky, Thomas #include <linux/dma-mapping.h>
121c5aa9e3bSLendacky, Thomas #include <linux/netdevice.h>
122c5aa9e3bSLendacky, Thomas #include <linux/workqueue.h>
123c5aa9e3bSLendacky, Thomas #include <linux/phy.h>
124801c62d9SLendacky, Thomas #include <linux/if_vlan.h>
125801c62d9SLendacky, Thomas #include <linux/bitops.h>
12623e4eef7SLendacky, Thomas #include <linux/ptp_clock_kernel.h>
12774d23cc7SRichard Cochran #include <linux/timecounter.h>
12823e4eef7SLendacky, Thomas #include <linux/net_tstamp.h>
129fca2d994SLendacky, Thomas #include <net/dcbnl.h>
130c5aa9e3bSLendacky, Thomas 
131c5aa9e3bSLendacky, Thomas #define XGBE_DRV_NAME		"amd-xgbe"
13234bfff40SLendacky, Thomas #define XGBE_DRV_VERSION	"1.0.2"
133c5aa9e3bSLendacky, Thomas #define XGBE_DRV_DESC		"AMD 10 Gigabit Ethernet Driver"
134c5aa9e3bSLendacky, Thomas 
135c5aa9e3bSLendacky, Thomas /* Descriptor related defines */
136d0a8ba6cSLendacky, Thomas #define XGBE_TX_DESC_CNT	512
137d0a8ba6cSLendacky, Thomas #define XGBE_TX_DESC_MIN_FREE	(XGBE_TX_DESC_CNT >> 3)
138d0a8ba6cSLendacky, Thomas #define XGBE_TX_DESC_MAX_PROC	(XGBE_TX_DESC_CNT >> 1)
139d0a8ba6cSLendacky, Thomas #define XGBE_RX_DESC_CNT	512
140c5aa9e3bSLendacky, Thomas 
141d0a8ba6cSLendacky, Thomas #define XGBE_TX_MAX_BUF_SIZE	(0x3fff & ~(64 - 1))
142c5aa9e3bSLendacky, Thomas 
143e1c05067SMasahiro Yamada /* Descriptors required for maximum contiguous TSO/GSO packet */
14416958a2bSLendacky, Thomas #define XGBE_TX_MAX_SPLIT	((GSO_MAX_SIZE / XGBE_TX_MAX_BUF_SIZE) + 1)
14516958a2bSLendacky, Thomas 
14616958a2bSLendacky, Thomas /* Maximum possible descriptors needed for an SKB:
14716958a2bSLendacky, Thomas  * - Maximum number of SKB frags
14816958a2bSLendacky, Thomas  * - Maximum descriptors for contiguous TSO/GSO packet
14916958a2bSLendacky, Thomas  * - Possible context descriptor
15016958a2bSLendacky, Thomas  * - Possible TSO header descriptor
15116958a2bSLendacky, Thomas  */
15216958a2bSLendacky, Thomas #define XGBE_TX_MAX_DESCS	(MAX_SKB_FRAGS + XGBE_TX_MAX_SPLIT + 2)
15316958a2bSLendacky, Thomas 
154d0a8ba6cSLendacky, Thomas #define XGBE_RX_MIN_BUF_SIZE	(ETH_FRAME_LEN + ETH_FCS_LEN + VLAN_HLEN)
155d0a8ba6cSLendacky, Thomas #define XGBE_RX_BUF_ALIGN	64
15608dcc47cSLendacky, Thomas #define XGBE_SKB_ALLOC_SIZE	256
157174fd259SLendacky, Thomas #define XGBE_SPH_HDSMS_SIZE	2	/* Keep in sync with SKB_ALLOC_SIZE */
158c5aa9e3bSLendacky, Thomas 
159d5c48582SLendacky, Thomas #define XGBE_MAX_DMA_CHANNELS	16
160fca2d994SLendacky, Thomas #define XGBE_MAX_QUEUES		16
161*43e0dcf7SLendacky, Thomas #define XGBE_PRIORITY_QUEUES	8
16216edd34eSLendacky, Thomas #define XGBE_DMA_STOP_TIMEOUT	5
163d0a8ba6cSLendacky, Thomas 
164d0a8ba6cSLendacky, Thomas /* DMA cache settings - Outer sharable, write-back, write-allocate */
165cfa50c78SLendacky, Thomas #define XGBE_DMA_OS_AXDOMAIN	0x2
166cfa50c78SLendacky, Thomas #define XGBE_DMA_OS_ARCACHE	0xb
167cfa50c78SLendacky, Thomas #define XGBE_DMA_OS_AWCACHE	0xf
168cfa50c78SLendacky, Thomas 
169cfa50c78SLendacky, Thomas /* DMA cache settings - System, no caches used */
170cfa50c78SLendacky, Thomas #define XGBE_DMA_SYS_AXDOMAIN	0x3
171cfa50c78SLendacky, Thomas #define XGBE_DMA_SYS_ARCACHE	0x0
172cfa50c78SLendacky, Thomas #define XGBE_DMA_SYS_AWCACHE	0x0
173d0a8ba6cSLendacky, Thomas 
174d0a8ba6cSLendacky, Thomas #define XGBE_DMA_INTERRUPT_MASK	0x31c7
175c5aa9e3bSLendacky, Thomas 
176c5aa9e3bSLendacky, Thomas #define XGMAC_MIN_PACKET	60
177c5aa9e3bSLendacky, Thomas #define XGMAC_STD_PACKET_MTU	1500
178c5aa9e3bSLendacky, Thomas #define XGMAC_MAX_STD_PACKET	1518
179c5aa9e3bSLendacky, Thomas #define XGMAC_JUMBO_PACKET_MTU	9000
180c5aa9e3bSLendacky, Thomas #define XGMAC_MAX_JUMBO_PACKET	9018
181*43e0dcf7SLendacky, Thomas #define XGMAC_ETH_PREAMBLE	(12 + 8)	/* Inter-frame gap + preamble */
182*43e0dcf7SLendacky, Thomas 
183*43e0dcf7SLendacky, Thomas #define XGMAC_PFC_DATA_LEN	46
184*43e0dcf7SLendacky, Thomas #define XGMAC_PFC_DELAYS	14000
185*43e0dcf7SLendacky, Thomas 
186*43e0dcf7SLendacky, Thomas #define XGMAC_PRIO_QUEUES(_cnt)					\
187*43e0dcf7SLendacky, Thomas 	min_t(unsigned int, IEEE_8021QAZ_MAX_TCS, (_cnt))
188c5aa9e3bSLendacky, Thomas 
18982a19035SLendacky, Thomas /* Common property names */
19082a19035SLendacky, Thomas #define XGBE_MAC_ADDR_PROPERTY	"mac-address"
19182a19035SLendacky, Thomas #define XGBE_PHY_MODE_PROPERTY	"phy-mode"
19282a19035SLendacky, Thomas #define XGBE_DMA_IRQS_PROPERTY	"amd,per-channel-interrupt"
1937c12aa08SLendacky, Thomas #define XGBE_SPEEDSET_PROPERTY	"amd,speed-set"
1947c12aa08SLendacky, Thomas #define XGBE_BLWC_PROPERTY	"amd,serdes-blwc"
1957c12aa08SLendacky, Thomas #define XGBE_CDR_RATE_PROPERTY	"amd,serdes-cdr-rate"
1967c12aa08SLendacky, Thomas #define XGBE_PQ_SKEW_PROPERTY	"amd,serdes-pq-skew"
1977c12aa08SLendacky, Thomas #define XGBE_TX_AMP_PROPERTY	"amd,serdes-tx-amp"
1987c12aa08SLendacky, Thomas #define XGBE_DFE_CFG_PROPERTY	"amd,serdes-dfe-tap-config"
1997c12aa08SLendacky, Thomas #define XGBE_DFE_ENA_PROPERTY	"amd,serdes-dfe-tap-enable"
20082a19035SLendacky, Thomas 
20123e4eef7SLendacky, Thomas /* Device-tree clock names */
20223e4eef7SLendacky, Thomas #define XGBE_DMA_CLOCK		"dma_clk"
20323e4eef7SLendacky, Thomas #define XGBE_PTP_CLOCK		"ptp_clk"
20482a19035SLendacky, Thomas 
20582a19035SLendacky, Thomas /* ACPI property names */
20682a19035SLendacky, Thomas #define XGBE_ACPI_DMA_FREQ	"amd,dma-freq"
20782a19035SLendacky, Thomas #define XGBE_ACPI_PTP_FREQ	"amd,ptp-freq"
20823e4eef7SLendacky, Thomas 
20923e4eef7SLendacky, Thomas /* Timestamp support - values based on 50MHz PTP clock
21023e4eef7SLendacky, Thomas  *   50MHz => 20 nsec
21123e4eef7SLendacky, Thomas  */
21223e4eef7SLendacky, Thomas #define XGBE_TSTAMP_SSINC	20
21323e4eef7SLendacky, Thomas #define XGBE_TSTAMP_SNSINC	0
21423e4eef7SLendacky, Thomas 
215c5aa9e3bSLendacky, Thomas /* Driver PMT macros */
216c5aa9e3bSLendacky, Thomas #define XGMAC_DRIVER_CONTEXT	1
217c5aa9e3bSLendacky, Thomas #define XGMAC_IOCTL_CONTEXT	2
218c5aa9e3bSLendacky, Thomas 
219586e3cfbSLendacky, Thomas #define XGMAC_FIFO_RX_MAX	81920
220586e3cfbSLendacky, Thomas #define XGMAC_FIFO_TX_MAX	81920
221*43e0dcf7SLendacky, Thomas #define XGMAC_FIFO_MIN_ALLOC	2048
222*43e0dcf7SLendacky, Thomas #define XGMAC_FIFO_UNIT		256
223*43e0dcf7SLendacky, Thomas #define XGMAC_FIFO_ALIGN(_x)				\
224*43e0dcf7SLendacky, Thomas 	(((_x) + XGMAC_FIFO_UNIT - 1) & ~(XGMAC_FIFO_UNIT - 1))
225*43e0dcf7SLendacky, Thomas #define XGMAC_FIFO_FC_OFF	2048
226*43e0dcf7SLendacky, Thomas #define XGMAC_FIFO_FC_MIN	4096
227c5aa9e3bSLendacky, Thomas 
228fca2d994SLendacky, Thomas #define XGBE_TC_MIN_QUANTUM	10
229c5aa9e3bSLendacky, Thomas 
230c5aa9e3bSLendacky, Thomas /* Helper macro for descriptor handling
231d0a8ba6cSLendacky, Thomas  *  Always use XGBE_GET_DESC_DATA to access the descriptor data
232c5aa9e3bSLendacky, Thomas  *  since the index is free-running and needs to be and-ed
233c5aa9e3bSLendacky, Thomas  *  with the descriptor count value of the ring to index to
234c5aa9e3bSLendacky, Thomas  *  the proper descriptor data.
235c5aa9e3bSLendacky, Thomas  */
236d0a8ba6cSLendacky, Thomas #define XGBE_GET_DESC_DATA(_ring, _idx)				\
237c5aa9e3bSLendacky, Thomas 	((_ring)->rdata +					\
238c5aa9e3bSLendacky, Thomas 	 ((_idx) & ((_ring)->rdesc_count - 1)))
239c5aa9e3bSLendacky, Thomas 
240c5aa9e3bSLendacky, Thomas /* Default coalescing parameters */
241c635eaacSLendacky, Thomas #define XGMAC_INIT_DMA_TX_USECS		1000
2429867e8fbSLendacky, Thomas #define XGMAC_INIT_DMA_TX_FRAMES	25
243c5aa9e3bSLendacky, Thomas 
244c5aa9e3bSLendacky, Thomas #define XGMAC_MAX_DMA_RIWT		0xff
2459867e8fbSLendacky, Thomas #define XGMAC_INIT_DMA_RX_USECS		30
2469867e8fbSLendacky, Thomas #define XGMAC_INIT_DMA_RX_FRAMES	25
247c5aa9e3bSLendacky, Thomas 
248c5aa9e3bSLendacky, Thomas /* Flow control queue count */
249c5aa9e3bSLendacky, Thomas #define XGMAC_MAX_FLOW_CONTROL_QUEUES	8
250c5aa9e3bSLendacky, Thomas 
251*43e0dcf7SLendacky, Thomas /* Flow control threshold units */
252*43e0dcf7SLendacky, Thomas #define XGMAC_FLOW_CONTROL_UNIT		512
253*43e0dcf7SLendacky, Thomas #define XGMAC_FLOW_CONTROL_ALIGN(_x)				\
254*43e0dcf7SLendacky, Thomas 	(((_x) + XGMAC_FLOW_CONTROL_UNIT - 1) & ~(XGMAC_FLOW_CONTROL_UNIT - 1))
255*43e0dcf7SLendacky, Thomas #define XGMAC_FLOW_CONTROL_VALUE(_x)				\
256*43e0dcf7SLendacky, Thomas 	(((_x) < 1024) ? 0 : ((_x) / XGMAC_FLOW_CONTROL_UNIT) - 2)
257*43e0dcf7SLendacky, Thomas #define XGMAC_FLOW_CONTROL_MAX		33280
258*43e0dcf7SLendacky, Thomas 
259b85e4d89SLendacky, Thomas /* Maximum MAC address hash table size (256 bits = 8 bytes) */
260b85e4d89SLendacky, Thomas #define XGBE_MAC_HASH_TABLE_SIZE	8
261c5aa9e3bSLendacky, Thomas 
2625b9dfe29SLendacky, Thomas /* Receive Side Scaling */
2635b9dfe29SLendacky, Thomas #define XGBE_RSS_HASH_KEY_SIZE		40
2645b9dfe29SLendacky, Thomas #define XGBE_RSS_MAX_TABLE_SIZE		256
2655b9dfe29SLendacky, Thomas #define XGBE_RSS_LOOKUP_TABLE_TYPE	0
2665b9dfe29SLendacky, Thomas #define XGBE_RSS_HASH_KEY_TYPE		1
2675b9dfe29SLendacky, Thomas 
2687c12aa08SLendacky, Thomas /* Auto-negotiation */
2697c12aa08SLendacky, Thomas #define XGBE_AN_MS_TIMEOUT		500
2707c12aa08SLendacky, Thomas #define XGBE_LINK_TIMEOUT		10
2717c12aa08SLendacky, Thomas 
2727c12aa08SLendacky, Thomas #define XGBE_AN_INT_CMPLT		0x01
2737c12aa08SLendacky, Thomas #define XGBE_AN_INC_LINK		0x02
2747c12aa08SLendacky, Thomas #define XGBE_AN_PG_RCV			0x04
2757c12aa08SLendacky, Thomas #define XGBE_AN_INT_MASK		0x07
2767c12aa08SLendacky, Thomas 
2777c12aa08SLendacky, Thomas /* Rate-change complete wait/retry count */
2787c12aa08SLendacky, Thomas #define XGBE_RATECHANGE_COUNT		500
2797c12aa08SLendacky, Thomas 
2807c12aa08SLendacky, Thomas /* Default SerDes settings */
2817c12aa08SLendacky, Thomas #define XGBE_SPEED_10000_BLWC		0
2827c12aa08SLendacky, Thomas #define XGBE_SPEED_10000_CDR		0x7
2837c12aa08SLendacky, Thomas #define XGBE_SPEED_10000_PLL		0x1
2847c12aa08SLendacky, Thomas #define XGBE_SPEED_10000_PQ		0x12
2857c12aa08SLendacky, Thomas #define XGBE_SPEED_10000_RATE		0x0
2867c12aa08SLendacky, Thomas #define XGBE_SPEED_10000_TXAMP		0xa
2877c12aa08SLendacky, Thomas #define XGBE_SPEED_10000_WORD		0x7
2887c12aa08SLendacky, Thomas #define XGBE_SPEED_10000_DFE_TAP_CONFIG	0x1
2897c12aa08SLendacky, Thomas #define XGBE_SPEED_10000_DFE_TAP_ENABLE	0x7f
2907c12aa08SLendacky, Thomas 
2917c12aa08SLendacky, Thomas #define XGBE_SPEED_2500_BLWC		1
2927c12aa08SLendacky, Thomas #define XGBE_SPEED_2500_CDR		0x2
2937c12aa08SLendacky, Thomas #define XGBE_SPEED_2500_PLL		0x0
2947c12aa08SLendacky, Thomas #define XGBE_SPEED_2500_PQ		0xa
2957c12aa08SLendacky, Thomas #define XGBE_SPEED_2500_RATE		0x1
2967c12aa08SLendacky, Thomas #define XGBE_SPEED_2500_TXAMP		0xf
2977c12aa08SLendacky, Thomas #define XGBE_SPEED_2500_WORD		0x1
2987c12aa08SLendacky, Thomas #define XGBE_SPEED_2500_DFE_TAP_CONFIG	0x3
2997c12aa08SLendacky, Thomas #define XGBE_SPEED_2500_DFE_TAP_ENABLE	0x0
3007c12aa08SLendacky, Thomas 
3017c12aa08SLendacky, Thomas #define XGBE_SPEED_1000_BLWC		1
3027c12aa08SLendacky, Thomas #define XGBE_SPEED_1000_CDR		0x2
3037c12aa08SLendacky, Thomas #define XGBE_SPEED_1000_PLL		0x0
3047c12aa08SLendacky, Thomas #define XGBE_SPEED_1000_PQ		0xa
3057c12aa08SLendacky, Thomas #define XGBE_SPEED_1000_RATE		0x3
3067c12aa08SLendacky, Thomas #define XGBE_SPEED_1000_TXAMP		0xf
3077c12aa08SLendacky, Thomas #define XGBE_SPEED_1000_WORD		0x1
3087c12aa08SLendacky, Thomas #define XGBE_SPEED_1000_DFE_TAP_CONFIG	0x3
3097c12aa08SLendacky, Thomas #define XGBE_SPEED_1000_DFE_TAP_ENABLE	0x0
3107c12aa08SLendacky, Thomas 
311c5aa9e3bSLendacky, Thomas struct xgbe_prv_data;
312c5aa9e3bSLendacky, Thomas 
313c5aa9e3bSLendacky, Thomas struct xgbe_packet_data {
31416958a2bSLendacky, Thomas 	struct sk_buff *skb;
31516958a2bSLendacky, Thomas 
316c5aa9e3bSLendacky, Thomas 	unsigned int attributes;
317c5aa9e3bSLendacky, Thomas 
318c5aa9e3bSLendacky, Thomas 	unsigned int errors;
319c5aa9e3bSLendacky, Thomas 
320c5aa9e3bSLendacky, Thomas 	unsigned int rdesc_count;
321c5aa9e3bSLendacky, Thomas 	unsigned int length;
322c5aa9e3bSLendacky, Thomas 
323c5aa9e3bSLendacky, Thomas 	unsigned int header_len;
324c5aa9e3bSLendacky, Thomas 	unsigned int tcp_header_len;
325c5aa9e3bSLendacky, Thomas 	unsigned int tcp_payload_len;
326c5aa9e3bSLendacky, Thomas 	unsigned short mss;
327c5aa9e3bSLendacky, Thomas 
328c5aa9e3bSLendacky, Thomas 	unsigned short vlan_ctag;
32923e4eef7SLendacky, Thomas 
33023e4eef7SLendacky, Thomas 	u64 rx_tstamp;
3315b9dfe29SLendacky, Thomas 
3325b9dfe29SLendacky, Thomas 	u32 rss_hash;
3335b9dfe29SLendacky, Thomas 	enum pkt_hash_types rss_hash_type;
3345fb4b86aSLendacky, Thomas 
3355fb4b86aSLendacky, Thomas 	unsigned int tx_packets;
3365fb4b86aSLendacky, Thomas 	unsigned int tx_bytes;
337c5aa9e3bSLendacky, Thomas };
338c5aa9e3bSLendacky, Thomas 
339c5aa9e3bSLendacky, Thomas /* Common Rx and Tx descriptor mapping */
340c5aa9e3bSLendacky, Thomas struct xgbe_ring_desc {
3415226cfc5SLendacky, Thomas 	__le32 desc0;
3425226cfc5SLendacky, Thomas 	__le32 desc1;
3435226cfc5SLendacky, Thomas 	__le32 desc2;
3445226cfc5SLendacky, Thomas 	__le32 desc3;
345c5aa9e3bSLendacky, Thomas };
346c5aa9e3bSLendacky, Thomas 
34708dcc47cSLendacky, Thomas /* Page allocation related values */
34808dcc47cSLendacky, Thomas struct xgbe_page_alloc {
34908dcc47cSLendacky, Thomas 	struct page *pages;
35008dcc47cSLendacky, Thomas 	unsigned int pages_len;
35108dcc47cSLendacky, Thomas 	unsigned int pages_offset;
35208dcc47cSLendacky, Thomas 
35308dcc47cSLendacky, Thomas 	dma_addr_t pages_dma;
35408dcc47cSLendacky, Thomas };
35508dcc47cSLendacky, Thomas 
356174fd259SLendacky, Thomas /* Ring entry buffer data */
357174fd259SLendacky, Thomas struct xgbe_buffer_data {
358174fd259SLendacky, Thomas 	struct xgbe_page_alloc pa;
359174fd259SLendacky, Thomas 	struct xgbe_page_alloc pa_unmap;
360174fd259SLendacky, Thomas 
361cfbfd86bSLendacky, Thomas 	dma_addr_t dma_base;
362cfbfd86bSLendacky, Thomas 	unsigned long dma_off;
363174fd259SLendacky, Thomas 	unsigned int dma_len;
364174fd259SLendacky, Thomas };
365174fd259SLendacky, Thomas 
366c9f140ebSLendacky, Thomas /* Tx-related ring data */
367c9f140ebSLendacky, Thomas struct xgbe_tx_ring_data {
3685fb4b86aSLendacky, Thomas 	unsigned int packets;		/* BQL packet count */
3695fb4b86aSLendacky, Thomas 	unsigned int bytes;		/* BQL byte count */
370c9f140ebSLendacky, Thomas };
371c9f140ebSLendacky, Thomas 
372c9f140ebSLendacky, Thomas /* Rx-related ring data */
373c9f140ebSLendacky, Thomas struct xgbe_rx_ring_data {
374c9f140ebSLendacky, Thomas 	struct xgbe_buffer_data hdr;	/* Header locations */
375c9f140ebSLendacky, Thomas 	struct xgbe_buffer_data buf;	/* Payload locations */
376c9f140ebSLendacky, Thomas 
377c9f140ebSLendacky, Thomas 	unsigned short hdr_len;		/* Length of received header */
378c9f140ebSLendacky, Thomas 	unsigned short len;		/* Length of received packet */
379c9f140ebSLendacky, Thomas };
380c9f140ebSLendacky, Thomas 
381c5aa9e3bSLendacky, Thomas /* Structure used to hold information related to the descriptor
382c5aa9e3bSLendacky, Thomas  * and the packet associated with the descriptor (always use
383d0a8ba6cSLendacky, Thomas  * use the XGBE_GET_DESC_DATA macro to access this data from the ring)
384c5aa9e3bSLendacky, Thomas  */
385c5aa9e3bSLendacky, Thomas struct xgbe_ring_data {
386c5aa9e3bSLendacky, Thomas 	struct xgbe_ring_desc *rdesc;	/* Virtual address of descriptor */
387c5aa9e3bSLendacky, Thomas 	dma_addr_t rdesc_dma;		/* DMA address of descriptor */
388c5aa9e3bSLendacky, Thomas 
389c5aa9e3bSLendacky, Thomas 	struct sk_buff *skb;		/* Virtual address of SKB */
390c5aa9e3bSLendacky, Thomas 	dma_addr_t skb_dma;		/* DMA address of SKB data */
391c5aa9e3bSLendacky, Thomas 	unsigned int skb_dma_len;	/* Length of SKB DMA area */
392c5aa9e3bSLendacky, Thomas 
393c9f140ebSLendacky, Thomas 	struct xgbe_tx_ring_data tx;	/* Tx-related data */
394c9f140ebSLendacky, Thomas 	struct xgbe_rx_ring_data rx;	/* Rx-related data */
395c5aa9e3bSLendacky, Thomas 
396c5aa9e3bSLendacky, Thomas 	unsigned int mapped_as_page;
39723e4eef7SLendacky, Thomas 
39823e4eef7SLendacky, Thomas 	/* Incomplete receive save location.  If the budget is exhausted
39923e4eef7SLendacky, Thomas 	 * or the last descriptor (last normal descriptor or a following
40023e4eef7SLendacky, Thomas 	 * context descriptor) has not been DMA'd yet the current state
40123e4eef7SLendacky, Thomas 	 * of the receive processing needs to be saved.
40223e4eef7SLendacky, Thomas 	 */
40323e4eef7SLendacky, Thomas 	unsigned int state_saved;
40423e4eef7SLendacky, Thomas 	struct {
40523e4eef7SLendacky, Thomas 		struct sk_buff *skb;
40623e4eef7SLendacky, Thomas 		unsigned int len;
40723e4eef7SLendacky, Thomas 		unsigned int error;
40823e4eef7SLendacky, Thomas 	} state;
409c5aa9e3bSLendacky, Thomas };
410c5aa9e3bSLendacky, Thomas 
411c5aa9e3bSLendacky, Thomas struct xgbe_ring {
412c5aa9e3bSLendacky, Thomas 	/* Ring lock - used just for TX rings at the moment */
413c5aa9e3bSLendacky, Thomas 	spinlock_t lock;
414c5aa9e3bSLendacky, Thomas 
415c5aa9e3bSLendacky, Thomas 	/* Per packet related information */
416c5aa9e3bSLendacky, Thomas 	struct xgbe_packet_data packet_data;
417c5aa9e3bSLendacky, Thomas 
418c5aa9e3bSLendacky, Thomas 	/* Virtual/DMA addresses and count of allocated descriptor memory */
419c5aa9e3bSLendacky, Thomas 	struct xgbe_ring_desc *rdesc;
420c5aa9e3bSLendacky, Thomas 	dma_addr_t rdesc_dma;
421c5aa9e3bSLendacky, Thomas 	unsigned int rdesc_count;
422c5aa9e3bSLendacky, Thomas 
423c5aa9e3bSLendacky, Thomas 	/* Array of descriptor data corresponding the descriptor memory
424d0a8ba6cSLendacky, Thomas 	 * (always use the XGBE_GET_DESC_DATA macro to access this data)
425c5aa9e3bSLendacky, Thomas 	 */
426c5aa9e3bSLendacky, Thomas 	struct xgbe_ring_data *rdata;
427c5aa9e3bSLendacky, Thomas 
42808dcc47cSLendacky, Thomas 	/* Page allocation for RX buffers */
429174fd259SLendacky, Thomas 	struct xgbe_page_alloc rx_hdr_pa;
430174fd259SLendacky, Thomas 	struct xgbe_page_alloc rx_buf_pa;
43108dcc47cSLendacky, Thomas 
432c5aa9e3bSLendacky, Thomas 	/* Ring index values
433c5aa9e3bSLendacky, Thomas 	 *  cur   - Tx: index of descriptor to be used for current transfer
434c5aa9e3bSLendacky, Thomas 	 *          Rx: index of descriptor to check for packet availability
435c5aa9e3bSLendacky, Thomas 	 *  dirty - Tx: index of descriptor to check for transfer complete
436270894e7SLendacky, Thomas 	 *          Rx: index of descriptor to check for buffer reallocation
437c5aa9e3bSLendacky, Thomas 	 */
438c5aa9e3bSLendacky, Thomas 	unsigned int cur;
439c5aa9e3bSLendacky, Thomas 	unsigned int dirty;
440c5aa9e3bSLendacky, Thomas 
441c5aa9e3bSLendacky, Thomas 	/* Coalesce frame count used for interrupt bit setting */
442c5aa9e3bSLendacky, Thomas 	unsigned int coalesce_count;
443c5aa9e3bSLendacky, Thomas 
444c5aa9e3bSLendacky, Thomas 	union {
445c5aa9e3bSLendacky, Thomas 		struct {
446c5aa9e3bSLendacky, Thomas 			unsigned int queue_stopped;
44716958a2bSLendacky, Thomas 			unsigned int xmit_more;
448c5aa9e3bSLendacky, Thomas 			unsigned short cur_mss;
449c5aa9e3bSLendacky, Thomas 			unsigned short cur_vlan_ctag;
450c5aa9e3bSLendacky, Thomas 		} tx;
451c5aa9e3bSLendacky, Thomas 	};
452c5aa9e3bSLendacky, Thomas } ____cacheline_aligned;
453c5aa9e3bSLendacky, Thomas 
454c5aa9e3bSLendacky, Thomas /* Structure used to describe the descriptor rings associated with
455c5aa9e3bSLendacky, Thomas  * a DMA channel.
456c5aa9e3bSLendacky, Thomas  */
457c5aa9e3bSLendacky, Thomas struct xgbe_channel {
458c5aa9e3bSLendacky, Thomas 	char name[16];
459c5aa9e3bSLendacky, Thomas 
460c5aa9e3bSLendacky, Thomas 	/* Address of private data area for device */
461c5aa9e3bSLendacky, Thomas 	struct xgbe_prv_data *pdata;
462c5aa9e3bSLendacky, Thomas 
463c5aa9e3bSLendacky, Thomas 	/* Queue index and base address of queue's DMA registers */
464c5aa9e3bSLendacky, Thomas 	unsigned int queue_index;
465c5aa9e3bSLendacky, Thomas 	void __iomem *dma_regs;
466c5aa9e3bSLendacky, Thomas 
4679227dc5eSLendacky, Thomas 	/* Per channel interrupt irq number */
4689227dc5eSLendacky, Thomas 	int dma_irq;
46954ceb9ecSLendacky, Thomas 	char dma_irq_name[IFNAMSIZ + 32];
4709227dc5eSLendacky, Thomas 
4719227dc5eSLendacky, Thomas 	/* Netdev related settings */
4729227dc5eSLendacky, Thomas 	struct napi_struct napi;
4739227dc5eSLendacky, Thomas 
474c5aa9e3bSLendacky, Thomas 	unsigned int saved_ier;
475c5aa9e3bSLendacky, Thomas 
476c5aa9e3bSLendacky, Thomas 	unsigned int tx_timer_active;
477c635eaacSLendacky, Thomas 	struct timer_list tx_timer;
478c5aa9e3bSLendacky, Thomas 
479c5aa9e3bSLendacky, Thomas 	struct xgbe_ring *tx_ring;
480c5aa9e3bSLendacky, Thomas 	struct xgbe_ring *rx_ring;
481c5aa9e3bSLendacky, Thomas } ____cacheline_aligned;
482c5aa9e3bSLendacky, Thomas 
4837c12aa08SLendacky, Thomas enum xgbe_state {
4847c12aa08SLendacky, Thomas 	XGBE_DOWN,
4857c12aa08SLendacky, Thomas 	XGBE_LINK_INIT,
4867c12aa08SLendacky, Thomas 	XGBE_LINK_ERR,
4877c12aa08SLendacky, Thomas };
4887c12aa08SLendacky, Thomas 
489c5aa9e3bSLendacky, Thomas enum xgbe_int {
490c5aa9e3bSLendacky, Thomas 	XGMAC_INT_DMA_CH_SR_TI,
491c5aa9e3bSLendacky, Thomas 	XGMAC_INT_DMA_CH_SR_TPS,
492c5aa9e3bSLendacky, Thomas 	XGMAC_INT_DMA_CH_SR_TBU,
493c5aa9e3bSLendacky, Thomas 	XGMAC_INT_DMA_CH_SR_RI,
494c5aa9e3bSLendacky, Thomas 	XGMAC_INT_DMA_CH_SR_RBU,
495c5aa9e3bSLendacky, Thomas 	XGMAC_INT_DMA_CH_SR_RPS,
4969867e8fbSLendacky, Thomas 	XGMAC_INT_DMA_CH_SR_TI_RI,
497c5aa9e3bSLendacky, Thomas 	XGMAC_INT_DMA_CH_SR_FBE,
498c5aa9e3bSLendacky, Thomas 	XGMAC_INT_DMA_ALL,
499c5aa9e3bSLendacky, Thomas };
500c5aa9e3bSLendacky, Thomas 
501c5aa9e3bSLendacky, Thomas enum xgbe_int_state {
502c5aa9e3bSLendacky, Thomas 	XGMAC_INT_STATE_SAVE,
503c5aa9e3bSLendacky, Thomas 	XGMAC_INT_STATE_RESTORE,
504c5aa9e3bSLendacky, Thomas };
505c5aa9e3bSLendacky, Thomas 
5067c12aa08SLendacky, Thomas enum xgbe_speed {
5077c12aa08SLendacky, Thomas 	XGBE_SPEED_1000 = 0,
5087c12aa08SLendacky, Thomas 	XGBE_SPEED_2500,
5097c12aa08SLendacky, Thomas 	XGBE_SPEED_10000,
5107c12aa08SLendacky, Thomas 	XGBE_SPEEDS,
5117c12aa08SLendacky, Thomas };
5127c12aa08SLendacky, Thomas 
5137c12aa08SLendacky, Thomas enum xgbe_an {
5147c12aa08SLendacky, Thomas 	XGBE_AN_READY = 0,
5157c12aa08SLendacky, Thomas 	XGBE_AN_PAGE_RECEIVED,
5167c12aa08SLendacky, Thomas 	XGBE_AN_INCOMPAT_LINK,
5177c12aa08SLendacky, Thomas 	XGBE_AN_COMPLETE,
5187c12aa08SLendacky, Thomas 	XGBE_AN_NO_LINK,
5197c12aa08SLendacky, Thomas 	XGBE_AN_ERROR,
5207c12aa08SLendacky, Thomas };
5217c12aa08SLendacky, Thomas 
5227c12aa08SLendacky, Thomas enum xgbe_rx {
5237c12aa08SLendacky, Thomas 	XGBE_RX_BPA = 0,
5247c12aa08SLendacky, Thomas 	XGBE_RX_XNP,
5257c12aa08SLendacky, Thomas 	XGBE_RX_COMPLETE,
5267c12aa08SLendacky, Thomas 	XGBE_RX_ERROR,
5277c12aa08SLendacky, Thomas };
5287c12aa08SLendacky, Thomas 
5297c12aa08SLendacky, Thomas enum xgbe_mode {
5307c12aa08SLendacky, Thomas 	XGBE_MODE_KR = 0,
5317c12aa08SLendacky, Thomas 	XGBE_MODE_KX,
5327c12aa08SLendacky, Thomas };
5337c12aa08SLendacky, Thomas 
5347c12aa08SLendacky, Thomas enum xgbe_speedset {
5357c12aa08SLendacky, Thomas 	XGBE_SPEEDSET_1000_10000 = 0,
5367c12aa08SLendacky, Thomas 	XGBE_SPEEDSET_2500_10000,
5377c12aa08SLendacky, Thomas };
5387c12aa08SLendacky, Thomas 
5397c12aa08SLendacky, Thomas struct xgbe_phy {
5407c12aa08SLendacky, Thomas 	u32 supported;
5417c12aa08SLendacky, Thomas 	u32 advertising;
5427c12aa08SLendacky, Thomas 	u32 lp_advertising;
5437c12aa08SLendacky, Thomas 
5447c12aa08SLendacky, Thomas 	int address;
5457c12aa08SLendacky, Thomas 
5467c12aa08SLendacky, Thomas 	int autoneg;
5477c12aa08SLendacky, Thomas 	int speed;
5487c12aa08SLendacky, Thomas 	int duplex;
5497c12aa08SLendacky, Thomas 
5507c12aa08SLendacky, Thomas 	int link;
551c1ce2f77SLendacky, Thomas 
552c1ce2f77SLendacky, Thomas 	int pause_autoneg;
553c1ce2f77SLendacky, Thomas 	int tx_pause;
554c1ce2f77SLendacky, Thomas 	int rx_pause;
5557c12aa08SLendacky, Thomas };
5567c12aa08SLendacky, Thomas 
557c5aa9e3bSLendacky, Thomas struct xgbe_mmc_stats {
558c5aa9e3bSLendacky, Thomas 	/* Tx Stats */
559c5aa9e3bSLendacky, Thomas 	u64 txoctetcount_gb;
560c5aa9e3bSLendacky, Thomas 	u64 txframecount_gb;
561c5aa9e3bSLendacky, Thomas 	u64 txbroadcastframes_g;
562c5aa9e3bSLendacky, Thomas 	u64 txmulticastframes_g;
563c5aa9e3bSLendacky, Thomas 	u64 tx64octets_gb;
564c5aa9e3bSLendacky, Thomas 	u64 tx65to127octets_gb;
565c5aa9e3bSLendacky, Thomas 	u64 tx128to255octets_gb;
566c5aa9e3bSLendacky, Thomas 	u64 tx256to511octets_gb;
567c5aa9e3bSLendacky, Thomas 	u64 tx512to1023octets_gb;
568c5aa9e3bSLendacky, Thomas 	u64 tx1024tomaxoctets_gb;
569c5aa9e3bSLendacky, Thomas 	u64 txunicastframes_gb;
570c5aa9e3bSLendacky, Thomas 	u64 txmulticastframes_gb;
571c5aa9e3bSLendacky, Thomas 	u64 txbroadcastframes_gb;
572c5aa9e3bSLendacky, Thomas 	u64 txunderflowerror;
573c5aa9e3bSLendacky, Thomas 	u64 txoctetcount_g;
574c5aa9e3bSLendacky, Thomas 	u64 txframecount_g;
575c5aa9e3bSLendacky, Thomas 	u64 txpauseframes;
576c5aa9e3bSLendacky, Thomas 	u64 txvlanframes_g;
577c5aa9e3bSLendacky, Thomas 
578c5aa9e3bSLendacky, Thomas 	/* Rx Stats */
579c5aa9e3bSLendacky, Thomas 	u64 rxframecount_gb;
580c5aa9e3bSLendacky, Thomas 	u64 rxoctetcount_gb;
581c5aa9e3bSLendacky, Thomas 	u64 rxoctetcount_g;
582c5aa9e3bSLendacky, Thomas 	u64 rxbroadcastframes_g;
583c5aa9e3bSLendacky, Thomas 	u64 rxmulticastframes_g;
584c5aa9e3bSLendacky, Thomas 	u64 rxcrcerror;
585c5aa9e3bSLendacky, Thomas 	u64 rxrunterror;
586c5aa9e3bSLendacky, Thomas 	u64 rxjabbererror;
587c5aa9e3bSLendacky, Thomas 	u64 rxundersize_g;
588c5aa9e3bSLendacky, Thomas 	u64 rxoversize_g;
589c5aa9e3bSLendacky, Thomas 	u64 rx64octets_gb;
590c5aa9e3bSLendacky, Thomas 	u64 rx65to127octets_gb;
591c5aa9e3bSLendacky, Thomas 	u64 rx128to255octets_gb;
592c5aa9e3bSLendacky, Thomas 	u64 rx256to511octets_gb;
593c5aa9e3bSLendacky, Thomas 	u64 rx512to1023octets_gb;
594c5aa9e3bSLendacky, Thomas 	u64 rx1024tomaxoctets_gb;
595c5aa9e3bSLendacky, Thomas 	u64 rxunicastframes_g;
596c5aa9e3bSLendacky, Thomas 	u64 rxlengtherror;
597c5aa9e3bSLendacky, Thomas 	u64 rxoutofrangetype;
598c5aa9e3bSLendacky, Thomas 	u64 rxpauseframes;
599c5aa9e3bSLendacky, Thomas 	u64 rxfifooverflow;
600c5aa9e3bSLendacky, Thomas 	u64 rxvlanframes_gb;
601c5aa9e3bSLendacky, Thomas 	u64 rxwatchdogerror;
602c5aa9e3bSLendacky, Thomas };
603c5aa9e3bSLendacky, Thomas 
6045452b2dfSLendacky, Thomas struct xgbe_ext_stats {
6055452b2dfSLendacky, Thomas 	u64 tx_tso_packets;
6065452b2dfSLendacky, Thomas 	u64 rx_split_header_packets;
60772c9ac4eSLendacky, Thomas 	u64 rx_buffer_unavailable;
6085452b2dfSLendacky, Thomas };
6095452b2dfSLendacky, Thomas 
610c5aa9e3bSLendacky, Thomas struct xgbe_hw_if {
611c5aa9e3bSLendacky, Thomas 	int (*tx_complete)(struct xgbe_ring_desc *);
612c5aa9e3bSLendacky, Thomas 
613c5aa9e3bSLendacky, Thomas 	int (*set_mac_address)(struct xgbe_prv_data *, u8 *addr);
614b876382bSLendacky, Thomas 	int (*config_rx_mode)(struct xgbe_prv_data *);
615c5aa9e3bSLendacky, Thomas 
616c5aa9e3bSLendacky, Thomas 	int (*enable_rx_csum)(struct xgbe_prv_data *);
617c5aa9e3bSLendacky, Thomas 	int (*disable_rx_csum)(struct xgbe_prv_data *);
618c5aa9e3bSLendacky, Thomas 
619c5aa9e3bSLendacky, Thomas 	int (*enable_rx_vlan_stripping)(struct xgbe_prv_data *);
620c5aa9e3bSLendacky, Thomas 	int (*disable_rx_vlan_stripping)(struct xgbe_prv_data *);
621801c62d9SLendacky, Thomas 	int (*enable_rx_vlan_filtering)(struct xgbe_prv_data *);
622801c62d9SLendacky, Thomas 	int (*disable_rx_vlan_filtering)(struct xgbe_prv_data *);
623801c62d9SLendacky, Thomas 	int (*update_vlan_hash_table)(struct xgbe_prv_data *);
624c5aa9e3bSLendacky, Thomas 
625c5aa9e3bSLendacky, Thomas 	int (*read_mmd_regs)(struct xgbe_prv_data *, int, int);
626c5aa9e3bSLendacky, Thomas 	void (*write_mmd_regs)(struct xgbe_prv_data *, int, int, int);
627c5aa9e3bSLendacky, Thomas 	int (*set_gmii_speed)(struct xgbe_prv_data *);
628c5aa9e3bSLendacky, Thomas 	int (*set_gmii_2500_speed)(struct xgbe_prv_data *);
629c5aa9e3bSLendacky, Thomas 	int (*set_xgmii_speed)(struct xgbe_prv_data *);
630c5aa9e3bSLendacky, Thomas 
631c5aa9e3bSLendacky, Thomas 	void (*enable_tx)(struct xgbe_prv_data *);
632c5aa9e3bSLendacky, Thomas 	void (*disable_tx)(struct xgbe_prv_data *);
633c5aa9e3bSLendacky, Thomas 	void (*enable_rx)(struct xgbe_prv_data *);
634c5aa9e3bSLendacky, Thomas 	void (*disable_rx)(struct xgbe_prv_data *);
635c5aa9e3bSLendacky, Thomas 
636c5aa9e3bSLendacky, Thomas 	void (*powerup_tx)(struct xgbe_prv_data *);
637c5aa9e3bSLendacky, Thomas 	void (*powerdown_tx)(struct xgbe_prv_data *);
638c5aa9e3bSLendacky, Thomas 	void (*powerup_rx)(struct xgbe_prv_data *);
639c5aa9e3bSLendacky, Thomas 	void (*powerdown_rx)(struct xgbe_prv_data *);
640c5aa9e3bSLendacky, Thomas 
641c5aa9e3bSLendacky, Thomas 	int (*init)(struct xgbe_prv_data *);
642c5aa9e3bSLendacky, Thomas 	int (*exit)(struct xgbe_prv_data *);
643c5aa9e3bSLendacky, Thomas 
644c5aa9e3bSLendacky, Thomas 	int (*enable_int)(struct xgbe_channel *, enum xgbe_int);
645c5aa9e3bSLendacky, Thomas 	int (*disable_int)(struct xgbe_channel *, enum xgbe_int);
646a9d41981SLendacky, Thomas 	void (*dev_xmit)(struct xgbe_channel *);
647c5aa9e3bSLendacky, Thomas 	int (*dev_read)(struct xgbe_channel *);
648c5aa9e3bSLendacky, Thomas 	void (*tx_desc_init)(struct xgbe_channel *);
649c5aa9e3bSLendacky, Thomas 	void (*rx_desc_init)(struct xgbe_channel *);
650c5aa9e3bSLendacky, Thomas 	void (*tx_desc_reset)(struct xgbe_ring_data *);
6518dee19e6SLendacky, Thomas 	void (*rx_desc_reset)(struct xgbe_prv_data *, struct xgbe_ring_data *,
6528dee19e6SLendacky, Thomas 			      unsigned int);
653c5aa9e3bSLendacky, Thomas 	int (*is_last_desc)(struct xgbe_ring_desc *);
654c5aa9e3bSLendacky, Thomas 	int (*is_context_desc)(struct xgbe_ring_desc *);
65516958a2bSLendacky, Thomas 	void (*tx_start_xmit)(struct xgbe_channel *, struct xgbe_ring *);
656c5aa9e3bSLendacky, Thomas 
657c5aa9e3bSLendacky, Thomas 	/* For FLOW ctrl */
658c5aa9e3bSLendacky, Thomas 	int (*config_tx_flow_control)(struct xgbe_prv_data *);
659c5aa9e3bSLendacky, Thomas 	int (*config_rx_flow_control)(struct xgbe_prv_data *);
660c5aa9e3bSLendacky, Thomas 
661c5aa9e3bSLendacky, Thomas 	/* For RX coalescing */
662c5aa9e3bSLendacky, Thomas 	int (*config_rx_coalesce)(struct xgbe_prv_data *);
663c5aa9e3bSLendacky, Thomas 	int (*config_tx_coalesce)(struct xgbe_prv_data *);
664c5aa9e3bSLendacky, Thomas 	unsigned int (*usec_to_riwt)(struct xgbe_prv_data *, unsigned int);
665c5aa9e3bSLendacky, Thomas 	unsigned int (*riwt_to_usec)(struct xgbe_prv_data *, unsigned int);
666c5aa9e3bSLendacky, Thomas 
667c5aa9e3bSLendacky, Thomas 	/* For RX and TX threshold config */
668c5aa9e3bSLendacky, Thomas 	int (*config_rx_threshold)(struct xgbe_prv_data *, unsigned int);
669c5aa9e3bSLendacky, Thomas 	int (*config_tx_threshold)(struct xgbe_prv_data *, unsigned int);
670c5aa9e3bSLendacky, Thomas 
671c5aa9e3bSLendacky, Thomas 	/* For RX and TX Store and Forward Mode config */
672c5aa9e3bSLendacky, Thomas 	int (*config_rsf_mode)(struct xgbe_prv_data *, unsigned int);
673c5aa9e3bSLendacky, Thomas 	int (*config_tsf_mode)(struct xgbe_prv_data *, unsigned int);
674c5aa9e3bSLendacky, Thomas 
675c5aa9e3bSLendacky, Thomas 	/* For TX DMA Operate on Second Frame config */
676c5aa9e3bSLendacky, Thomas 	int (*config_osp_mode)(struct xgbe_prv_data *);
677c5aa9e3bSLendacky, Thomas 
678c5aa9e3bSLendacky, Thomas 	/* For RX and TX PBL config */
679c5aa9e3bSLendacky, Thomas 	int (*config_rx_pbl_val)(struct xgbe_prv_data *);
680c5aa9e3bSLendacky, Thomas 	int (*get_rx_pbl_val)(struct xgbe_prv_data *);
681c5aa9e3bSLendacky, Thomas 	int (*config_tx_pbl_val)(struct xgbe_prv_data *);
682c5aa9e3bSLendacky, Thomas 	int (*get_tx_pbl_val)(struct xgbe_prv_data *);
683c5aa9e3bSLendacky, Thomas 	int (*config_pblx8)(struct xgbe_prv_data *);
684c5aa9e3bSLendacky, Thomas 
685c5aa9e3bSLendacky, Thomas 	/* For MMC statistics */
686c5aa9e3bSLendacky, Thomas 	void (*rx_mmc_int)(struct xgbe_prv_data *);
687c5aa9e3bSLendacky, Thomas 	void (*tx_mmc_int)(struct xgbe_prv_data *);
688c5aa9e3bSLendacky, Thomas 	void (*read_mmc_stats)(struct xgbe_prv_data *);
68923e4eef7SLendacky, Thomas 
69023e4eef7SLendacky, Thomas 	/* For Timestamp config */
69123e4eef7SLendacky, Thomas 	int (*config_tstamp)(struct xgbe_prv_data *, unsigned int);
69223e4eef7SLendacky, Thomas 	void (*update_tstamp_addend)(struct xgbe_prv_data *, unsigned int);
69323e4eef7SLendacky, Thomas 	void (*set_tstamp_time)(struct xgbe_prv_data *, unsigned int sec,
69423e4eef7SLendacky, Thomas 				unsigned int nsec);
69523e4eef7SLendacky, Thomas 	u64 (*get_tstamp_time)(struct xgbe_prv_data *);
69623e4eef7SLendacky, Thomas 	u64 (*get_tx_tstamp)(struct xgbe_prv_data *);
697fca2d994SLendacky, Thomas 
698fca2d994SLendacky, Thomas 	/* For Data Center Bridging config */
699b3b71597SLendacky, Thomas 	void (*config_tc)(struct xgbe_prv_data *);
700fca2d994SLendacky, Thomas 	void (*config_dcb_tc)(struct xgbe_prv_data *);
701fca2d994SLendacky, Thomas 	void (*config_dcb_pfc)(struct xgbe_prv_data *);
7025b9dfe29SLendacky, Thomas 
7035b9dfe29SLendacky, Thomas 	/* For Receive Side Scaling */
7045b9dfe29SLendacky, Thomas 	int (*enable_rss)(struct xgbe_prv_data *);
7055b9dfe29SLendacky, Thomas 	int (*disable_rss)(struct xgbe_prv_data *);
706f6ac8628SLendacky, Thomas 	int (*set_rss_hash_key)(struct xgbe_prv_data *, const u8 *);
707f6ac8628SLendacky, Thomas 	int (*set_rss_lookup_table)(struct xgbe_prv_data *, const u32 *);
708c5aa9e3bSLendacky, Thomas };
709c5aa9e3bSLendacky, Thomas 
7107c12aa08SLendacky, Thomas struct xgbe_phy_if {
7117c12aa08SLendacky, Thomas 	/* For initial PHY setup */
7127c12aa08SLendacky, Thomas 	void (*phy_init)(struct xgbe_prv_data *);
7137c12aa08SLendacky, Thomas 
7147c12aa08SLendacky, Thomas 	/* For PHY support when setting device up/down */
7157c12aa08SLendacky, Thomas 	int (*phy_reset)(struct xgbe_prv_data *);
7167c12aa08SLendacky, Thomas 	int (*phy_start)(struct xgbe_prv_data *);
7177c12aa08SLendacky, Thomas 	void (*phy_stop)(struct xgbe_prv_data *);
7187c12aa08SLendacky, Thomas 
7197c12aa08SLendacky, Thomas 	/* For PHY support while device is up */
7207c12aa08SLendacky, Thomas 	void (*phy_status)(struct xgbe_prv_data *);
7217c12aa08SLendacky, Thomas 	int (*phy_config_aneg)(struct xgbe_prv_data *);
7227c12aa08SLendacky, Thomas };
7237c12aa08SLendacky, Thomas 
724c5aa9e3bSLendacky, Thomas struct xgbe_desc_if {
725c5aa9e3bSLendacky, Thomas 	int (*alloc_ring_resources)(struct xgbe_prv_data *);
726c5aa9e3bSLendacky, Thomas 	void (*free_ring_resources)(struct xgbe_prv_data *);
727c5aa9e3bSLendacky, Thomas 	int (*map_tx_skb)(struct xgbe_channel *, struct sk_buff *);
728270894e7SLendacky, Thomas 	int (*map_rx_buffer)(struct xgbe_prv_data *, struct xgbe_ring *,
729270894e7SLendacky, Thomas 			     struct xgbe_ring_data *);
73008dcc47cSLendacky, Thomas 	void (*unmap_rdata)(struct xgbe_prv_data *, struct xgbe_ring_data *);
731c5aa9e3bSLendacky, Thomas 	void (*wrapper_tx_desc_init)(struct xgbe_prv_data *);
732c5aa9e3bSLendacky, Thomas 	void (*wrapper_rx_desc_init)(struct xgbe_prv_data *);
733c5aa9e3bSLendacky, Thomas };
734c5aa9e3bSLendacky, Thomas 
735c5aa9e3bSLendacky, Thomas /* This structure contains flags that indicate what hardware features
736c5aa9e3bSLendacky, Thomas  * or configurations are present in the device.
737c5aa9e3bSLendacky, Thomas  */
738c5aa9e3bSLendacky, Thomas struct xgbe_hw_features {
739a9a4a2d9SLendacky, Thomas 	/* HW Version */
740a9a4a2d9SLendacky, Thomas 	unsigned int version;
741a9a4a2d9SLendacky, Thomas 
742c5aa9e3bSLendacky, Thomas 	/* HW Feature Register0 */
743c5aa9e3bSLendacky, Thomas 	unsigned int gmii;		/* 1000 Mbps support */
744c5aa9e3bSLendacky, Thomas 	unsigned int vlhash;		/* VLAN Hash Filter */
745c5aa9e3bSLendacky, Thomas 	unsigned int sma;		/* SMA(MDIO) Interface */
746c5aa9e3bSLendacky, Thomas 	unsigned int rwk;		/* PMT remote wake-up packet */
747c5aa9e3bSLendacky, Thomas 	unsigned int mgk;		/* PMT magic packet */
748c5aa9e3bSLendacky, Thomas 	unsigned int mmc;		/* RMON module */
749c5aa9e3bSLendacky, Thomas 	unsigned int aoe;		/* ARP Offload */
750dbedd44eSJoe Perches 	unsigned int ts;		/* IEEE 1588-2008 Advanced Timestamp */
751c5aa9e3bSLendacky, Thomas 	unsigned int eee;		/* Energy Efficient Ethernet */
752c5aa9e3bSLendacky, Thomas 	unsigned int tx_coe;		/* Tx Checksum Offload */
753c5aa9e3bSLendacky, Thomas 	unsigned int rx_coe;		/* Rx Checksum Offload */
754c5aa9e3bSLendacky, Thomas 	unsigned int addn_mac;		/* Additional MAC Addresses */
755c5aa9e3bSLendacky, Thomas 	unsigned int ts_src;		/* Timestamp Source */
756c5aa9e3bSLendacky, Thomas 	unsigned int sa_vlan_ins;	/* Source Address or VLAN Insertion */
757c5aa9e3bSLendacky, Thomas 
758c5aa9e3bSLendacky, Thomas 	/* HW Feature Register1 */
759c5aa9e3bSLendacky, Thomas 	unsigned int rx_fifo_size;	/* MTL Receive FIFO Size */
760c5aa9e3bSLendacky, Thomas 	unsigned int tx_fifo_size;	/* MTL Transmit FIFO Size */
761c5aa9e3bSLendacky, Thomas 	unsigned int adv_ts_hi;		/* Advance Timestamping High Word */
762386d325dSLendacky, Thomas 	unsigned int dma_width;		/* DMA width */
763c5aa9e3bSLendacky, Thomas 	unsigned int dcb;		/* DCB Feature */
764c5aa9e3bSLendacky, Thomas 	unsigned int sph;		/* Split Header Feature */
765c5aa9e3bSLendacky, Thomas 	unsigned int tso;		/* TCP Segmentation Offload */
766c5aa9e3bSLendacky, Thomas 	unsigned int dma_debug;		/* DMA Debug Registers */
767c5aa9e3bSLendacky, Thomas 	unsigned int rss;		/* Receive Side Scaling */
768fca2d994SLendacky, Thomas 	unsigned int tc_cnt;		/* Number of Traffic Classes */
769c5aa9e3bSLendacky, Thomas 	unsigned int hash_table_size;	/* Hash Table Size */
770c5aa9e3bSLendacky, Thomas 	unsigned int l3l4_filter_num;	/* Number of L3-L4 Filters */
771c5aa9e3bSLendacky, Thomas 
772c5aa9e3bSLendacky, Thomas 	/* HW Feature Register2 */
773c5aa9e3bSLendacky, Thomas 	unsigned int rx_q_cnt;		/* Number of MTL Receive Queues */
774c5aa9e3bSLendacky, Thomas 	unsigned int tx_q_cnt;		/* Number of MTL Transmit Queues */
775c5aa9e3bSLendacky, Thomas 	unsigned int rx_ch_cnt;		/* Number of DMA Receive Channels */
776c5aa9e3bSLendacky, Thomas 	unsigned int tx_ch_cnt;		/* Number of DMA Transmit Channels */
777c5aa9e3bSLendacky, Thomas 	unsigned int pps_out_num;	/* Number of PPS outputs */
778c5aa9e3bSLendacky, Thomas 	unsigned int aux_snap_num;	/* Number of Aux snapshot inputs */
779c5aa9e3bSLendacky, Thomas };
780c5aa9e3bSLendacky, Thomas 
781c5aa9e3bSLendacky, Thomas struct xgbe_prv_data {
782c5aa9e3bSLendacky, Thomas 	struct net_device *netdev;
783c5aa9e3bSLendacky, Thomas 	struct platform_device *pdev;
78482a19035SLendacky, Thomas 	struct acpi_device *adev;
785c5aa9e3bSLendacky, Thomas 	struct device *dev;
786c5aa9e3bSLendacky, Thomas 
78782a19035SLendacky, Thomas 	/* ACPI or DT flag */
78882a19035SLendacky, Thomas 	unsigned int use_acpi;
78982a19035SLendacky, Thomas 
790c5aa9e3bSLendacky, Thomas 	/* XGMAC/XPCS related mmio registers */
791c5aa9e3bSLendacky, Thomas 	void __iomem *xgmac_regs;	/* XGMAC CSRs */
792c5aa9e3bSLendacky, Thomas 	void __iomem *xpcs_regs;	/* XPCS MMD registers */
7937c12aa08SLendacky, Thomas 	void __iomem *rxtx_regs;	/* SerDes Rx/Tx CSRs */
7947c12aa08SLendacky, Thomas 	void __iomem *sir0_regs;	/* SerDes integration registers (1/2) */
7957c12aa08SLendacky, Thomas 	void __iomem *sir1_regs;	/* SerDes integration registers (2/2) */
796c5aa9e3bSLendacky, Thomas 
797c5aa9e3bSLendacky, Thomas 	/* Overall device lock */
798c5aa9e3bSLendacky, Thomas 	spinlock_t lock;
799c5aa9e3bSLendacky, Thomas 
800ced3fcaeSLendacky, Thomas 	/* XPCS indirect addressing lock */
801ced3fcaeSLendacky, Thomas 	spinlock_t xpcs_lock;
802c5aa9e3bSLendacky, Thomas 
8035b9dfe29SLendacky, Thomas 	/* RSS addressing mutex */
8045b9dfe29SLendacky, Thomas 	struct mutex rss_mutex;
8055b9dfe29SLendacky, Thomas 
8067c12aa08SLendacky, Thomas 	/* Flags representing xgbe_state */
8077c12aa08SLendacky, Thomas 	unsigned long dev_state;
8087c12aa08SLendacky, Thomas 
8099227dc5eSLendacky, Thomas 	int dev_irq;
8109227dc5eSLendacky, Thomas 	unsigned int per_channel_irq;
811c5aa9e3bSLendacky, Thomas 
812c5aa9e3bSLendacky, Thomas 	struct xgbe_hw_if hw_if;
8137c12aa08SLendacky, Thomas 	struct xgbe_phy_if phy_if;
814c5aa9e3bSLendacky, Thomas 	struct xgbe_desc_if desc_if;
815c5aa9e3bSLendacky, Thomas 
816cfa50c78SLendacky, Thomas 	/* AXI DMA settings */
81782a19035SLendacky, Thomas 	unsigned int coherent;
818cfa50c78SLendacky, Thomas 	unsigned int axdomain;
819cfa50c78SLendacky, Thomas 	unsigned int arcache;
820cfa50c78SLendacky, Thomas 	unsigned int awcache;
821cfa50c78SLendacky, Thomas 
8227c12aa08SLendacky, Thomas 	/* Service routine support */
8237c12aa08SLendacky, Thomas 	struct workqueue_struct *dev_workqueue;
8247c12aa08SLendacky, Thomas 	struct work_struct service_work;
8257c12aa08SLendacky, Thomas 	struct timer_list service_timer;
8267c12aa08SLendacky, Thomas 
827c5aa9e3bSLendacky, Thomas 	/* Rings for Tx/Rx on a DMA channel */
828c5aa9e3bSLendacky, Thomas 	struct xgbe_channel *channel;
829c5aa9e3bSLendacky, Thomas 	unsigned int channel_count;
830c5aa9e3bSLendacky, Thomas 	unsigned int tx_ring_count;
831c5aa9e3bSLendacky, Thomas 	unsigned int tx_desc_count;
832c5aa9e3bSLendacky, Thomas 	unsigned int rx_ring_count;
833c5aa9e3bSLendacky, Thomas 	unsigned int rx_desc_count;
834c5aa9e3bSLendacky, Thomas 
835853eb16bSLendacky, Thomas 	unsigned int tx_q_count;
836853eb16bSLendacky, Thomas 	unsigned int rx_q_count;
837853eb16bSLendacky, Thomas 
838c5aa9e3bSLendacky, Thomas 	/* Tx/Rx common settings */
839c5aa9e3bSLendacky, Thomas 	unsigned int pblx8;
840c5aa9e3bSLendacky, Thomas 
841c5aa9e3bSLendacky, Thomas 	/* Tx settings */
842c5aa9e3bSLendacky, Thomas 	unsigned int tx_sf_mode;
843c5aa9e3bSLendacky, Thomas 	unsigned int tx_threshold;
844c5aa9e3bSLendacky, Thomas 	unsigned int tx_pbl;
845c5aa9e3bSLendacky, Thomas 	unsigned int tx_osp_mode;
846c5aa9e3bSLendacky, Thomas 
847c5aa9e3bSLendacky, Thomas 	/* Rx settings */
848c5aa9e3bSLendacky, Thomas 	unsigned int rx_sf_mode;
849c5aa9e3bSLendacky, Thomas 	unsigned int rx_threshold;
850c5aa9e3bSLendacky, Thomas 	unsigned int rx_pbl;
851c5aa9e3bSLendacky, Thomas 
852c5aa9e3bSLendacky, Thomas 	/* Tx coalescing settings */
853c5aa9e3bSLendacky, Thomas 	unsigned int tx_usecs;
854c5aa9e3bSLendacky, Thomas 	unsigned int tx_frames;
855c5aa9e3bSLendacky, Thomas 
856c5aa9e3bSLendacky, Thomas 	/* Rx coalescing settings */
857c5aa9e3bSLendacky, Thomas 	unsigned int rx_riwt;
8584a57ebccSLendacky, Thomas 	unsigned int rx_usecs;
859c5aa9e3bSLendacky, Thomas 	unsigned int rx_frames;
860c5aa9e3bSLendacky, Thomas 
86108dcc47cSLendacky, Thomas 	/* Current Rx buffer size */
862c5aa9e3bSLendacky, Thomas 	unsigned int rx_buf_size;
863c5aa9e3bSLendacky, Thomas 
864c5aa9e3bSLendacky, Thomas 	/* Flow control settings */
865c5aa9e3bSLendacky, Thomas 	unsigned int pause_autoneg;
866c5aa9e3bSLendacky, Thomas 	unsigned int tx_pause;
867c5aa9e3bSLendacky, Thomas 	unsigned int rx_pause;
868*43e0dcf7SLendacky, Thomas 	unsigned int rx_rfa[XGBE_MAX_QUEUES];
869*43e0dcf7SLendacky, Thomas 	unsigned int rx_rfd[XGBE_MAX_QUEUES];
870c5aa9e3bSLendacky, Thomas 
8715b9dfe29SLendacky, Thomas 	/* Receive Side Scaling settings */
8725b9dfe29SLendacky, Thomas 	u8 rss_key[XGBE_RSS_HASH_KEY_SIZE];
8735b9dfe29SLendacky, Thomas 	u32 rss_table[XGBE_RSS_MAX_TABLE_SIZE];
8745b9dfe29SLendacky, Thomas 	u32 rss_options;
8755b9dfe29SLendacky, Thomas 
876c5aa9e3bSLendacky, Thomas 	/* Netdev related settings */
87782a19035SLendacky, Thomas 	unsigned char mac_addr[ETH_ALEN];
878c5aa9e3bSLendacky, Thomas 	netdev_features_t netdev_features;
879c5aa9e3bSLendacky, Thomas 	struct napi_struct napi;
880c5aa9e3bSLendacky, Thomas 	struct xgbe_mmc_stats mmc_stats;
8815452b2dfSLendacky, Thomas 	struct xgbe_ext_stats ext_stats;
882c5aa9e3bSLendacky, Thomas 
883801c62d9SLendacky, Thomas 	/* Filtering support */
884801c62d9SLendacky, Thomas 	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
885801c62d9SLendacky, Thomas 
88623e4eef7SLendacky, Thomas 	/* Device clocks */
88723e4eef7SLendacky, Thomas 	struct clk *sysclk;
88882a19035SLendacky, Thomas 	unsigned long sysclk_rate;
88923e4eef7SLendacky, Thomas 	struct clk *ptpclk;
89082a19035SLendacky, Thomas 	unsigned long ptpclk_rate;
89123e4eef7SLendacky, Thomas 
89223e4eef7SLendacky, Thomas 	/* Timestamp support */
89323e4eef7SLendacky, Thomas 	spinlock_t tstamp_lock;
89423e4eef7SLendacky, Thomas 	struct ptp_clock_info ptp_clock_info;
89523e4eef7SLendacky, Thomas 	struct ptp_clock *ptp_clock;
89623e4eef7SLendacky, Thomas 	struct hwtstamp_config tstamp_config;
89723e4eef7SLendacky, Thomas 	struct cyclecounter tstamp_cc;
89823e4eef7SLendacky, Thomas 	struct timecounter tstamp_tc;
89923e4eef7SLendacky, Thomas 	unsigned int tstamp_addend;
90023e4eef7SLendacky, Thomas 	struct work_struct tx_tstamp_work;
90123e4eef7SLendacky, Thomas 	struct sk_buff *tx_tstamp_skb;
90223e4eef7SLendacky, Thomas 	u64 tx_tstamp;
903c5aa9e3bSLendacky, Thomas 
904fca2d994SLendacky, Thomas 	/* DCB support */
905fca2d994SLendacky, Thomas 	struct ieee_ets *ets;
906fca2d994SLendacky, Thomas 	struct ieee_pfc *pfc;
907fca2d994SLendacky, Thomas 	unsigned int q2tc_map[XGBE_MAX_QUEUES];
908fca2d994SLendacky, Thomas 	unsigned int prio2q_map[IEEE_8021QAZ_MAX_TCS];
909*43e0dcf7SLendacky, Thomas 	unsigned int pfcq[XGBE_MAX_QUEUES];
910*43e0dcf7SLendacky, Thomas 	unsigned int pfc_rfa;
911b3b71597SLendacky, Thomas 	u8 num_tcs;
912fca2d994SLendacky, Thomas 
913c5aa9e3bSLendacky, Thomas 	/* Hardware features of the device */
914c5aa9e3bSLendacky, Thomas 	struct xgbe_hw_features hw_feat;
915c5aa9e3bSLendacky, Thomas 
916c5aa9e3bSLendacky, Thomas 	/* Device restart work structure */
917c5aa9e3bSLendacky, Thomas 	struct work_struct restart_work;
918c5aa9e3bSLendacky, Thomas 
919c5aa9e3bSLendacky, Thomas 	/* Keeps track of power mode */
920c5aa9e3bSLendacky, Thomas 	unsigned int power_down;
921c5aa9e3bSLendacky, Thomas 
92234bf65dfSLendacky, Thomas 	/* Network interface message level setting */
92334bf65dfSLendacky, Thomas 	u32 msg_enable;
92434bf65dfSLendacky, Thomas 
9257c12aa08SLendacky, Thomas 	/* Current PHY settings */
9267c12aa08SLendacky, Thomas 	phy_interface_t phy_mode;
9277c12aa08SLendacky, Thomas 	int phy_link;
9287c12aa08SLendacky, Thomas 	int phy_speed;
9297c12aa08SLendacky, Thomas 
9307c12aa08SLendacky, Thomas 	/* MDIO/PHY related settings */
9317c12aa08SLendacky, Thomas 	struct xgbe_phy phy;
9327c12aa08SLendacky, Thomas 	int mdio_mmd;
9337c12aa08SLendacky, Thomas 	unsigned long link_check;
9347c12aa08SLendacky, Thomas 
9357c12aa08SLendacky, Thomas 	char an_name[IFNAMSIZ + 32];
9367c12aa08SLendacky, Thomas 	struct workqueue_struct *an_workqueue;
9377c12aa08SLendacky, Thomas 
9387c12aa08SLendacky, Thomas 	int an_irq;
9397c12aa08SLendacky, Thomas 	struct work_struct an_irq_work;
9407c12aa08SLendacky, Thomas 
9417c12aa08SLendacky, Thomas 	unsigned int speed_set;
9427c12aa08SLendacky, Thomas 
9437c12aa08SLendacky, Thomas 	/* SerDes UEFI configurable settings.
9447c12aa08SLendacky, Thomas 	 *   Switching between modes/speeds requires new values for some
9457c12aa08SLendacky, Thomas 	 *   SerDes settings.  The values can be supplied as device
9467c12aa08SLendacky, Thomas 	 *   properties in array format.  The first array entry is for
9477c12aa08SLendacky, Thomas 	 *   1GbE, second for 2.5GbE and third for 10GbE
9487c12aa08SLendacky, Thomas 	 */
9497c12aa08SLendacky, Thomas 	u32 serdes_blwc[XGBE_SPEEDS];
9507c12aa08SLendacky, Thomas 	u32 serdes_cdr_rate[XGBE_SPEEDS];
9517c12aa08SLendacky, Thomas 	u32 serdes_pq_skew[XGBE_SPEEDS];
9527c12aa08SLendacky, Thomas 	u32 serdes_tx_amp[XGBE_SPEEDS];
9537c12aa08SLendacky, Thomas 	u32 serdes_dfe_tap_cfg[XGBE_SPEEDS];
9547c12aa08SLendacky, Thomas 	u32 serdes_dfe_tap_ena[XGBE_SPEEDS];
9557c12aa08SLendacky, Thomas 
9567c12aa08SLendacky, Thomas 	/* Auto-negotiation state machine support */
957ced3fcaeSLendacky, Thomas 	unsigned int an_int;
9587c12aa08SLendacky, Thomas 	struct mutex an_mutex;
9597c12aa08SLendacky, Thomas 	enum xgbe_an an_result;
9607c12aa08SLendacky, Thomas 	enum xgbe_an an_state;
9617c12aa08SLendacky, Thomas 	enum xgbe_rx kr_state;
9627c12aa08SLendacky, Thomas 	enum xgbe_rx kx_state;
9637c12aa08SLendacky, Thomas 	struct work_struct an_work;
9647c12aa08SLendacky, Thomas 	unsigned int an_supported;
9657c12aa08SLendacky, Thomas 	unsigned int parallel_detect;
9667c12aa08SLendacky, Thomas 	unsigned int fec_ability;
9677c12aa08SLendacky, Thomas 	unsigned long an_start;
9687c12aa08SLendacky, Thomas 
9697c12aa08SLendacky, Thomas 	unsigned int lpm_ctrl;		/* CTRL1 for resume */
9707c12aa08SLendacky, Thomas 
971c5aa9e3bSLendacky, Thomas #ifdef CONFIG_DEBUG_FS
972c5aa9e3bSLendacky, Thomas 	struct dentry *xgbe_debugfs;
973c5aa9e3bSLendacky, Thomas 
974c5aa9e3bSLendacky, Thomas 	unsigned int debugfs_xgmac_reg;
975c5aa9e3bSLendacky, Thomas 
976c5aa9e3bSLendacky, Thomas 	unsigned int debugfs_xpcs_mmd;
977c5aa9e3bSLendacky, Thomas 	unsigned int debugfs_xpcs_reg;
978c5aa9e3bSLendacky, Thomas #endif
979c5aa9e3bSLendacky, Thomas };
980c5aa9e3bSLendacky, Thomas 
981c5aa9e3bSLendacky, Thomas /* Function prototypes*/
982c5aa9e3bSLendacky, Thomas 
983c5aa9e3bSLendacky, Thomas void xgbe_init_function_ptrs_dev(struct xgbe_hw_if *);
9847c12aa08SLendacky, Thomas void xgbe_init_function_ptrs_phy(struct xgbe_phy_if *);
985c5aa9e3bSLendacky, Thomas void xgbe_init_function_ptrs_desc(struct xgbe_desc_if *);
986ce0b15d1Sstephen hemminger const struct net_device_ops *xgbe_get_netdev_ops(void);
987ce0b15d1Sstephen hemminger const struct ethtool_ops *xgbe_get_ethtool_ops(void);
988ce0b15d1Sstephen hemminger 
989fca2d994SLendacky, Thomas #ifdef CONFIG_AMD_XGBE_DCB
990fca2d994SLendacky, Thomas const struct dcbnl_rtnl_ops *xgbe_get_dcbnl_ops(void);
991fca2d994SLendacky, Thomas #endif
992c5aa9e3bSLendacky, Thomas 
99323e4eef7SLendacky, Thomas void xgbe_ptp_register(struct xgbe_prv_data *);
99423e4eef7SLendacky, Thomas void xgbe_ptp_unregister(struct xgbe_prv_data *);
99534bf65dfSLendacky, Thomas void xgbe_dump_tx_desc(struct xgbe_prv_data *, struct xgbe_ring *,
99634bf65dfSLendacky, Thomas 		       unsigned int, unsigned int, unsigned int);
99734bf65dfSLendacky, Thomas void xgbe_dump_rx_desc(struct xgbe_prv_data *, struct xgbe_ring *,
998c5aa9e3bSLendacky, Thomas 		       unsigned int);
999c5aa9e3bSLendacky, Thomas void xgbe_print_pkt(struct net_device *, struct sk_buff *, bool);
1000c5aa9e3bSLendacky, Thomas void xgbe_get_all_hw_features(struct xgbe_prv_data *);
1001c5aa9e3bSLendacky, Thomas int xgbe_powerup(struct net_device *, unsigned int);
1002c5aa9e3bSLendacky, Thomas int xgbe_powerdown(struct net_device *, unsigned int);
1003c5aa9e3bSLendacky, Thomas void xgbe_init_rx_coalesce(struct xgbe_prv_data *);
1004c5aa9e3bSLendacky, Thomas void xgbe_init_tx_coalesce(struct xgbe_prv_data *);
1005c5aa9e3bSLendacky, Thomas 
1006c5aa9e3bSLendacky, Thomas #ifdef CONFIG_DEBUG_FS
1007c5aa9e3bSLendacky, Thomas void xgbe_debugfs_init(struct xgbe_prv_data *);
1008c5aa9e3bSLendacky, Thomas void xgbe_debugfs_exit(struct xgbe_prv_data *);
1009c5aa9e3bSLendacky, Thomas #else
1010c5aa9e3bSLendacky, Thomas static inline void xgbe_debugfs_init(struct xgbe_prv_data *pdata) {}
1011c5aa9e3bSLendacky, Thomas static inline void xgbe_debugfs_exit(struct xgbe_prv_data *pdata) {}
1012c5aa9e3bSLendacky, Thomas #endif /* CONFIG_DEBUG_FS */
1013c5aa9e3bSLendacky, Thomas 
1014c5aa9e3bSLendacky, Thomas /* NOTE: Uncomment for function trace log messages in KERNEL LOG */
1015c5aa9e3bSLendacky, Thomas #if 0
1016c5aa9e3bSLendacky, Thomas #define YDEBUG
1017c5aa9e3bSLendacky, Thomas #define YDEBUG_MDIO
1018c5aa9e3bSLendacky, Thomas #endif
1019c5aa9e3bSLendacky, Thomas 
1020c5aa9e3bSLendacky, Thomas /* For debug prints */
1021c5aa9e3bSLendacky, Thomas #ifdef YDEBUG
1022c5aa9e3bSLendacky, Thomas #define DBGPR(x...) pr_alert(x)
1023c5aa9e3bSLendacky, Thomas #else
1024c5aa9e3bSLendacky, Thomas #define DBGPR(x...) do { } while (0)
1025c5aa9e3bSLendacky, Thomas #endif
1026c5aa9e3bSLendacky, Thomas 
1027c5aa9e3bSLendacky, Thomas #ifdef YDEBUG_MDIO
1028c5aa9e3bSLendacky, Thomas #define DBGPR_MDIO(x...) pr_alert(x)
1029c5aa9e3bSLendacky, Thomas #else
1030c5aa9e3bSLendacky, Thomas #define DBGPR_MDIO(x...) do { } while (0)
1031c5aa9e3bSLendacky, Thomas #endif
1032c5aa9e3bSLendacky, Thomas 
1033c5aa9e3bSLendacky, Thomas #endif
1034