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>
1305ab1dcd5SLendacky, Thomas #include <linux/completion.h>
131f00ba49dSLendacky, Thomas #include <linux/cpumask.h>
1320ab10314SFlorian Westphal #include <linux/interrupt.h>
133efbaa828SLendacky, Thomas #include <linux/dcache.h>
13485f9feb6SLendacky, Thomas #include <linux/ethtool.h>
1351a510ccfSLendacky, Thomas #include <linux/list.h>
136c5aa9e3bSLendacky, Thomas
137c5aa9e3bSLendacky, Thomas #define XGBE_DRV_NAME "amd-xgbe"
138c5aa9e3bSLendacky, Thomas #define XGBE_DRV_DESC "AMD 10 Gigabit Ethernet Driver"
139c5aa9e3bSLendacky, Thomas
140c5aa9e3bSLendacky, Thomas /* Descriptor related defines */
141d0a8ba6cSLendacky, Thomas #define XGBE_TX_DESC_CNT 512
142d0a8ba6cSLendacky, Thomas #define XGBE_TX_DESC_MIN_FREE (XGBE_TX_DESC_CNT >> 3)
143d0a8ba6cSLendacky, Thomas #define XGBE_TX_DESC_MAX_PROC (XGBE_TX_DESC_CNT >> 1)
144d0a8ba6cSLendacky, Thomas #define XGBE_RX_DESC_CNT 512
145c5aa9e3bSLendacky, Thomas
146bab748deSTom Lendacky #define XGBE_TX_DESC_CNT_MIN 64
147bab748deSTom Lendacky #define XGBE_TX_DESC_CNT_MAX 4096
148bab748deSTom Lendacky #define XGBE_RX_DESC_CNT_MIN 64
149bab748deSTom Lendacky #define XGBE_RX_DESC_CNT_MAX 4096
150bab748deSTom Lendacky
151d0a8ba6cSLendacky, Thomas #define XGBE_TX_MAX_BUF_SIZE (0x3fff & ~(64 - 1))
152c5aa9e3bSLendacky, Thomas
153e1c05067SMasahiro Yamada /* Descriptors required for maximum contiguous TSO/GSO packet */
1547c4e983cSAlexander Duyck #define XGBE_TX_MAX_SPLIT \
1557c4e983cSAlexander Duyck ((GSO_LEGACY_MAX_SIZE / XGBE_TX_MAX_BUF_SIZE) + 1)
15616958a2bSLendacky, Thomas
15716958a2bSLendacky, Thomas /* Maximum possible descriptors needed for an SKB:
15816958a2bSLendacky, Thomas * - Maximum number of SKB frags
15916958a2bSLendacky, Thomas * - Maximum descriptors for contiguous TSO/GSO packet
16016958a2bSLendacky, Thomas * - Possible context descriptor
16116958a2bSLendacky, Thomas * - Possible TSO header descriptor
16216958a2bSLendacky, Thomas */
16316958a2bSLendacky, Thomas #define XGBE_TX_MAX_DESCS (MAX_SKB_FRAGS + XGBE_TX_MAX_SPLIT + 2)
16416958a2bSLendacky, Thomas
165d0a8ba6cSLendacky, Thomas #define XGBE_RX_MIN_BUF_SIZE (ETH_FRAME_LEN + ETH_FCS_LEN + VLAN_HLEN)
166d0a8ba6cSLendacky, Thomas #define XGBE_RX_BUF_ALIGN 64
16708dcc47cSLendacky, Thomas #define XGBE_SKB_ALLOC_SIZE 256
168174fd259SLendacky, Thomas #define XGBE_SPH_HDSMS_SIZE 2 /* Keep in sync with SKB_ALLOC_SIZE */
169c5aa9e3bSLendacky, Thomas
170d5c48582SLendacky, Thomas #define XGBE_MAX_DMA_CHANNELS 16
171fca2d994SLendacky, Thomas #define XGBE_MAX_QUEUES 16
17243e0dcf7SLendacky, Thomas #define XGBE_PRIORITY_QUEUES 8
1734b8acdf5SLendacky, Thomas #define XGBE_DMA_STOP_TIMEOUT 1
174d0a8ba6cSLendacky, Thomas
175d0a8ba6cSLendacky, Thomas /* DMA cache settings - Outer sharable, write-back, write-allocate */
1769916716aSLendacky, Thomas #define XGBE_DMA_OS_ARCR 0x002b2b2b
1779916716aSLendacky, Thomas #define XGBE_DMA_OS_AWCR 0x2f2f2f2f
178cfa50c78SLendacky, Thomas
179cfa50c78SLendacky, Thomas /* DMA cache settings - System, no caches used */
1809916716aSLendacky, Thomas #define XGBE_DMA_SYS_ARCR 0x00303030
1819916716aSLendacky, Thomas #define XGBE_DMA_SYS_AWCR 0x30303030
182d0a8ba6cSLendacky, Thomas
1836f595959SLendacky, Thomas /* DMA cache settings - PCI device */
184d7513508SShyam Sundar S K #define XGBE_DMA_PCI_ARCR 0x000f0f0f
185d7513508SShyam Sundar S K #define XGBE_DMA_PCI_AWCR 0x0f0f0f0f
186d7513508SShyam Sundar S K #define XGBE_DMA_PCI_AWARCR 0x00000f0f
1876f595959SLendacky, Thomas
1884c70dd8aSLendacky, Thomas /* DMA channel interrupt modes */
1894c70dd8aSLendacky, Thomas #define XGBE_IRQ_MODE_EDGE 0
1904c70dd8aSLendacky, Thomas #define XGBE_IRQ_MODE_LEVEL 1
1914c70dd8aSLendacky, Thomas
192c5aa9e3bSLendacky, Thomas #define XGMAC_MIN_PACKET 60
193c5aa9e3bSLendacky, Thomas #define XGMAC_STD_PACKET_MTU 1500
194c5aa9e3bSLendacky, Thomas #define XGMAC_MAX_STD_PACKET 1518
195c5aa9e3bSLendacky, Thomas #define XGMAC_JUMBO_PACKET_MTU 9000
196c5aa9e3bSLendacky, Thomas #define XGMAC_MAX_JUMBO_PACKET 9018
19743e0dcf7SLendacky, Thomas #define XGMAC_ETH_PREAMBLE (12 + 8) /* Inter-frame gap + preamble */
19843e0dcf7SLendacky, Thomas
19943e0dcf7SLendacky, Thomas #define XGMAC_PFC_DATA_LEN 46
20043e0dcf7SLendacky, Thomas #define XGMAC_PFC_DELAYS 14000
20143e0dcf7SLendacky, Thomas
20243e0dcf7SLendacky, Thomas #define XGMAC_PRIO_QUEUES(_cnt) \
20343e0dcf7SLendacky, Thomas min_t(unsigned int, IEEE_8021QAZ_MAX_TCS, (_cnt))
204c5aa9e3bSLendacky, Thomas
20582a19035SLendacky, Thomas /* Common property names */
20682a19035SLendacky, Thomas #define XGBE_MAC_ADDR_PROPERTY "mac-address"
20782a19035SLendacky, Thomas #define XGBE_PHY_MODE_PROPERTY "phy-mode"
20882a19035SLendacky, Thomas #define XGBE_DMA_IRQS_PROPERTY "amd,per-channel-interrupt"
2097c12aa08SLendacky, Thomas #define XGBE_SPEEDSET_PROPERTY "amd,speed-set"
21082a19035SLendacky, Thomas
21123e4eef7SLendacky, Thomas /* Device-tree clock names */
21223e4eef7SLendacky, Thomas #define XGBE_DMA_CLOCK "dma_clk"
21323e4eef7SLendacky, Thomas #define XGBE_PTP_CLOCK "ptp_clk"
21482a19035SLendacky, Thomas
21582a19035SLendacky, Thomas /* ACPI property names */
21682a19035SLendacky, Thomas #define XGBE_ACPI_DMA_FREQ "amd,dma-freq"
21782a19035SLendacky, Thomas #define XGBE_ACPI_PTP_FREQ "amd,ptp-freq"
21823e4eef7SLendacky, Thomas
21947f164deSLendacky, Thomas /* PCI BAR mapping */
22047f164deSLendacky, Thomas #define XGBE_XGMAC_BAR 0
22147f164deSLendacky, Thomas #define XGBE_XPCS_BAR 1
22247f164deSLendacky, Thomas #define XGBE_MAC_PROP_OFFSET 0x1d000
22347f164deSLendacky, Thomas #define XGBE_I2C_CTRL_OFFSET 0x1e000
22447f164deSLendacky, Thomas
225e7537740STom Lendacky /* PCI MSI/MSIx support */
226e7537740STom Lendacky #define XGBE_MSI_BASE_COUNT 4
227e7537740STom Lendacky #define XGBE_MSI_MIN_COUNT (XGBE_MSI_BASE_COUNT + 1)
22847f164deSLendacky, Thomas
22947f164deSLendacky, Thomas /* PCI clock frequencies */
23047f164deSLendacky, Thomas #define XGBE_V2_DMA_CLOCK_FREQ 500000000 /* 500 MHz */
23147f164deSLendacky, Thomas #define XGBE_V2_PTP_CLOCK_FREQ 125000000 /* 125 MHz */
23247f164deSLendacky, Thomas
23323e4eef7SLendacky, Thomas /* Timestamp support - values based on 50MHz PTP clock
23423e4eef7SLendacky, Thomas * 50MHz => 20 nsec
23523e4eef7SLendacky, Thomas */
23623e4eef7SLendacky, Thomas #define XGBE_TSTAMP_SSINC 20
23723e4eef7SLendacky, Thomas #define XGBE_TSTAMP_SNSINC 0
23823e4eef7SLendacky, Thomas
239c5aa9e3bSLendacky, Thomas /* Driver PMT macros */
240c5aa9e3bSLendacky, Thomas #define XGMAC_DRIVER_CONTEXT 1
241c5aa9e3bSLendacky, Thomas #define XGMAC_IOCTL_CONTEXT 2
242c5aa9e3bSLendacky, Thomas
24343e0dcf7SLendacky, Thomas #define XGMAC_FIFO_MIN_ALLOC 2048
24443e0dcf7SLendacky, Thomas #define XGMAC_FIFO_UNIT 256
24543e0dcf7SLendacky, Thomas #define XGMAC_FIFO_ALIGN(_x) \
24643e0dcf7SLendacky, Thomas (((_x) + XGMAC_FIFO_UNIT - 1) & ~(XGMAC_FIFO_UNIT - 1))
24743e0dcf7SLendacky, Thomas #define XGMAC_FIFO_FC_OFF 2048
24843e0dcf7SLendacky, Thomas #define XGMAC_FIFO_FC_MIN 4096
249c5aa9e3bSLendacky, Thomas
250fca2d994SLendacky, Thomas #define XGBE_TC_MIN_QUANTUM 10
251c5aa9e3bSLendacky, Thomas
252c5aa9e3bSLendacky, Thomas /* Helper macro for descriptor handling
253d0a8ba6cSLendacky, Thomas * Always use XGBE_GET_DESC_DATA to access the descriptor data
254c5aa9e3bSLendacky, Thomas * since the index is free-running and needs to be and-ed
255c5aa9e3bSLendacky, Thomas * with the descriptor count value of the ring to index to
256c5aa9e3bSLendacky, Thomas * the proper descriptor data.
257c5aa9e3bSLendacky, Thomas */
258d0a8ba6cSLendacky, Thomas #define XGBE_GET_DESC_DATA(_ring, _idx) \
259c5aa9e3bSLendacky, Thomas ((_ring)->rdata + \
260c5aa9e3bSLendacky, Thomas ((_idx) & ((_ring)->rdesc_count - 1)))
261c5aa9e3bSLendacky, Thomas
262c5aa9e3bSLendacky, Thomas /* Default coalescing parameters */
263c635eaacSLendacky, Thomas #define XGMAC_INIT_DMA_TX_USECS 1000
2649867e8fbSLendacky, Thomas #define XGMAC_INIT_DMA_TX_FRAMES 25
265c5aa9e3bSLendacky, Thomas
266c5aa9e3bSLendacky, Thomas #define XGMAC_MAX_DMA_RIWT 0xff
2679867e8fbSLendacky, Thomas #define XGMAC_INIT_DMA_RX_USECS 30
2689867e8fbSLendacky, Thomas #define XGMAC_INIT_DMA_RX_FRAMES 25
269c5aa9e3bSLendacky, Thomas
270c5aa9e3bSLendacky, Thomas /* Flow control queue count */
271c5aa9e3bSLendacky, Thomas #define XGMAC_MAX_FLOW_CONTROL_QUEUES 8
272c5aa9e3bSLendacky, Thomas
27343e0dcf7SLendacky, Thomas /* Flow control threshold units */
27443e0dcf7SLendacky, Thomas #define XGMAC_FLOW_CONTROL_UNIT 512
27543e0dcf7SLendacky, Thomas #define XGMAC_FLOW_CONTROL_ALIGN(_x) \
27643e0dcf7SLendacky, Thomas (((_x) + XGMAC_FLOW_CONTROL_UNIT - 1) & ~(XGMAC_FLOW_CONTROL_UNIT - 1))
27743e0dcf7SLendacky, Thomas #define XGMAC_FLOW_CONTROL_VALUE(_x) \
27843e0dcf7SLendacky, Thomas (((_x) < 1024) ? 0 : ((_x) / XGMAC_FLOW_CONTROL_UNIT) - 2)
27943e0dcf7SLendacky, Thomas #define XGMAC_FLOW_CONTROL_MAX 33280
28043e0dcf7SLendacky, Thomas
281b85e4d89SLendacky, Thomas /* Maximum MAC address hash table size (256 bits = 8 bytes) */
282b85e4d89SLendacky, Thomas #define XGBE_MAC_HASH_TABLE_SIZE 8
283c5aa9e3bSLendacky, Thomas
2845b9dfe29SLendacky, Thomas /* Receive Side Scaling */
2855b9dfe29SLendacky, Thomas #define XGBE_RSS_HASH_KEY_SIZE 40
2865b9dfe29SLendacky, Thomas #define XGBE_RSS_MAX_TABLE_SIZE 256
2875b9dfe29SLendacky, Thomas #define XGBE_RSS_LOOKUP_TABLE_TYPE 0
2885b9dfe29SLendacky, Thomas #define XGBE_RSS_HASH_KEY_TYPE 1
2895b9dfe29SLendacky, Thomas
2907c12aa08SLendacky, Thomas /* Auto-negotiation */
2917c12aa08SLendacky, Thomas #define XGBE_AN_MS_TIMEOUT 500
2921bf40adaSLendacky, Thomas #define XGBE_LINK_TIMEOUT 5
293926446aeSRaju Rangoju #define XGBE_KR_TRAINING_WAIT_ITER 50
2941bf40adaSLendacky, Thomas
2951bf40adaSLendacky, Thomas #define XGBE_SGMII_AN_LINK_STATUS BIT(1)
2961bf40adaSLendacky, Thomas #define XGBE_SGMII_AN_LINK_SPEED (BIT(2) | BIT(3))
29707445f3cSRaju Rangoju #define XGBE_SGMII_AN_LINK_SPEED_10 0x00
2981bf40adaSLendacky, Thomas #define XGBE_SGMII_AN_LINK_SPEED_100 0x04
2991bf40adaSLendacky, Thomas #define XGBE_SGMII_AN_LINK_SPEED_1000 0x08
3001bf40adaSLendacky, Thomas #define XGBE_SGMII_AN_LINK_DUPLEX BIT(4)
3017c12aa08SLendacky, Thomas
302e78332b2SLendacky, Thomas /* ECC correctable error notification window (seconds) */
303e78332b2SLendacky, Thomas #define XGBE_ECC_LIMIT 60
304e78332b2SLendacky, Thomas
305732f2ab7SLendacky, Thomas /* MDIO port types */
306732f2ab7SLendacky, Thomas #define XGMAC_MAX_C22_PORT 3
307732f2ab7SLendacky, Thomas
30885f9feb6SLendacky, Thomas /* Link mode bit operations */
30985f9feb6SLendacky, Thomas #define XGBE_ZERO_SUP(_ls) \
31085f9feb6SLendacky, Thomas ethtool_link_ksettings_zero_link_mode((_ls), supported)
31185f9feb6SLendacky, Thomas
31285f9feb6SLendacky, Thomas #define XGBE_SET_SUP(_ls, _mode) \
31385f9feb6SLendacky, Thomas ethtool_link_ksettings_add_link_mode((_ls), supported, _mode)
31485f9feb6SLendacky, Thomas
31585f9feb6SLendacky, Thomas #define XGBE_CLR_SUP(_ls, _mode) \
31685f9feb6SLendacky, Thomas ethtool_link_ksettings_del_link_mode((_ls), supported, _mode)
31785f9feb6SLendacky, Thomas
31885f9feb6SLendacky, Thomas #define XGBE_IS_SUP(_ls, _mode) \
31985f9feb6SLendacky, Thomas ethtool_link_ksettings_test_link_mode((_ls), supported, _mode)
32085f9feb6SLendacky, Thomas
32185f9feb6SLendacky, Thomas #define XGBE_ZERO_ADV(_ls) \
32285f9feb6SLendacky, Thomas ethtool_link_ksettings_zero_link_mode((_ls), advertising)
32385f9feb6SLendacky, Thomas
32485f9feb6SLendacky, Thomas #define XGBE_SET_ADV(_ls, _mode) \
32585f9feb6SLendacky, Thomas ethtool_link_ksettings_add_link_mode((_ls), advertising, _mode)
32685f9feb6SLendacky, Thomas
32785f9feb6SLendacky, Thomas #define XGBE_CLR_ADV(_ls, _mode) \
32885f9feb6SLendacky, Thomas ethtool_link_ksettings_del_link_mode((_ls), advertising, _mode)
32985f9feb6SLendacky, Thomas
33085f9feb6SLendacky, Thomas #define XGBE_ADV(_ls, _mode) \
33185f9feb6SLendacky, Thomas ethtool_link_ksettings_test_link_mode((_ls), advertising, _mode)
33285f9feb6SLendacky, Thomas
33385f9feb6SLendacky, Thomas #define XGBE_ZERO_LP_ADV(_ls) \
33485f9feb6SLendacky, Thomas ethtool_link_ksettings_zero_link_mode((_ls), lp_advertising)
33585f9feb6SLendacky, Thomas
33685f9feb6SLendacky, Thomas #define XGBE_SET_LP_ADV(_ls, _mode) \
33785f9feb6SLendacky, Thomas ethtool_link_ksettings_add_link_mode((_ls), lp_advertising, _mode)
33885f9feb6SLendacky, Thomas
33985f9feb6SLendacky, Thomas #define XGBE_CLR_LP_ADV(_ls, _mode) \
34085f9feb6SLendacky, Thomas ethtool_link_ksettings_del_link_mode((_ls), lp_advertising, _mode)
34185f9feb6SLendacky, Thomas
34285f9feb6SLendacky, Thomas #define XGBE_LP_ADV(_ls, _mode) \
34385f9feb6SLendacky, Thomas ethtool_link_ksettings_test_link_mode((_ls), lp_advertising, _mode)
34485f9feb6SLendacky, Thomas
34585f9feb6SLendacky, Thomas #define XGBE_LM_COPY(_dst, _dname, _src, _sname) \
34685f9feb6SLendacky, Thomas bitmap_copy((_dst)->link_modes._dname, \
34785f9feb6SLendacky, Thomas (_src)->link_modes._sname, \
34885f9feb6SLendacky, Thomas __ETHTOOL_LINK_MODE_MASK_NBITS)
34985f9feb6SLendacky, Thomas
350c5aa9e3bSLendacky, Thomas struct xgbe_prv_data;
351c5aa9e3bSLendacky, Thomas
352c5aa9e3bSLendacky, Thomas struct xgbe_packet_data {
35316958a2bSLendacky, Thomas struct sk_buff *skb;
35416958a2bSLendacky, Thomas
355c5aa9e3bSLendacky, Thomas unsigned int attributes;
356c5aa9e3bSLendacky, Thomas
357c5aa9e3bSLendacky, Thomas unsigned int errors;
358c5aa9e3bSLendacky, Thomas
359c5aa9e3bSLendacky, Thomas unsigned int rdesc_count;
360c5aa9e3bSLendacky, Thomas unsigned int length;
361c5aa9e3bSLendacky, Thomas
362c5aa9e3bSLendacky, Thomas unsigned int header_len;
363c5aa9e3bSLendacky, Thomas unsigned int tcp_header_len;
364c5aa9e3bSLendacky, Thomas unsigned int tcp_payload_len;
365c5aa9e3bSLendacky, Thomas unsigned short mss;
366c5aa9e3bSLendacky, Thomas
367c5aa9e3bSLendacky, Thomas unsigned short vlan_ctag;
36823e4eef7SLendacky, Thomas
36923e4eef7SLendacky, Thomas u64 rx_tstamp;
3705b9dfe29SLendacky, Thomas
3715b9dfe29SLendacky, Thomas u32 rss_hash;
3725b9dfe29SLendacky, Thomas enum pkt_hash_types rss_hash_type;
3735fb4b86aSLendacky, Thomas
3745fb4b86aSLendacky, Thomas unsigned int tx_packets;
3755fb4b86aSLendacky, Thomas unsigned int tx_bytes;
376c5aa9e3bSLendacky, Thomas };
377c5aa9e3bSLendacky, Thomas
378c5aa9e3bSLendacky, Thomas /* Common Rx and Tx descriptor mapping */
379c5aa9e3bSLendacky, Thomas struct xgbe_ring_desc {
3805226cfc5SLendacky, Thomas __le32 desc0;
3815226cfc5SLendacky, Thomas __le32 desc1;
3825226cfc5SLendacky, Thomas __le32 desc2;
3835226cfc5SLendacky, Thomas __le32 desc3;
384c5aa9e3bSLendacky, Thomas };
385c5aa9e3bSLendacky, Thomas
38608dcc47cSLendacky, Thomas /* Page allocation related values */
38708dcc47cSLendacky, Thomas struct xgbe_page_alloc {
38808dcc47cSLendacky, Thomas struct page *pages;
38908dcc47cSLendacky, Thomas unsigned int pages_len;
39008dcc47cSLendacky, Thomas unsigned int pages_offset;
39108dcc47cSLendacky, Thomas
39208dcc47cSLendacky, Thomas dma_addr_t pages_dma;
39308dcc47cSLendacky, Thomas };
39408dcc47cSLendacky, Thomas
395174fd259SLendacky, Thomas /* Ring entry buffer data */
396174fd259SLendacky, Thomas struct xgbe_buffer_data {
397174fd259SLendacky, Thomas struct xgbe_page_alloc pa;
398174fd259SLendacky, Thomas struct xgbe_page_alloc pa_unmap;
399174fd259SLendacky, Thomas
400cfbfd86bSLendacky, Thomas dma_addr_t dma_base;
401cfbfd86bSLendacky, Thomas unsigned long dma_off;
402174fd259SLendacky, Thomas unsigned int dma_len;
403174fd259SLendacky, Thomas };
404174fd259SLendacky, Thomas
405c9f140ebSLendacky, Thomas /* Tx-related ring data */
406c9f140ebSLendacky, Thomas struct xgbe_tx_ring_data {
4075fb4b86aSLendacky, Thomas unsigned int packets; /* BQL packet count */
4085fb4b86aSLendacky, Thomas unsigned int bytes; /* BQL byte count */
409c9f140ebSLendacky, Thomas };
410c9f140ebSLendacky, Thomas
411c9f140ebSLendacky, Thomas /* Rx-related ring data */
412c9f140ebSLendacky, Thomas struct xgbe_rx_ring_data {
413c9f140ebSLendacky, Thomas struct xgbe_buffer_data hdr; /* Header locations */
414c9f140ebSLendacky, Thomas struct xgbe_buffer_data buf; /* Payload locations */
415c9f140ebSLendacky, Thomas
416c9f140ebSLendacky, Thomas unsigned short hdr_len; /* Length of received header */
417c9f140ebSLendacky, Thomas unsigned short len; /* Length of received packet */
418c9f140ebSLendacky, Thomas };
419c9f140ebSLendacky, Thomas
420c5aa9e3bSLendacky, Thomas /* Structure used to hold information related to the descriptor
421c5aa9e3bSLendacky, Thomas * and the packet associated with the descriptor (always use
4227eddba16SJilin Yuan * the XGBE_GET_DESC_DATA macro to access this data from the ring)
423c5aa9e3bSLendacky, Thomas */
424c5aa9e3bSLendacky, Thomas struct xgbe_ring_data {
425c5aa9e3bSLendacky, Thomas struct xgbe_ring_desc *rdesc; /* Virtual address of descriptor */
426c5aa9e3bSLendacky, Thomas dma_addr_t rdesc_dma; /* DMA address of descriptor */
427c5aa9e3bSLendacky, Thomas
428c5aa9e3bSLendacky, Thomas struct sk_buff *skb; /* Virtual address of SKB */
429c5aa9e3bSLendacky, Thomas dma_addr_t skb_dma; /* DMA address of SKB data */
430c5aa9e3bSLendacky, Thomas unsigned int skb_dma_len; /* Length of SKB DMA area */
431c5aa9e3bSLendacky, Thomas
432c9f140ebSLendacky, Thomas struct xgbe_tx_ring_data tx; /* Tx-related data */
433c9f140ebSLendacky, Thomas struct xgbe_rx_ring_data rx; /* Rx-related data */
434c5aa9e3bSLendacky, Thomas
435c5aa9e3bSLendacky, Thomas unsigned int mapped_as_page;
43623e4eef7SLendacky, Thomas
43723e4eef7SLendacky, Thomas /* Incomplete receive save location. If the budget is exhausted
43823e4eef7SLendacky, Thomas * or the last descriptor (last normal descriptor or a following
43923e4eef7SLendacky, Thomas * context descriptor) has not been DMA'd yet the current state
44023e4eef7SLendacky, Thomas * of the receive processing needs to be saved.
44123e4eef7SLendacky, Thomas */
44223e4eef7SLendacky, Thomas unsigned int state_saved;
44323e4eef7SLendacky, Thomas struct {
44423e4eef7SLendacky, Thomas struct sk_buff *skb;
44523e4eef7SLendacky, Thomas unsigned int len;
44623e4eef7SLendacky, Thomas unsigned int error;
44723e4eef7SLendacky, Thomas } state;
448c5aa9e3bSLendacky, Thomas };
449c5aa9e3bSLendacky, Thomas
450c5aa9e3bSLendacky, Thomas struct xgbe_ring {
451c5aa9e3bSLendacky, Thomas /* Ring lock - used just for TX rings at the moment */
452c5aa9e3bSLendacky, Thomas spinlock_t lock;
453c5aa9e3bSLendacky, Thomas
454c5aa9e3bSLendacky, Thomas /* Per packet related information */
455c5aa9e3bSLendacky, Thomas struct xgbe_packet_data packet_data;
456c5aa9e3bSLendacky, Thomas
457c5aa9e3bSLendacky, Thomas /* Virtual/DMA addresses and count of allocated descriptor memory */
458c5aa9e3bSLendacky, Thomas struct xgbe_ring_desc *rdesc;
459c5aa9e3bSLendacky, Thomas dma_addr_t rdesc_dma;
460c5aa9e3bSLendacky, Thomas unsigned int rdesc_count;
461c5aa9e3bSLendacky, Thomas
462c5aa9e3bSLendacky, Thomas /* Array of descriptor data corresponding the descriptor memory
463d0a8ba6cSLendacky, Thomas * (always use the XGBE_GET_DESC_DATA macro to access this data)
464c5aa9e3bSLendacky, Thomas */
465c5aa9e3bSLendacky, Thomas struct xgbe_ring_data *rdata;
466c5aa9e3bSLendacky, Thomas
46708dcc47cSLendacky, Thomas /* Page allocation for RX buffers */
468174fd259SLendacky, Thomas struct xgbe_page_alloc rx_hdr_pa;
469174fd259SLendacky, Thomas struct xgbe_page_alloc rx_buf_pa;
47018f9f0acSLendacky, Thomas int node;
47108dcc47cSLendacky, Thomas
472c5aa9e3bSLendacky, Thomas /* Ring index values
473c5aa9e3bSLendacky, Thomas * cur - Tx: index of descriptor to be used for current transfer
474c5aa9e3bSLendacky, Thomas * Rx: index of descriptor to check for packet availability
475c5aa9e3bSLendacky, Thomas * dirty - Tx: index of descriptor to check for transfer complete
476270894e7SLendacky, Thomas * Rx: index of descriptor to check for buffer reallocation
477c5aa9e3bSLendacky, Thomas */
478c5aa9e3bSLendacky, Thomas unsigned int cur;
479c5aa9e3bSLendacky, Thomas unsigned int dirty;
480c5aa9e3bSLendacky, Thomas
481c5aa9e3bSLendacky, Thomas /* Coalesce frame count used for interrupt bit setting */
482c5aa9e3bSLendacky, Thomas unsigned int coalesce_count;
483c5aa9e3bSLendacky, Thomas
484c5aa9e3bSLendacky, Thomas union {
485c5aa9e3bSLendacky, Thomas struct {
486c5aa9e3bSLendacky, Thomas unsigned int queue_stopped;
48716958a2bSLendacky, Thomas unsigned int xmit_more;
488c5aa9e3bSLendacky, Thomas unsigned short cur_mss;
489c5aa9e3bSLendacky, Thomas unsigned short cur_vlan_ctag;
490c5aa9e3bSLendacky, Thomas } tx;
491c5aa9e3bSLendacky, Thomas };
492c5aa9e3bSLendacky, Thomas } ____cacheline_aligned;
493c5aa9e3bSLendacky, Thomas
494c5aa9e3bSLendacky, Thomas /* Structure used to describe the descriptor rings associated with
495c5aa9e3bSLendacky, Thomas * a DMA channel.
496c5aa9e3bSLendacky, Thomas */
497c5aa9e3bSLendacky, Thomas struct xgbe_channel {
498c5aa9e3bSLendacky, Thomas char name[16];
499c5aa9e3bSLendacky, Thomas
500c5aa9e3bSLendacky, Thomas /* Address of private data area for device */
501c5aa9e3bSLendacky, Thomas struct xgbe_prv_data *pdata;
502c5aa9e3bSLendacky, Thomas
503c5aa9e3bSLendacky, Thomas /* Queue index and base address of queue's DMA registers */
504c5aa9e3bSLendacky, Thomas unsigned int queue_index;
505c5aa9e3bSLendacky, Thomas void __iomem *dma_regs;
506c5aa9e3bSLendacky, Thomas
5079227dc5eSLendacky, Thomas /* Per channel interrupt irq number */
5089227dc5eSLendacky, Thomas int dma_irq;
50954ceb9ecSLendacky, Thomas char dma_irq_name[IFNAMSIZ + 32];
5109227dc5eSLendacky, Thomas
5119227dc5eSLendacky, Thomas /* Netdev related settings */
5129227dc5eSLendacky, Thomas struct napi_struct napi;
5139227dc5eSLendacky, Thomas
514caa575afSLendacky, Thomas /* Per channel interrupt enablement tracker */
515caa575afSLendacky, Thomas unsigned int curr_ier;
516c5aa9e3bSLendacky, Thomas unsigned int saved_ier;
517c5aa9e3bSLendacky, Thomas
518c5aa9e3bSLendacky, Thomas unsigned int tx_timer_active;
519c635eaacSLendacky, Thomas struct timer_list tx_timer;
520c5aa9e3bSLendacky, Thomas
521c5aa9e3bSLendacky, Thomas struct xgbe_ring *tx_ring;
522c5aa9e3bSLendacky, Thomas struct xgbe_ring *rx_ring;
52318f9f0acSLendacky, Thomas
52418f9f0acSLendacky, Thomas int node;
525f00ba49dSLendacky, Thomas cpumask_t affinity_mask;
526c5aa9e3bSLendacky, Thomas } ____cacheline_aligned;
527c5aa9e3bSLendacky, Thomas
5287c12aa08SLendacky, Thomas enum xgbe_state {
5297c12aa08SLendacky, Thomas XGBE_DOWN,
5307c12aa08SLendacky, Thomas XGBE_LINK_INIT,
5317c12aa08SLendacky, Thomas XGBE_LINK_ERR,
532e78332b2SLendacky, Thomas XGBE_STOPPED,
5337c12aa08SLendacky, Thomas };
5347c12aa08SLendacky, Thomas
535c5aa9e3bSLendacky, Thomas enum xgbe_int {
536c5aa9e3bSLendacky, Thomas XGMAC_INT_DMA_CH_SR_TI,
537c5aa9e3bSLendacky, Thomas XGMAC_INT_DMA_CH_SR_TPS,
538c5aa9e3bSLendacky, Thomas XGMAC_INT_DMA_CH_SR_TBU,
539c5aa9e3bSLendacky, Thomas XGMAC_INT_DMA_CH_SR_RI,
540c5aa9e3bSLendacky, Thomas XGMAC_INT_DMA_CH_SR_RBU,
541c5aa9e3bSLendacky, Thomas XGMAC_INT_DMA_CH_SR_RPS,
5429867e8fbSLendacky, Thomas XGMAC_INT_DMA_CH_SR_TI_RI,
543c5aa9e3bSLendacky, Thomas XGMAC_INT_DMA_CH_SR_FBE,
544c5aa9e3bSLendacky, Thomas XGMAC_INT_DMA_ALL,
545c5aa9e3bSLendacky, Thomas };
546c5aa9e3bSLendacky, Thomas
547c5aa9e3bSLendacky, Thomas enum xgbe_int_state {
548c5aa9e3bSLendacky, Thomas XGMAC_INT_STATE_SAVE,
549c5aa9e3bSLendacky, Thomas XGMAC_INT_STATE_RESTORE,
550c5aa9e3bSLendacky, Thomas };
551c5aa9e3bSLendacky, Thomas
552e78332b2SLendacky, Thomas enum xgbe_ecc_sec {
553e78332b2SLendacky, Thomas XGBE_ECC_SEC_TX,
554e78332b2SLendacky, Thomas XGBE_ECC_SEC_RX,
555e78332b2SLendacky, Thomas XGBE_ECC_SEC_DESC,
556e78332b2SLendacky, Thomas };
557e78332b2SLendacky, Thomas
5587c12aa08SLendacky, Thomas enum xgbe_speed {
5597c12aa08SLendacky, Thomas XGBE_SPEED_1000 = 0,
5607c12aa08SLendacky, Thomas XGBE_SPEED_2500,
5617c12aa08SLendacky, Thomas XGBE_SPEED_10000,
5627c12aa08SLendacky, Thomas XGBE_SPEEDS,
5637c12aa08SLendacky, Thomas };
5647c12aa08SLendacky, Thomas
565b03a4a6fSLendacky, Thomas enum xgbe_xpcs_access {
566b03a4a6fSLendacky, Thomas XGBE_XPCS_ACCESS_V1 = 0,
567b03a4a6fSLendacky, Thomas XGBE_XPCS_ACCESS_V2,
568b03a4a6fSLendacky, Thomas };
569b03a4a6fSLendacky, Thomas
570a64def41SLendacky, Thomas enum xgbe_an_mode {
571a64def41SLendacky, Thomas XGBE_AN_MODE_CL73 = 0,
572d7445d1fSLendacky, Thomas XGBE_AN_MODE_CL73_REDRV,
5731bf40adaSLendacky, Thomas XGBE_AN_MODE_CL37,
5741bf40adaSLendacky, Thomas XGBE_AN_MODE_CL37_SGMII,
575a64def41SLendacky, Thomas XGBE_AN_MODE_NONE,
576a64def41SLendacky, Thomas };
577a64def41SLendacky, Thomas
5787c12aa08SLendacky, Thomas enum xgbe_an {
5797c12aa08SLendacky, Thomas XGBE_AN_READY = 0,
5807c12aa08SLendacky, Thomas XGBE_AN_PAGE_RECEIVED,
5817c12aa08SLendacky, Thomas XGBE_AN_INCOMPAT_LINK,
5827c12aa08SLendacky, Thomas XGBE_AN_COMPLETE,
5837c12aa08SLendacky, Thomas XGBE_AN_NO_LINK,
5847c12aa08SLendacky, Thomas XGBE_AN_ERROR,
5857c12aa08SLendacky, Thomas };
5867c12aa08SLendacky, Thomas
5877c12aa08SLendacky, Thomas enum xgbe_rx {
5887c12aa08SLendacky, Thomas XGBE_RX_BPA = 0,
5897c12aa08SLendacky, Thomas XGBE_RX_XNP,
5907c12aa08SLendacky, Thomas XGBE_RX_COMPLETE,
5917c12aa08SLendacky, Thomas XGBE_RX_ERROR,
5927c12aa08SLendacky, Thomas };
5937c12aa08SLendacky, Thomas
5947c12aa08SLendacky, Thomas enum xgbe_mode {
595e57f7a3fSLendacky, Thomas XGBE_MODE_KX_1000 = 0,
596e57f7a3fSLendacky, Thomas XGBE_MODE_KX_2500,
597e57f7a3fSLendacky, Thomas XGBE_MODE_KR,
598abf0a1c2SLendacky, Thomas XGBE_MODE_X,
59907445f3cSRaju Rangoju XGBE_MODE_SGMII_10,
600abf0a1c2SLendacky, Thomas XGBE_MODE_SGMII_100,
601abf0a1c2SLendacky, Thomas XGBE_MODE_SGMII_1000,
602abf0a1c2SLendacky, Thomas XGBE_MODE_SFI,
603e57f7a3fSLendacky, Thomas XGBE_MODE_UNKNOWN,
6047c12aa08SLendacky, Thomas };
6057c12aa08SLendacky, Thomas
6067c12aa08SLendacky, Thomas enum xgbe_speedset {
6077c12aa08SLendacky, Thomas XGBE_SPEEDSET_1000_10000 = 0,
6087c12aa08SLendacky, Thomas XGBE_SPEEDSET_2500_10000,
6097c12aa08SLendacky, Thomas };
6107c12aa08SLendacky, Thomas
611abf0a1c2SLendacky, Thomas enum xgbe_mdio_mode {
612abf0a1c2SLendacky, Thomas XGBE_MDIO_MODE_NONE = 0,
613abf0a1c2SLendacky, Thomas XGBE_MDIO_MODE_CL22,
614abf0a1c2SLendacky, Thomas XGBE_MDIO_MODE_CL45,
615abf0a1c2SLendacky, Thomas };
616abf0a1c2SLendacky, Thomas
6171246d086SRaju Rangoju enum xgbe_mb_cmd {
6181246d086SRaju Rangoju XGBE_MB_CMD_POWER_OFF = 0,
6191246d086SRaju Rangoju XGBE_MB_CMD_SET_1G,
6201246d086SRaju Rangoju XGBE_MB_CMD_SET_2_5G,
6211246d086SRaju Rangoju XGBE_MB_CMD_SET_10G_SFI,
6221246d086SRaju Rangoju XGBE_MB_CMD_SET_10G_KR,
6231246d086SRaju Rangoju XGBE_MB_CMD_RRC
6241246d086SRaju Rangoju };
6251246d086SRaju Rangoju
6261246d086SRaju Rangoju enum xgbe_mb_subcmd {
6271246d086SRaju Rangoju XGBE_MB_SUBCMD_NONE = 0,
628*4f3b20bfSRaju Rangoju XGBE_MB_SUBCMD_RX_ADAP,
6291246d086SRaju Rangoju
6301246d086SRaju Rangoju /* 10GbE SFP subcommands */
6311246d086SRaju Rangoju XGBE_MB_SUBCMD_ACTIVE = 0,
6321246d086SRaju Rangoju XGBE_MB_SUBCMD_PASSIVE_1M,
6331246d086SRaju Rangoju XGBE_MB_SUBCMD_PASSIVE_3M,
6341246d086SRaju Rangoju XGBE_MB_SUBCMD_PASSIVE_OTHER,
6351246d086SRaju Rangoju
6361246d086SRaju Rangoju /* 1GbE Mode subcommands */
6371246d086SRaju Rangoju XGBE_MB_SUBCMD_10MBITS = 0,
6381246d086SRaju Rangoju XGBE_MB_SUBCMD_100MBITS,
6391246d086SRaju Rangoju XGBE_MB_SUBCMD_1G_SGMII,
6401246d086SRaju Rangoju XGBE_MB_SUBCMD_1G_KX
6411246d086SRaju Rangoju };
6421246d086SRaju Rangoju
6437c12aa08SLendacky, Thomas struct xgbe_phy {
64485f9feb6SLendacky, Thomas struct ethtool_link_ksettings lks;
6457c12aa08SLendacky, Thomas
6467c12aa08SLendacky, Thomas int address;
6477c12aa08SLendacky, Thomas
6487c12aa08SLendacky, Thomas int autoneg;
6497c12aa08SLendacky, Thomas int speed;
6507c12aa08SLendacky, Thomas int duplex;
6517c12aa08SLendacky, Thomas
6527c12aa08SLendacky, Thomas int link;
653c1ce2f77SLendacky, Thomas
654c1ce2f77SLendacky, Thomas int pause_autoneg;
655c1ce2f77SLendacky, Thomas int tx_pause;
656c1ce2f77SLendacky, Thomas int rx_pause;
6577c12aa08SLendacky, Thomas };
6587c12aa08SLendacky, Thomas
6595ab1dcd5SLendacky, Thomas enum xgbe_i2c_cmd {
6605ab1dcd5SLendacky, Thomas XGBE_I2C_CMD_READ = 0,
6615ab1dcd5SLendacky, Thomas XGBE_I2C_CMD_WRITE,
6625ab1dcd5SLendacky, Thomas };
6635ab1dcd5SLendacky, Thomas
6645ab1dcd5SLendacky, Thomas struct xgbe_i2c_op {
6655ab1dcd5SLendacky, Thomas enum xgbe_i2c_cmd cmd;
6665ab1dcd5SLendacky, Thomas
6675ab1dcd5SLendacky, Thomas unsigned int target;
6685ab1dcd5SLendacky, Thomas
6695ab1dcd5SLendacky, Thomas void *buf;
6705ab1dcd5SLendacky, Thomas unsigned int len;
6715ab1dcd5SLendacky, Thomas };
6725ab1dcd5SLendacky, Thomas
6735ab1dcd5SLendacky, Thomas struct xgbe_i2c_op_state {
6745ab1dcd5SLendacky, Thomas struct xgbe_i2c_op *op;
6755ab1dcd5SLendacky, Thomas
6765ab1dcd5SLendacky, Thomas unsigned int tx_len;
6775ab1dcd5SLendacky, Thomas unsigned char *tx_buf;
6785ab1dcd5SLendacky, Thomas
6795ab1dcd5SLendacky, Thomas unsigned int rx_len;
6805ab1dcd5SLendacky, Thomas unsigned char *rx_buf;
6815ab1dcd5SLendacky, Thomas
6825ab1dcd5SLendacky, Thomas unsigned int tx_abort_source;
6835ab1dcd5SLendacky, Thomas
6845ab1dcd5SLendacky, Thomas int ret;
6855ab1dcd5SLendacky, Thomas };
6865ab1dcd5SLendacky, Thomas
6875ab1dcd5SLendacky, Thomas struct xgbe_i2c {
6885ab1dcd5SLendacky, Thomas unsigned int started;
6895ab1dcd5SLendacky, Thomas unsigned int max_speed_mode;
6905ab1dcd5SLendacky, Thomas unsigned int rx_fifo_size;
6915ab1dcd5SLendacky, Thomas unsigned int tx_fifo_size;
6925ab1dcd5SLendacky, Thomas
6935ab1dcd5SLendacky, Thomas struct xgbe_i2c_op_state op_state;
6945ab1dcd5SLendacky, Thomas };
6955ab1dcd5SLendacky, Thomas
696c5aa9e3bSLendacky, Thomas struct xgbe_mmc_stats {
697c5aa9e3bSLendacky, Thomas /* Tx Stats */
698c5aa9e3bSLendacky, Thomas u64 txoctetcount_gb;
699c5aa9e3bSLendacky, Thomas u64 txframecount_gb;
700c5aa9e3bSLendacky, Thomas u64 txbroadcastframes_g;
701c5aa9e3bSLendacky, Thomas u64 txmulticastframes_g;
702c5aa9e3bSLendacky, Thomas u64 tx64octets_gb;
703c5aa9e3bSLendacky, Thomas u64 tx65to127octets_gb;
704c5aa9e3bSLendacky, Thomas u64 tx128to255octets_gb;
705c5aa9e3bSLendacky, Thomas u64 tx256to511octets_gb;
706c5aa9e3bSLendacky, Thomas u64 tx512to1023octets_gb;
707c5aa9e3bSLendacky, Thomas u64 tx1024tomaxoctets_gb;
708c5aa9e3bSLendacky, Thomas u64 txunicastframes_gb;
709c5aa9e3bSLendacky, Thomas u64 txmulticastframes_gb;
710c5aa9e3bSLendacky, Thomas u64 txbroadcastframes_gb;
711c5aa9e3bSLendacky, Thomas u64 txunderflowerror;
712c5aa9e3bSLendacky, Thomas u64 txoctetcount_g;
713c5aa9e3bSLendacky, Thomas u64 txframecount_g;
714c5aa9e3bSLendacky, Thomas u64 txpauseframes;
715c5aa9e3bSLendacky, Thomas u64 txvlanframes_g;
716c5aa9e3bSLendacky, Thomas
717c5aa9e3bSLendacky, Thomas /* Rx Stats */
718c5aa9e3bSLendacky, Thomas u64 rxframecount_gb;
719c5aa9e3bSLendacky, Thomas u64 rxoctetcount_gb;
720c5aa9e3bSLendacky, Thomas u64 rxoctetcount_g;
721c5aa9e3bSLendacky, Thomas u64 rxbroadcastframes_g;
722c5aa9e3bSLendacky, Thomas u64 rxmulticastframes_g;
723c5aa9e3bSLendacky, Thomas u64 rxcrcerror;
724c5aa9e3bSLendacky, Thomas u64 rxrunterror;
725c5aa9e3bSLendacky, Thomas u64 rxjabbererror;
726c5aa9e3bSLendacky, Thomas u64 rxundersize_g;
727c5aa9e3bSLendacky, Thomas u64 rxoversize_g;
728c5aa9e3bSLendacky, Thomas u64 rx64octets_gb;
729c5aa9e3bSLendacky, Thomas u64 rx65to127octets_gb;
730c5aa9e3bSLendacky, Thomas u64 rx128to255octets_gb;
731c5aa9e3bSLendacky, Thomas u64 rx256to511octets_gb;
732c5aa9e3bSLendacky, Thomas u64 rx512to1023octets_gb;
733c5aa9e3bSLendacky, Thomas u64 rx1024tomaxoctets_gb;
734c5aa9e3bSLendacky, Thomas u64 rxunicastframes_g;
735c5aa9e3bSLendacky, Thomas u64 rxlengtherror;
736c5aa9e3bSLendacky, Thomas u64 rxoutofrangetype;
737c5aa9e3bSLendacky, Thomas u64 rxpauseframes;
738c5aa9e3bSLendacky, Thomas u64 rxfifooverflow;
739c5aa9e3bSLendacky, Thomas u64 rxvlanframes_gb;
740c5aa9e3bSLendacky, Thomas u64 rxwatchdogerror;
741c5aa9e3bSLendacky, Thomas };
742c5aa9e3bSLendacky, Thomas
7435452b2dfSLendacky, Thomas struct xgbe_ext_stats {
7445452b2dfSLendacky, Thomas u64 tx_tso_packets;
7455452b2dfSLendacky, Thomas u64 rx_split_header_packets;
74672c9ac4eSLendacky, Thomas u64 rx_buffer_unavailable;
74780a788c9SLendacky, Thomas
74880a788c9SLendacky, Thomas u64 txq_packets[XGBE_MAX_DMA_CHANNELS];
74980a788c9SLendacky, Thomas u64 txq_bytes[XGBE_MAX_DMA_CHANNELS];
75080a788c9SLendacky, Thomas u64 rxq_packets[XGBE_MAX_DMA_CHANNELS];
75180a788c9SLendacky, Thomas u64 rxq_bytes[XGBE_MAX_DMA_CHANNELS];
7523010608dSLendacky, Thomas
7533010608dSLendacky, Thomas u64 tx_vxlan_packets;
7543010608dSLendacky, Thomas u64 rx_vxlan_packets;
7553010608dSLendacky, Thomas u64 rx_csum_errors;
7563010608dSLendacky, Thomas u64 rx_vxlan_csum_errors;
7575452b2dfSLendacky, Thomas };
7585452b2dfSLendacky, Thomas
759c5aa9e3bSLendacky, Thomas struct xgbe_hw_if {
760c5aa9e3bSLendacky, Thomas int (*tx_complete)(struct xgbe_ring_desc *);
761c5aa9e3bSLendacky, Thomas
76276660757SJakub Kicinski int (*set_mac_address)(struct xgbe_prv_data *, const u8 *addr);
763b876382bSLendacky, Thomas int (*config_rx_mode)(struct xgbe_prv_data *);
764c5aa9e3bSLendacky, Thomas
765c5aa9e3bSLendacky, Thomas int (*enable_rx_csum)(struct xgbe_prv_data *);
766c5aa9e3bSLendacky, Thomas int (*disable_rx_csum)(struct xgbe_prv_data *);
767c5aa9e3bSLendacky, Thomas
768c5aa9e3bSLendacky, Thomas int (*enable_rx_vlan_stripping)(struct xgbe_prv_data *);
769c5aa9e3bSLendacky, Thomas int (*disable_rx_vlan_stripping)(struct xgbe_prv_data *);
770801c62d9SLendacky, Thomas int (*enable_rx_vlan_filtering)(struct xgbe_prv_data *);
771801c62d9SLendacky, Thomas int (*disable_rx_vlan_filtering)(struct xgbe_prv_data *);
772801c62d9SLendacky, Thomas int (*update_vlan_hash_table)(struct xgbe_prv_data *);
773c5aa9e3bSLendacky, Thomas
774c5aa9e3bSLendacky, Thomas int (*read_mmd_regs)(struct xgbe_prv_data *, int, int);
775c5aa9e3bSLendacky, Thomas void (*write_mmd_regs)(struct xgbe_prv_data *, int, int, int);
776e57f7a3fSLendacky, Thomas int (*set_speed)(struct xgbe_prv_data *, int);
777c5aa9e3bSLendacky, Thomas
778732f2ab7SLendacky, Thomas int (*set_ext_mii_mode)(struct xgbe_prv_data *, unsigned int,
779732f2ab7SLendacky, Thomas enum xgbe_mdio_mode);
780070f6186SAndrew Lunn int (*read_ext_mii_regs_c22)(struct xgbe_prv_data *, int, int);
781070f6186SAndrew Lunn int (*write_ext_mii_regs_c22)(struct xgbe_prv_data *, int, int, u16);
782070f6186SAndrew Lunn int (*read_ext_mii_regs_c45)(struct xgbe_prv_data *, int, int, int);
783070f6186SAndrew Lunn int (*write_ext_mii_regs_c45)(struct xgbe_prv_data *, int, int, int,
784070f6186SAndrew Lunn u16);
785732f2ab7SLendacky, Thomas
786732f2ab7SLendacky, Thomas int (*set_gpio)(struct xgbe_prv_data *, unsigned int);
787732f2ab7SLendacky, Thomas int (*clr_gpio)(struct xgbe_prv_data *, unsigned int);
788732f2ab7SLendacky, Thomas
789c5aa9e3bSLendacky, Thomas void (*enable_tx)(struct xgbe_prv_data *);
790c5aa9e3bSLendacky, Thomas void (*disable_tx)(struct xgbe_prv_data *);
791c5aa9e3bSLendacky, Thomas void (*enable_rx)(struct xgbe_prv_data *);
792c5aa9e3bSLendacky, Thomas void (*disable_rx)(struct xgbe_prv_data *);
793c5aa9e3bSLendacky, Thomas
794c5aa9e3bSLendacky, Thomas void (*powerup_tx)(struct xgbe_prv_data *);
795c5aa9e3bSLendacky, Thomas void (*powerdown_tx)(struct xgbe_prv_data *);
796c5aa9e3bSLendacky, Thomas void (*powerup_rx)(struct xgbe_prv_data *);
797c5aa9e3bSLendacky, Thomas void (*powerdown_rx)(struct xgbe_prv_data *);
798c5aa9e3bSLendacky, Thomas
799c5aa9e3bSLendacky, Thomas int (*init)(struct xgbe_prv_data *);
800c5aa9e3bSLendacky, Thomas int (*exit)(struct xgbe_prv_data *);
801c5aa9e3bSLendacky, Thomas
802c5aa9e3bSLendacky, Thomas int (*enable_int)(struct xgbe_channel *, enum xgbe_int);
803c5aa9e3bSLendacky, Thomas int (*disable_int)(struct xgbe_channel *, enum xgbe_int);
804a9d41981SLendacky, Thomas void (*dev_xmit)(struct xgbe_channel *);
805c5aa9e3bSLendacky, Thomas int (*dev_read)(struct xgbe_channel *);
806c5aa9e3bSLendacky, Thomas void (*tx_desc_init)(struct xgbe_channel *);
807c5aa9e3bSLendacky, Thomas void (*rx_desc_init)(struct xgbe_channel *);
808c5aa9e3bSLendacky, Thomas void (*tx_desc_reset)(struct xgbe_ring_data *);
8098dee19e6SLendacky, Thomas void (*rx_desc_reset)(struct xgbe_prv_data *, struct xgbe_ring_data *,
8108dee19e6SLendacky, Thomas unsigned int);
811c5aa9e3bSLendacky, Thomas int (*is_last_desc)(struct xgbe_ring_desc *);
812c5aa9e3bSLendacky, Thomas int (*is_context_desc)(struct xgbe_ring_desc *);
81316958a2bSLendacky, Thomas void (*tx_start_xmit)(struct xgbe_channel *, struct xgbe_ring *);
814c5aa9e3bSLendacky, Thomas
815c5aa9e3bSLendacky, Thomas /* For FLOW ctrl */
816c5aa9e3bSLendacky, Thomas int (*config_tx_flow_control)(struct xgbe_prv_data *);
817c5aa9e3bSLendacky, Thomas int (*config_rx_flow_control)(struct xgbe_prv_data *);
818c5aa9e3bSLendacky, Thomas
819c5aa9e3bSLendacky, Thomas /* For RX coalescing */
820c5aa9e3bSLendacky, Thomas int (*config_rx_coalesce)(struct xgbe_prv_data *);
821c5aa9e3bSLendacky, Thomas int (*config_tx_coalesce)(struct xgbe_prv_data *);
822c5aa9e3bSLendacky, Thomas unsigned int (*usec_to_riwt)(struct xgbe_prv_data *, unsigned int);
823c5aa9e3bSLendacky, Thomas unsigned int (*riwt_to_usec)(struct xgbe_prv_data *, unsigned int);
824c5aa9e3bSLendacky, Thomas
825c5aa9e3bSLendacky, Thomas /* For RX and TX threshold config */
826c5aa9e3bSLendacky, Thomas int (*config_rx_threshold)(struct xgbe_prv_data *, unsigned int);
827c5aa9e3bSLendacky, Thomas int (*config_tx_threshold)(struct xgbe_prv_data *, unsigned int);
828c5aa9e3bSLendacky, Thomas
829c5aa9e3bSLendacky, Thomas /* For RX and TX Store and Forward Mode config */
830c5aa9e3bSLendacky, Thomas int (*config_rsf_mode)(struct xgbe_prv_data *, unsigned int);
831c5aa9e3bSLendacky, Thomas int (*config_tsf_mode)(struct xgbe_prv_data *, unsigned int);
832c5aa9e3bSLendacky, Thomas
833c5aa9e3bSLendacky, Thomas /* For TX DMA Operate on Second Frame config */
834c5aa9e3bSLendacky, Thomas int (*config_osp_mode)(struct xgbe_prv_data *);
835c5aa9e3bSLendacky, Thomas
836c5aa9e3bSLendacky, Thomas /* For MMC statistics */
837c5aa9e3bSLendacky, Thomas void (*rx_mmc_int)(struct xgbe_prv_data *);
838c5aa9e3bSLendacky, Thomas void (*tx_mmc_int)(struct xgbe_prv_data *);
839c5aa9e3bSLendacky, Thomas void (*read_mmc_stats)(struct xgbe_prv_data *);
84023e4eef7SLendacky, Thomas
84123e4eef7SLendacky, Thomas /* For Timestamp config */
84223e4eef7SLendacky, Thomas int (*config_tstamp)(struct xgbe_prv_data *, unsigned int);
84323e4eef7SLendacky, Thomas void (*update_tstamp_addend)(struct xgbe_prv_data *, unsigned int);
84423e4eef7SLendacky, Thomas void (*set_tstamp_time)(struct xgbe_prv_data *, unsigned int sec,
84523e4eef7SLendacky, Thomas unsigned int nsec);
84623e4eef7SLendacky, Thomas u64 (*get_tstamp_time)(struct xgbe_prv_data *);
84723e4eef7SLendacky, Thomas u64 (*get_tx_tstamp)(struct xgbe_prv_data *);
848fca2d994SLendacky, Thomas
849fca2d994SLendacky, Thomas /* For Data Center Bridging config */
850b3b71597SLendacky, Thomas void (*config_tc)(struct xgbe_prv_data *);
851fca2d994SLendacky, Thomas void (*config_dcb_tc)(struct xgbe_prv_data *);
852fca2d994SLendacky, Thomas void (*config_dcb_pfc)(struct xgbe_prv_data *);
8535b9dfe29SLendacky, Thomas
8545b9dfe29SLendacky, Thomas /* For Receive Side Scaling */
8555b9dfe29SLendacky, Thomas int (*enable_rss)(struct xgbe_prv_data *);
8565b9dfe29SLendacky, Thomas int (*disable_rss)(struct xgbe_prv_data *);
857f6ac8628SLendacky, Thomas int (*set_rss_hash_key)(struct xgbe_prv_data *, const u8 *);
858f6ac8628SLendacky, Thomas int (*set_rss_lookup_table)(struct xgbe_prv_data *, const u32 *);
859e78332b2SLendacky, Thomas
860e78332b2SLendacky, Thomas /* For ECC */
861e78332b2SLendacky, Thomas void (*disable_ecc_ded)(struct xgbe_prv_data *);
862e78332b2SLendacky, Thomas void (*disable_ecc_sec)(struct xgbe_prv_data *, enum xgbe_ecc_sec);
8631a510ccfSLendacky, Thomas
8641a510ccfSLendacky, Thomas /* For VXLAN */
8651a510ccfSLendacky, Thomas void (*enable_vxlan)(struct xgbe_prv_data *);
8661a510ccfSLendacky, Thomas void (*disable_vxlan)(struct xgbe_prv_data *);
8671a510ccfSLendacky, Thomas void (*set_vxlan_id)(struct xgbe_prv_data *);
868c5aa9e3bSLendacky, Thomas };
869c5aa9e3bSLendacky, Thomas
870e57f7a3fSLendacky, Thomas /* This structure represents implementation specific routines for an
871e57f7a3fSLendacky, Thomas * implementation of a PHY. All routines are required unless noted below.
872e57f7a3fSLendacky, Thomas * Optional routines:
8734d945663STom Lendacky * an_pre, an_post
874e57f7a3fSLendacky, Thomas * kr_training_pre, kr_training_post
87553a1024aSTom Lendacky * module_info, module_eeprom
876e57f7a3fSLendacky, Thomas */
877e57f7a3fSLendacky, Thomas struct xgbe_phy_impl_if {
878e57f7a3fSLendacky, Thomas /* Perform Setup/teardown actions */
879e57f7a3fSLendacky, Thomas int (*init)(struct xgbe_prv_data *);
880e57f7a3fSLendacky, Thomas void (*exit)(struct xgbe_prv_data *);
881e57f7a3fSLendacky, Thomas
882e57f7a3fSLendacky, Thomas /* Perform start/stop specific actions */
883e57f7a3fSLendacky, Thomas int (*reset)(struct xgbe_prv_data *);
884e57f7a3fSLendacky, Thomas int (*start)(struct xgbe_prv_data *);
885e57f7a3fSLendacky, Thomas void (*stop)(struct xgbe_prv_data *);
886e57f7a3fSLendacky, Thomas
887e57f7a3fSLendacky, Thomas /* Return the link status */
888abf0a1c2SLendacky, Thomas int (*link_status)(struct xgbe_prv_data *, int *);
889e57f7a3fSLendacky, Thomas
890e57f7a3fSLendacky, Thomas /* Indicate if a particular speed is valid */
891e57f7a3fSLendacky, Thomas bool (*valid_speed)(struct xgbe_prv_data *, int);
892e57f7a3fSLendacky, Thomas
893e57f7a3fSLendacky, Thomas /* Check if the specified mode can/should be used */
894e57f7a3fSLendacky, Thomas bool (*use_mode)(struct xgbe_prv_data *, enum xgbe_mode);
895e57f7a3fSLendacky, Thomas /* Switch the PHY into various modes */
896e57f7a3fSLendacky, Thomas void (*set_mode)(struct xgbe_prv_data *, enum xgbe_mode);
897e57f7a3fSLendacky, Thomas /* Retrieve mode needed for a specific speed */
898e57f7a3fSLendacky, Thomas enum xgbe_mode (*get_mode)(struct xgbe_prv_data *, int);
899e57f7a3fSLendacky, Thomas /* Retrieve new/next mode when trying to auto-negotiate */
900e57f7a3fSLendacky, Thomas enum xgbe_mode (*switch_mode)(struct xgbe_prv_data *);
901e57f7a3fSLendacky, Thomas /* Retrieve current mode */
902e57f7a3fSLendacky, Thomas enum xgbe_mode (*cur_mode)(struct xgbe_prv_data *);
903e57f7a3fSLendacky, Thomas
904a64def41SLendacky, Thomas /* Retrieve current auto-negotiation mode */
905a64def41SLendacky, Thomas enum xgbe_an_mode (*an_mode)(struct xgbe_prv_data *);
906a64def41SLendacky, Thomas
907abf0a1c2SLendacky, Thomas /* Configure auto-negotiation settings */
908abf0a1c2SLendacky, Thomas int (*an_config)(struct xgbe_prv_data *);
909abf0a1c2SLendacky, Thomas
910d7445d1fSLendacky, Thomas /* Set/override auto-negotiation advertisement settings */
91185f9feb6SLendacky, Thomas void (*an_advertising)(struct xgbe_prv_data *,
91285f9feb6SLendacky, Thomas struct ethtool_link_ksettings *);
913d7445d1fSLendacky, Thomas
914e57f7a3fSLendacky, Thomas /* Process results of auto-negotiation */
915e57f7a3fSLendacky, Thomas enum xgbe_mode (*an_outcome)(struct xgbe_prv_data *);
916e57f7a3fSLendacky, Thomas
9174d945663STom Lendacky /* Pre/Post auto-negotiation support */
9184d945663STom Lendacky void (*an_pre)(struct xgbe_prv_data *);
9194d945663STom Lendacky void (*an_post)(struct xgbe_prv_data *);
9204d945663STom Lendacky
921e57f7a3fSLendacky, Thomas /* Pre/Post KR training enablement support */
922e57f7a3fSLendacky, Thomas void (*kr_training_pre)(struct xgbe_prv_data *);
923e57f7a3fSLendacky, Thomas void (*kr_training_post)(struct xgbe_prv_data *);
92453a1024aSTom Lendacky
92553a1024aSTom Lendacky /* SFP module related info */
92653a1024aSTom Lendacky int (*module_info)(struct xgbe_prv_data *pdata,
92753a1024aSTom Lendacky struct ethtool_modinfo *modinfo);
92853a1024aSTom Lendacky int (*module_eeprom)(struct xgbe_prv_data *pdata,
92953a1024aSTom Lendacky struct ethtool_eeprom *eeprom, u8 *data);
930e57f7a3fSLendacky, Thomas };
931e57f7a3fSLendacky, Thomas
9327c12aa08SLendacky, Thomas struct xgbe_phy_if {
933e57f7a3fSLendacky, Thomas /* For PHY setup/teardown */
934e57f7a3fSLendacky, Thomas int (*phy_init)(struct xgbe_prv_data *);
935e57f7a3fSLendacky, Thomas void (*phy_exit)(struct xgbe_prv_data *);
9367c12aa08SLendacky, Thomas
9377c12aa08SLendacky, Thomas /* For PHY support when setting device up/down */
9387c12aa08SLendacky, Thomas int (*phy_reset)(struct xgbe_prv_data *);
9397c12aa08SLendacky, Thomas int (*phy_start)(struct xgbe_prv_data *);
9407c12aa08SLendacky, Thomas void (*phy_stop)(struct xgbe_prv_data *);
9417c12aa08SLendacky, Thomas
9427c12aa08SLendacky, Thomas /* For PHY support while device is up */
9437c12aa08SLendacky, Thomas void (*phy_status)(struct xgbe_prv_data *);
9447c12aa08SLendacky, Thomas int (*phy_config_aneg)(struct xgbe_prv_data *);
945e57f7a3fSLendacky, Thomas
946e57f7a3fSLendacky, Thomas /* For PHY settings validation */
947e57f7a3fSLendacky, Thomas bool (*phy_valid_speed)(struct xgbe_prv_data *, int);
948e57f7a3fSLendacky, Thomas
94947f164deSLendacky, Thomas /* For single interrupt support */
95085b85c85SLendacky, Thomas irqreturn_t (*an_isr)(struct xgbe_prv_data *);
95147f164deSLendacky, Thomas
95253a1024aSTom Lendacky /* For ethtool PHY support */
95353a1024aSTom Lendacky int (*module_info)(struct xgbe_prv_data *pdata,
95453a1024aSTom Lendacky struct ethtool_modinfo *modinfo);
95553a1024aSTom Lendacky int (*module_eeprom)(struct xgbe_prv_data *pdata,
95653a1024aSTom Lendacky struct ethtool_eeprom *eeprom, u8 *data);
95753a1024aSTom Lendacky
958e57f7a3fSLendacky, Thomas /* PHY implementation specific services */
959e57f7a3fSLendacky, Thomas struct xgbe_phy_impl_if phy_impl;
9607c12aa08SLendacky, Thomas };
9617c12aa08SLendacky, Thomas
9625ab1dcd5SLendacky, Thomas struct xgbe_i2c_if {
9635ab1dcd5SLendacky, Thomas /* For initial I2C setup */
9645ab1dcd5SLendacky, Thomas int (*i2c_init)(struct xgbe_prv_data *);
9655ab1dcd5SLendacky, Thomas
9665ab1dcd5SLendacky, Thomas /* For I2C support when setting device up/down */
9675ab1dcd5SLendacky, Thomas int (*i2c_start)(struct xgbe_prv_data *);
9685ab1dcd5SLendacky, Thomas void (*i2c_stop)(struct xgbe_prv_data *);
9695ab1dcd5SLendacky, Thomas
9705ab1dcd5SLendacky, Thomas /* For performing I2C operations */
9715ab1dcd5SLendacky, Thomas int (*i2c_xfer)(struct xgbe_prv_data *, struct xgbe_i2c_op *);
9725ab1dcd5SLendacky, Thomas
9735ab1dcd5SLendacky, Thomas /* For single interrupt support */
97485b85c85SLendacky, Thomas irqreturn_t (*i2c_isr)(struct xgbe_prv_data *);
9755ab1dcd5SLendacky, Thomas };
9765ab1dcd5SLendacky, Thomas
977c5aa9e3bSLendacky, Thomas struct xgbe_desc_if {
978c5aa9e3bSLendacky, Thomas int (*alloc_ring_resources)(struct xgbe_prv_data *);
979c5aa9e3bSLendacky, Thomas void (*free_ring_resources)(struct xgbe_prv_data *);
980c5aa9e3bSLendacky, Thomas int (*map_tx_skb)(struct xgbe_channel *, struct sk_buff *);
981270894e7SLendacky, Thomas int (*map_rx_buffer)(struct xgbe_prv_data *, struct xgbe_ring *,
982270894e7SLendacky, Thomas struct xgbe_ring_data *);
98308dcc47cSLendacky, Thomas void (*unmap_rdata)(struct xgbe_prv_data *, struct xgbe_ring_data *);
984c5aa9e3bSLendacky, Thomas void (*wrapper_tx_desc_init)(struct xgbe_prv_data *);
985c5aa9e3bSLendacky, Thomas void (*wrapper_rx_desc_init)(struct xgbe_prv_data *);
986c5aa9e3bSLendacky, Thomas };
987c5aa9e3bSLendacky, Thomas
988c5aa9e3bSLendacky, Thomas /* This structure contains flags that indicate what hardware features
989c5aa9e3bSLendacky, Thomas * or configurations are present in the device.
990c5aa9e3bSLendacky, Thomas */
991c5aa9e3bSLendacky, Thomas struct xgbe_hw_features {
992a9a4a2d9SLendacky, Thomas /* HW Version */
993a9a4a2d9SLendacky, Thomas unsigned int version;
994a9a4a2d9SLendacky, Thomas
995c5aa9e3bSLendacky, Thomas /* HW Feature Register0 */
996c5aa9e3bSLendacky, Thomas unsigned int gmii; /* 1000 Mbps support */
997c5aa9e3bSLendacky, Thomas unsigned int vlhash; /* VLAN Hash Filter */
998c5aa9e3bSLendacky, Thomas unsigned int sma; /* SMA(MDIO) Interface */
999c5aa9e3bSLendacky, Thomas unsigned int rwk; /* PMT remote wake-up packet */
1000c5aa9e3bSLendacky, Thomas unsigned int mgk; /* PMT magic packet */
1001c5aa9e3bSLendacky, Thomas unsigned int mmc; /* RMON module */
1002c5aa9e3bSLendacky, Thomas unsigned int aoe; /* ARP Offload */
1003dbedd44eSJoe Perches unsigned int ts; /* IEEE 1588-2008 Advanced Timestamp */
1004c5aa9e3bSLendacky, Thomas unsigned int eee; /* Energy Efficient Ethernet */
1005c5aa9e3bSLendacky, Thomas unsigned int tx_coe; /* Tx Checksum Offload */
1006c5aa9e3bSLendacky, Thomas unsigned int rx_coe; /* Rx Checksum Offload */
1007c5aa9e3bSLendacky, Thomas unsigned int addn_mac; /* Additional MAC Addresses */
1008c5aa9e3bSLendacky, Thomas unsigned int ts_src; /* Timestamp Source */
1009c5aa9e3bSLendacky, Thomas unsigned int sa_vlan_ins; /* Source Address or VLAN Insertion */
10101a510ccfSLendacky, Thomas unsigned int vxn; /* VXLAN/NVGRE */
1011c5aa9e3bSLendacky, Thomas
1012c5aa9e3bSLendacky, Thomas /* HW Feature Register1 */
1013c5aa9e3bSLendacky, Thomas unsigned int rx_fifo_size; /* MTL Receive FIFO Size */
1014c5aa9e3bSLendacky, Thomas unsigned int tx_fifo_size; /* MTL Transmit FIFO Size */
1015c5aa9e3bSLendacky, Thomas unsigned int adv_ts_hi; /* Advance Timestamping High Word */
1016386d325dSLendacky, Thomas unsigned int dma_width; /* DMA width */
1017c5aa9e3bSLendacky, Thomas unsigned int dcb; /* DCB Feature */
1018c5aa9e3bSLendacky, Thomas unsigned int sph; /* Split Header Feature */
1019c5aa9e3bSLendacky, Thomas unsigned int tso; /* TCP Segmentation Offload */
1020c5aa9e3bSLendacky, Thomas unsigned int dma_debug; /* DMA Debug Registers */
1021c5aa9e3bSLendacky, Thomas unsigned int rss; /* Receive Side Scaling */
1022fca2d994SLendacky, Thomas unsigned int tc_cnt; /* Number of Traffic Classes */
1023c5aa9e3bSLendacky, Thomas unsigned int hash_table_size; /* Hash Table Size */
1024c5aa9e3bSLendacky, Thomas unsigned int l3l4_filter_num; /* Number of L3-L4 Filters */
1025c5aa9e3bSLendacky, Thomas
1026c5aa9e3bSLendacky, Thomas /* HW Feature Register2 */
1027c5aa9e3bSLendacky, Thomas unsigned int rx_q_cnt; /* Number of MTL Receive Queues */
1028c5aa9e3bSLendacky, Thomas unsigned int tx_q_cnt; /* Number of MTL Transmit Queues */
1029c5aa9e3bSLendacky, Thomas unsigned int rx_ch_cnt; /* Number of DMA Receive Channels */
1030c5aa9e3bSLendacky, Thomas unsigned int tx_ch_cnt; /* Number of DMA Transmit Channels */
1031c5aa9e3bSLendacky, Thomas unsigned int pps_out_num; /* Number of PPS outputs */
1032c5aa9e3bSLendacky, Thomas unsigned int aux_snap_num; /* Number of Aux snapshot inputs */
1033c5aa9e3bSLendacky, Thomas };
1034c5aa9e3bSLendacky, Thomas
1035e57f7a3fSLendacky, Thomas struct xgbe_version_data {
1036e57f7a3fSLendacky, Thomas void (*init_function_ptrs_phy_impl)(struct xgbe_phy_if *);
1037b03a4a6fSLendacky, Thomas enum xgbe_xpcs_access xpcs_access;
1038e5a20b90SLendacky, Thomas unsigned int mmc_64bit;
1039bd8255d8SLendacky, Thomas unsigned int tx_max_fifo_size;
1040bd8255d8SLendacky, Thomas unsigned int rx_max_fifo_size;
1041aba9777aSLendacky, Thomas unsigned int tx_tstamp_workaround;
1042e78332b2SLendacky, Thomas unsigned int ecc_support;
10435ab1dcd5SLendacky, Thomas unsigned int i2c_support;
104485b85c85SLendacky, Thomas unsigned int irq_reissue_support;
10456f595959SLendacky, Thomas unsigned int tx_desc_prefetch;
10466f595959SLendacky, Thomas unsigned int rx_desc_prefetch;
104796f4d430STom Lendacky unsigned int an_cdr_workaround;
1048f97fc7efSRaju Rangoju unsigned int enable_rrc;
1049e57f7a3fSLendacky, Thomas };
1050e57f7a3fSLendacky, Thomas
1051c5aa9e3bSLendacky, Thomas struct xgbe_prv_data {
1052c5aa9e3bSLendacky, Thomas struct net_device *netdev;
105347f164deSLendacky, Thomas struct pci_dev *pcidev;
1054bd8255d8SLendacky, Thomas struct platform_device *platdev;
105582a19035SLendacky, Thomas struct acpi_device *adev;
1056c5aa9e3bSLendacky, Thomas struct device *dev;
1057bd8255d8SLendacky, Thomas struct platform_device *phy_platdev;
1058e57f7a3fSLendacky, Thomas struct device *phy_dev;
1059e57f7a3fSLendacky, Thomas
1060e57f7a3fSLendacky, Thomas /* Version related data */
1061e57f7a3fSLendacky, Thomas struct xgbe_version_data *vdata;
1062c5aa9e3bSLendacky, Thomas
106382a19035SLendacky, Thomas /* ACPI or DT flag */
106482a19035SLendacky, Thomas unsigned int use_acpi;
106582a19035SLendacky, Thomas
1066c5aa9e3bSLendacky, Thomas /* XGMAC/XPCS related mmio registers */
1067c5aa9e3bSLendacky, Thomas void __iomem *xgmac_regs; /* XGMAC CSRs */
1068c5aa9e3bSLendacky, Thomas void __iomem *xpcs_regs; /* XPCS MMD registers */
10697c12aa08SLendacky, Thomas void __iomem *rxtx_regs; /* SerDes Rx/Tx CSRs */
10707c12aa08SLendacky, Thomas void __iomem *sir0_regs; /* SerDes integration registers (1/2) */
10717c12aa08SLendacky, Thomas void __iomem *sir1_regs; /* SerDes integration registers (2/2) */
107247f164deSLendacky, Thomas void __iomem *xprop_regs; /* XGBE property registers */
107347f164deSLendacky, Thomas void __iomem *xi2c_regs; /* XGBE I2C CSRs */
1074c5aa9e3bSLendacky, Thomas
1075b93c3ab6STom Lendacky /* Port property registers */
1076b93c3ab6STom Lendacky unsigned int pp0;
1077b93c3ab6STom Lendacky unsigned int pp1;
1078b93c3ab6STom Lendacky unsigned int pp2;
1079b93c3ab6STom Lendacky unsigned int pp3;
1080b93c3ab6STom Lendacky unsigned int pp4;
1081b93c3ab6STom Lendacky
1082c5aa9e3bSLendacky, Thomas /* Overall device lock */
1083c5aa9e3bSLendacky, Thomas spinlock_t lock;
1084c5aa9e3bSLendacky, Thomas
1085ced3fcaeSLendacky, Thomas /* XPCS indirect addressing lock */
1086ced3fcaeSLendacky, Thomas spinlock_t xpcs_lock;
10874eccbfc3SLendacky, Thomas unsigned int xpcs_window_def_reg;
10884eccbfc3SLendacky, Thomas unsigned int xpcs_window_sel_reg;
1089b03a4a6fSLendacky, Thomas unsigned int xpcs_window;
1090b03a4a6fSLendacky, Thomas unsigned int xpcs_window_size;
1091b03a4a6fSLendacky, Thomas unsigned int xpcs_window_mask;
1092c5aa9e3bSLendacky, Thomas
10935b9dfe29SLendacky, Thomas /* RSS addressing mutex */
10945b9dfe29SLendacky, Thomas struct mutex rss_mutex;
10955b9dfe29SLendacky, Thomas
10967c12aa08SLendacky, Thomas /* Flags representing xgbe_state */
10977c12aa08SLendacky, Thomas unsigned long dev_state;
10987c12aa08SLendacky, Thomas
1099e78332b2SLendacky, Thomas /* ECC support */
1100e78332b2SLendacky, Thomas unsigned long tx_sec_period;
1101e78332b2SLendacky, Thomas unsigned long tx_ded_period;
1102e78332b2SLendacky, Thomas unsigned long rx_sec_period;
1103e78332b2SLendacky, Thomas unsigned long rx_ded_period;
1104e78332b2SLendacky, Thomas unsigned long desc_sec_period;
1105e78332b2SLendacky, Thomas unsigned long desc_ded_period;
1106e78332b2SLendacky, Thomas
1107e78332b2SLendacky, Thomas unsigned int tx_sec_count;
1108e78332b2SLendacky, Thomas unsigned int tx_ded_count;
1109e78332b2SLendacky, Thomas unsigned int rx_sec_count;
1110e78332b2SLendacky, Thomas unsigned int rx_ded_count;
1111e78332b2SLendacky, Thomas unsigned int desc_ded_count;
1112e78332b2SLendacky, Thomas unsigned int desc_sec_count;
1113e78332b2SLendacky, Thomas
11149227dc5eSLendacky, Thomas int dev_irq;
111547f164deSLendacky, Thomas int ecc_irq;
111647f164deSLendacky, Thomas int i2c_irq;
1117bd8255d8SLendacky, Thomas int channel_irq[XGBE_MAX_DMA_CHANNELS];
1118c5aa9e3bSLendacky, Thomas
111947f164deSLendacky, Thomas unsigned int per_channel_irq;
112047f164deSLendacky, Thomas unsigned int irq_count;
112147f164deSLendacky, Thomas unsigned int channel_irq_count;
11224c70dd8aSLendacky, Thomas unsigned int channel_irq_mode;
112347f164deSLendacky, Thomas
1124e78332b2SLendacky, Thomas char ecc_name[IFNAMSIZ + 32];
1125e78332b2SLendacky, Thomas
1126c5aa9e3bSLendacky, Thomas struct xgbe_hw_if hw_if;
11277c12aa08SLendacky, Thomas struct xgbe_phy_if phy_if;
1128c5aa9e3bSLendacky, Thomas struct xgbe_desc_if desc_if;
11295ab1dcd5SLendacky, Thomas struct xgbe_i2c_if i2c_if;
1130c5aa9e3bSLendacky, Thomas
1131cfa50c78SLendacky, Thomas /* AXI DMA settings */
113282a19035SLendacky, Thomas unsigned int coherent;
11339916716aSLendacky, Thomas unsigned int arcr;
11349916716aSLendacky, Thomas unsigned int awcr;
11356f595959SLendacky, Thomas unsigned int awarcr;
1136cfa50c78SLendacky, Thomas
11377c12aa08SLendacky, Thomas /* Service routine support */
11387c12aa08SLendacky, Thomas struct workqueue_struct *dev_workqueue;
11397c12aa08SLendacky, Thomas struct work_struct service_work;
11407c12aa08SLendacky, Thomas struct timer_list service_timer;
11417c12aa08SLendacky, Thomas
1142c5aa9e3bSLendacky, Thomas /* Rings for Tx/Rx on a DMA channel */
114318f9f0acSLendacky, Thomas struct xgbe_channel *channel[XGBE_MAX_DMA_CHANNELS];
1144bd8255d8SLendacky, Thomas unsigned int tx_max_channel_count;
1145bd8255d8SLendacky, Thomas unsigned int rx_max_channel_count;
1146c5aa9e3bSLendacky, Thomas unsigned int channel_count;
1147c5aa9e3bSLendacky, Thomas unsigned int tx_ring_count;
1148c5aa9e3bSLendacky, Thomas unsigned int tx_desc_count;
1149c5aa9e3bSLendacky, Thomas unsigned int rx_ring_count;
1150c5aa9e3bSLendacky, Thomas unsigned int rx_desc_count;
1151c5aa9e3bSLendacky, Thomas
115201b5277fSTom Lendacky unsigned int new_tx_ring_count;
115301b5277fSTom Lendacky unsigned int new_rx_ring_count;
115401b5277fSTom Lendacky
1155bd8255d8SLendacky, Thomas unsigned int tx_max_q_count;
1156bd8255d8SLendacky, Thomas unsigned int rx_max_q_count;
1157853eb16bSLendacky, Thomas unsigned int tx_q_count;
1158853eb16bSLendacky, Thomas unsigned int rx_q_count;
1159853eb16bSLendacky, Thomas
1160c5aa9e3bSLendacky, Thomas /* Tx/Rx common settings */
11617e1e6b86SLendacky, Thomas unsigned int blen;
11627e1e6b86SLendacky, Thomas unsigned int pbl;
11636f595959SLendacky, Thomas unsigned int aal;
11646f595959SLendacky, Thomas unsigned int rd_osr_limit;
11656f595959SLendacky, Thomas unsigned int wr_osr_limit;
1166c5aa9e3bSLendacky, Thomas
1167c5aa9e3bSLendacky, Thomas /* Tx settings */
1168c5aa9e3bSLendacky, Thomas unsigned int tx_sf_mode;
1169c5aa9e3bSLendacky, Thomas unsigned int tx_threshold;
1170c5aa9e3bSLendacky, Thomas unsigned int tx_osp_mode;
1171bd8255d8SLendacky, Thomas unsigned int tx_max_fifo_size;
1172c5aa9e3bSLendacky, Thomas
1173c5aa9e3bSLendacky, Thomas /* Rx settings */
1174c5aa9e3bSLendacky, Thomas unsigned int rx_sf_mode;
1175c5aa9e3bSLendacky, Thomas unsigned int rx_threshold;
1176bd8255d8SLendacky, Thomas unsigned int rx_max_fifo_size;
1177c5aa9e3bSLendacky, Thomas
1178c5aa9e3bSLendacky, Thomas /* Tx coalescing settings */
1179c5aa9e3bSLendacky, Thomas unsigned int tx_usecs;
1180c5aa9e3bSLendacky, Thomas unsigned int tx_frames;
1181c5aa9e3bSLendacky, Thomas
1182c5aa9e3bSLendacky, Thomas /* Rx coalescing settings */
1183c5aa9e3bSLendacky, Thomas unsigned int rx_riwt;
11844a57ebccSLendacky, Thomas unsigned int rx_usecs;
1185c5aa9e3bSLendacky, Thomas unsigned int rx_frames;
1186c5aa9e3bSLendacky, Thomas
118708dcc47cSLendacky, Thomas /* Current Rx buffer size */
1188c5aa9e3bSLendacky, Thomas unsigned int rx_buf_size;
1189c5aa9e3bSLendacky, Thomas
1190c5aa9e3bSLendacky, Thomas /* Flow control settings */
1191c5aa9e3bSLendacky, Thomas unsigned int pause_autoneg;
1192c5aa9e3bSLendacky, Thomas unsigned int tx_pause;
1193c5aa9e3bSLendacky, Thomas unsigned int rx_pause;
119443e0dcf7SLendacky, Thomas unsigned int rx_rfa[XGBE_MAX_QUEUES];
119543e0dcf7SLendacky, Thomas unsigned int rx_rfd[XGBE_MAX_QUEUES];
1196c5aa9e3bSLendacky, Thomas
11975b9dfe29SLendacky, Thomas /* Receive Side Scaling settings */
11985b9dfe29SLendacky, Thomas u8 rss_key[XGBE_RSS_HASH_KEY_SIZE];
11995b9dfe29SLendacky, Thomas u32 rss_table[XGBE_RSS_MAX_TABLE_SIZE];
12005b9dfe29SLendacky, Thomas u32 rss_options;
12015b9dfe29SLendacky, Thomas
12021a510ccfSLendacky, Thomas /* VXLAN settings */
12031a510ccfSLendacky, Thomas u16 vxlan_port;
12041a510ccfSLendacky, Thomas
1205c5aa9e3bSLendacky, Thomas /* Netdev related settings */
120682a19035SLendacky, Thomas unsigned char mac_addr[ETH_ALEN];
1207c5aa9e3bSLendacky, Thomas netdev_features_t netdev_features;
1208c5aa9e3bSLendacky, Thomas struct napi_struct napi;
1209c5aa9e3bSLendacky, Thomas struct xgbe_mmc_stats mmc_stats;
12105452b2dfSLendacky, Thomas struct xgbe_ext_stats ext_stats;
1211c5aa9e3bSLendacky, Thomas
1212801c62d9SLendacky, Thomas /* Filtering support */
1213801c62d9SLendacky, Thomas unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
1214801c62d9SLendacky, Thomas
121523e4eef7SLendacky, Thomas /* Device clocks */
121623e4eef7SLendacky, Thomas struct clk *sysclk;
121782a19035SLendacky, Thomas unsigned long sysclk_rate;
121823e4eef7SLendacky, Thomas struct clk *ptpclk;
121982a19035SLendacky, Thomas unsigned long ptpclk_rate;
122023e4eef7SLendacky, Thomas
122123e4eef7SLendacky, Thomas /* Timestamp support */
122223e4eef7SLendacky, Thomas spinlock_t tstamp_lock;
122323e4eef7SLendacky, Thomas struct ptp_clock_info ptp_clock_info;
122423e4eef7SLendacky, Thomas struct ptp_clock *ptp_clock;
122523e4eef7SLendacky, Thomas struct hwtstamp_config tstamp_config;
122623e4eef7SLendacky, Thomas struct cyclecounter tstamp_cc;
122723e4eef7SLendacky, Thomas struct timecounter tstamp_tc;
122823e4eef7SLendacky, Thomas unsigned int tstamp_addend;
122923e4eef7SLendacky, Thomas struct work_struct tx_tstamp_work;
123023e4eef7SLendacky, Thomas struct sk_buff *tx_tstamp_skb;
123123e4eef7SLendacky, Thomas u64 tx_tstamp;
1232c5aa9e3bSLendacky, Thomas
1233fca2d994SLendacky, Thomas /* DCB support */
1234fca2d994SLendacky, Thomas struct ieee_ets *ets;
1235fca2d994SLendacky, Thomas struct ieee_pfc *pfc;
1236fca2d994SLendacky, Thomas unsigned int q2tc_map[XGBE_MAX_QUEUES];
1237fca2d994SLendacky, Thomas unsigned int prio2q_map[IEEE_8021QAZ_MAX_TCS];
123843e0dcf7SLendacky, Thomas unsigned int pfcq[XGBE_MAX_QUEUES];
123943e0dcf7SLendacky, Thomas unsigned int pfc_rfa;
1240b3b71597SLendacky, Thomas u8 num_tcs;
1241fca2d994SLendacky, Thomas
1242c5aa9e3bSLendacky, Thomas /* Hardware features of the device */
1243c5aa9e3bSLendacky, Thomas struct xgbe_hw_features hw_feat;
1244c5aa9e3bSLendacky, Thomas
1245e78332b2SLendacky, Thomas /* Device work structures */
1246c5aa9e3bSLendacky, Thomas struct work_struct restart_work;
1247e78332b2SLendacky, Thomas struct work_struct stopdev_work;
1248c5aa9e3bSLendacky, Thomas
1249c5aa9e3bSLendacky, Thomas /* Keeps track of power mode */
1250c5aa9e3bSLendacky, Thomas unsigned int power_down;
1251c5aa9e3bSLendacky, Thomas
125234bf65dfSLendacky, Thomas /* Network interface message level setting */
125334bf65dfSLendacky, Thomas u32 msg_enable;
125434bf65dfSLendacky, Thomas
12557c12aa08SLendacky, Thomas /* Current PHY settings */
12567c12aa08SLendacky, Thomas phy_interface_t phy_mode;
12577c12aa08SLendacky, Thomas int phy_link;
12587c12aa08SLendacky, Thomas int phy_speed;
12597c12aa08SLendacky, Thomas
12607c12aa08SLendacky, Thomas /* MDIO/PHY related settings */
1261e57f7a3fSLendacky, Thomas unsigned int phy_started;
1262e57f7a3fSLendacky, Thomas void *phy_data;
12637c12aa08SLendacky, Thomas struct xgbe_phy phy;
12647c12aa08SLendacky, Thomas int mdio_mmd;
12657c12aa08SLendacky, Thomas unsigned long link_check;
1266732f2ab7SLendacky, Thomas struct completion mdio_complete;
12677c12aa08SLendacky, Thomas
1268d7445d1fSLendacky, Thomas unsigned int kr_redrv;
1269d7445d1fSLendacky, Thomas
12707c12aa08SLendacky, Thomas char an_name[IFNAMSIZ + 32];
12717c12aa08SLendacky, Thomas struct workqueue_struct *an_workqueue;
12727c12aa08SLendacky, Thomas
12737c12aa08SLendacky, Thomas int an_irq;
12747c12aa08SLendacky, Thomas struct work_struct an_irq_work;
12757c12aa08SLendacky, Thomas
12767c12aa08SLendacky, Thomas /* Auto-negotiation state machine support */
1277ced3fcaeSLendacky, Thomas unsigned int an_int;
12781bf40adaSLendacky, Thomas unsigned int an_status;
12797c12aa08SLendacky, Thomas struct mutex an_mutex;
12807c12aa08SLendacky, Thomas enum xgbe_an an_result;
12817c12aa08SLendacky, Thomas enum xgbe_an an_state;
12827c12aa08SLendacky, Thomas enum xgbe_rx kr_state;
12837c12aa08SLendacky, Thomas enum xgbe_rx kx_state;
12847c12aa08SLendacky, Thomas struct work_struct an_work;
128576cce0afSTom Lendacky unsigned int an_again;
12867c12aa08SLendacky, Thomas unsigned int an_supported;
12877c12aa08SLendacky, Thomas unsigned int parallel_detect;
12887c12aa08SLendacky, Thomas unsigned int fec_ability;
12897c12aa08SLendacky, Thomas unsigned long an_start;
1290926446aeSRaju Rangoju unsigned long kr_start_time;
1291a64def41SLendacky, Thomas enum xgbe_an_mode an_mode;
12927c12aa08SLendacky, Thomas
12935ab1dcd5SLendacky, Thomas /* I2C support */
12945ab1dcd5SLendacky, Thomas struct xgbe_i2c i2c;
12955ab1dcd5SLendacky, Thomas struct mutex i2c_mutex;
12965ab1dcd5SLendacky, Thomas struct completion i2c_complete;
12975ab1dcd5SLendacky, Thomas char i2c_name[IFNAMSIZ + 32];
12985ab1dcd5SLendacky, Thomas
12997c12aa08SLendacky, Thomas unsigned int lpm_ctrl; /* CTRL1 for resume */
13007c12aa08SLendacky, Thomas
130185b85c85SLendacky, Thomas unsigned int isr_as_tasklet;
130285b85c85SLendacky, Thomas struct tasklet_struct tasklet_dev;
130385b85c85SLendacky, Thomas struct tasklet_struct tasklet_ecc;
130485b85c85SLendacky, Thomas struct tasklet_struct tasklet_i2c;
130585b85c85SLendacky, Thomas struct tasklet_struct tasklet_an;
130685b85c85SLendacky, Thomas
1307c5aa9e3bSLendacky, Thomas struct dentry *xgbe_debugfs;
1308c5aa9e3bSLendacky, Thomas
1309c5aa9e3bSLendacky, Thomas unsigned int debugfs_xgmac_reg;
1310c5aa9e3bSLendacky, Thomas
1311c5aa9e3bSLendacky, Thomas unsigned int debugfs_xpcs_mmd;
1312c5aa9e3bSLendacky, Thomas unsigned int debugfs_xpcs_reg;
131347f164deSLendacky, Thomas
131447f164deSLendacky, Thomas unsigned int debugfs_xprop_reg;
13155ab1dcd5SLendacky, Thomas
13165ab1dcd5SLendacky, Thomas unsigned int debugfs_xi2c_reg;
131796f4d430STom Lendacky
131896f4d430STom Lendacky bool debugfs_an_cdr_workaround;
131996f4d430STom Lendacky bool debugfs_an_cdr_track_early;
1320*4f3b20bfSRaju Rangoju bool en_rx_adap;
1321*4f3b20bfSRaju Rangoju int rx_adapt_retries;
1322*4f3b20bfSRaju Rangoju bool rx_adapt_done;
1323*4f3b20bfSRaju Rangoju bool mode_set;
1324c5aa9e3bSLendacky, Thomas };
1325c5aa9e3bSLendacky, Thomas
1326c5aa9e3bSLendacky, Thomas /* Function prototypes*/
1327bd8255d8SLendacky, Thomas struct xgbe_prv_data *xgbe_alloc_pdata(struct device *);
1328bd8255d8SLendacky, Thomas void xgbe_free_pdata(struct xgbe_prv_data *);
1329bd8255d8SLendacky, Thomas void xgbe_set_counts(struct xgbe_prv_data *);
1330bd8255d8SLendacky, Thomas int xgbe_config_netdev(struct xgbe_prv_data *);
1331bd8255d8SLendacky, Thomas void xgbe_deconfig_netdev(struct xgbe_prv_data *);
1332bd8255d8SLendacky, Thomas
1333bd8255d8SLendacky, Thomas int xgbe_platform_init(void);
1334bd8255d8SLendacky, Thomas void xgbe_platform_exit(void);
133547f164deSLendacky, Thomas #ifdef CONFIG_PCI
133647f164deSLendacky, Thomas int xgbe_pci_init(void);
133747f164deSLendacky, Thomas void xgbe_pci_exit(void);
133847f164deSLendacky, Thomas #else
xgbe_pci_init(void)133947f164deSLendacky, Thomas static inline int xgbe_pci_init(void) { return 0; }
xgbe_pci_exit(void)134047f164deSLendacky, Thomas static inline void xgbe_pci_exit(void) { }
134147f164deSLendacky, Thomas #endif
1342c5aa9e3bSLendacky, Thomas
1343c5aa9e3bSLendacky, Thomas void xgbe_init_function_ptrs_dev(struct xgbe_hw_if *);
13447c12aa08SLendacky, Thomas void xgbe_init_function_ptrs_phy(struct xgbe_phy_if *);
1345e57f7a3fSLendacky, Thomas void xgbe_init_function_ptrs_phy_v1(struct xgbe_phy_if *);
134647f164deSLendacky, Thomas void xgbe_init_function_ptrs_phy_v2(struct xgbe_phy_if *);
1347c5aa9e3bSLendacky, Thomas void xgbe_init_function_ptrs_desc(struct xgbe_desc_if *);
13485ab1dcd5SLendacky, Thomas void xgbe_init_function_ptrs_i2c(struct xgbe_i2c_if *);
1349ce0b15d1Sstephen hemminger const struct net_device_ops *xgbe_get_netdev_ops(void);
1350ce0b15d1Sstephen hemminger const struct ethtool_ops *xgbe_get_ethtool_ops(void);
13514df587abSJakub Kicinski const struct udp_tunnel_nic_info *xgbe_get_udp_tunnel_info(void);
1352ce0b15d1Sstephen hemminger
1353fca2d994SLendacky, Thomas #ifdef CONFIG_AMD_XGBE_DCB
1354fca2d994SLendacky, Thomas const struct dcbnl_rtnl_ops *xgbe_get_dcbnl_ops(void);
1355fca2d994SLendacky, Thomas #endif
1356c5aa9e3bSLendacky, Thomas
135723e4eef7SLendacky, Thomas void xgbe_ptp_register(struct xgbe_prv_data *);
135823e4eef7SLendacky, Thomas void xgbe_ptp_unregister(struct xgbe_prv_data *);
135934bf65dfSLendacky, Thomas void xgbe_dump_tx_desc(struct xgbe_prv_data *, struct xgbe_ring *,
136034bf65dfSLendacky, Thomas unsigned int, unsigned int, unsigned int);
136134bf65dfSLendacky, Thomas void xgbe_dump_rx_desc(struct xgbe_prv_data *, struct xgbe_ring *,
1362c5aa9e3bSLendacky, Thomas unsigned int);
1363c5aa9e3bSLendacky, Thomas void xgbe_print_pkt(struct net_device *, struct sk_buff *, bool);
1364c5aa9e3bSLendacky, Thomas void xgbe_get_all_hw_features(struct xgbe_prv_data *);
1365c5aa9e3bSLendacky, Thomas int xgbe_powerup(struct net_device *, unsigned int);
1366c5aa9e3bSLendacky, Thomas int xgbe_powerdown(struct net_device *, unsigned int);
1367c5aa9e3bSLendacky, Thomas void xgbe_init_rx_coalesce(struct xgbe_prv_data *);
1368c5aa9e3bSLendacky, Thomas void xgbe_init_tx_coalesce(struct xgbe_prv_data *);
1369bab748deSTom Lendacky void xgbe_restart_dev(struct xgbe_prv_data *pdata);
137001b5277fSTom Lendacky void xgbe_full_restart_dev(struct xgbe_prv_data *pdata);
1371c5aa9e3bSLendacky, Thomas
1372c5aa9e3bSLendacky, Thomas #ifdef CONFIG_DEBUG_FS
1373c5aa9e3bSLendacky, Thomas void xgbe_debugfs_init(struct xgbe_prv_data *);
1374c5aa9e3bSLendacky, Thomas void xgbe_debugfs_exit(struct xgbe_prv_data *);
1375efbaa828SLendacky, Thomas void xgbe_debugfs_rename(struct xgbe_prv_data *pdata);
1376c5aa9e3bSLendacky, Thomas #else
xgbe_debugfs_init(struct xgbe_prv_data * pdata)1377c5aa9e3bSLendacky, Thomas static inline void xgbe_debugfs_init(struct xgbe_prv_data *pdata) {}
xgbe_debugfs_exit(struct xgbe_prv_data * pdata)1378c5aa9e3bSLendacky, Thomas static inline void xgbe_debugfs_exit(struct xgbe_prv_data *pdata) {}
xgbe_debugfs_rename(struct xgbe_prv_data * pdata)1379efbaa828SLendacky, Thomas static inline void xgbe_debugfs_rename(struct xgbe_prv_data *pdata) {}
1380c5aa9e3bSLendacky, Thomas #endif /* CONFIG_DEBUG_FS */
1381c5aa9e3bSLendacky, Thomas
1382c5aa9e3bSLendacky, Thomas /* NOTE: Uncomment for function trace log messages in KERNEL LOG */
1383c5aa9e3bSLendacky, Thomas #if 0
1384c5aa9e3bSLendacky, Thomas #define YDEBUG
1385c5aa9e3bSLendacky, Thomas #define YDEBUG_MDIO
1386c5aa9e3bSLendacky, Thomas #endif
1387c5aa9e3bSLendacky, Thomas
1388c5aa9e3bSLendacky, Thomas /* For debug prints */
1389c5aa9e3bSLendacky, Thomas #ifdef YDEBUG
1390c5aa9e3bSLendacky, Thomas #define DBGPR(x...) pr_alert(x)
1391c5aa9e3bSLendacky, Thomas #else
1392c5aa9e3bSLendacky, Thomas #define DBGPR(x...) do { } while (0)
1393c5aa9e3bSLendacky, Thomas #endif
1394c5aa9e3bSLendacky, Thomas
1395c5aa9e3bSLendacky, Thomas #ifdef YDEBUG_MDIO
1396c5aa9e3bSLendacky, Thomas #define DBGPR_MDIO(x...) pr_alert(x)
1397c5aa9e3bSLendacky, Thomas #else
1398c5aa9e3bSLendacky, Thomas #define DBGPR_MDIO(x...) do { } while (0)
1399c5aa9e3bSLendacky, Thomas #endif
1400c5aa9e3bSLendacky, Thomas
1401c5aa9e3bSLendacky, Thomas #endif
1402