blob: e9282c9246210344d79a626cac9d7bcbfb49a1ff [file] [log] [blame]
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001/*
2 * AMD 10Gb Ethernet driver
3 *
4 * This file is available to you under your choice of the following two
5 * licenses:
6 *
7 * License 1: GPLv2
8 *
Lendacky, Thomasb3b71592016-02-17 11:49:08 -06009 * Copyright (c) 2014-2016 Advanced Micro Devices, Inc.
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -050010 *
11 * This file is free software; you may copy, redistribute and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 2 of the License, or (at
14 * your option) any later version.
15 *
16 * This file is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 *
24 * This file incorporates work covered by the following copyright and
25 * permission notice:
26 * The Synopsys DWC ETHER XGMAC Software Driver and documentation
27 * (hereinafter "Software") is an unsupported proprietary work of Synopsys,
28 * Inc. unless otherwise expressly agreed to in writing between Synopsys
29 * and you.
30 *
31 * The Software IS NOT an item of Licensed Software or Licensed Product
32 * under any End User Software License Agreement or Agreement for Licensed
33 * Product with Synopsys or any supplement thereto. Permission is hereby
34 * granted, free of charge, to any person obtaining a copy of this software
35 * annotated with this license and the Software, to deal in the Software
36 * without restriction, including without limitation the rights to use,
37 * copy, modify, merge, publish, distribute, sublicense, and/or sell copies
38 * of the Software, and to permit persons to whom the Software is furnished
39 * to do so, subject to the following conditions:
40 *
41 * The above copyright notice and this permission notice shall be included
42 * in all copies or substantial portions of the Software.
43 *
44 * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
45 * BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
46 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
47 * PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
48 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
49 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
50 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
51 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
52 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
53 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
54 * THE POSSIBILITY OF SUCH DAMAGE.
55 *
56 *
57 * License 2: Modified BSD
58 *
Lendacky, Thomasb3b71592016-02-17 11:49:08 -060059 * Copyright (c) 2014-2016 Advanced Micro Devices, Inc.
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -050060 * All rights reserved.
61 *
62 * Redistribution and use in source and binary forms, with or without
63 * modification, are permitted provided that the following conditions are met:
64 * * Redistributions of source code must retain the above copyright
65 * notice, this list of conditions and the following disclaimer.
66 * * Redistributions in binary form must reproduce the above copyright
67 * notice, this list of conditions and the following disclaimer in the
68 * documentation and/or other materials provided with the distribution.
69 * * Neither the name of Advanced Micro Devices, Inc. nor the
70 * names of its contributors may be used to endorse or promote products
71 * derived from this software without specific prior written permission.
72 *
73 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
74 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
75 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
76 * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
77 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
78 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
79 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
80 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
81 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
82 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
83 *
84 * This file incorporates work covered by the following copyright and
85 * permission notice:
86 * The Synopsys DWC ETHER XGMAC Software Driver and documentation
87 * (hereinafter "Software") is an unsupported proprietary work of Synopsys,
88 * Inc. unless otherwise expressly agreed to in writing between Synopsys
89 * and you.
90 *
91 * The Software IS NOT an item of Licensed Software or Licensed Product
92 * under any End User Software License Agreement or Agreement for Licensed
93 * Product with Synopsys or any supplement thereto. Permission is hereby
94 * granted, free of charge, to any person obtaining a copy of this software
95 * annotated with this license and the Software, to deal in the Software
96 * without restriction, including without limitation the rights to use,
97 * copy, modify, merge, publish, distribute, sublicense, and/or sell copies
98 * of the Software, and to permit persons to whom the Software is furnished
99 * to do so, subject to the following conditions:
100 *
101 * The above copyright notice and this permission notice shall be included
102 * in all copies or substantial portions of the Software.
103 *
104 * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
105 * BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
106 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
107 * PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
108 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
109 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
110 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
111 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
112 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
113 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
114 * THE POSSIBILITY OF SUCH DAMAGE.
115 */
116
117#ifndef __XGBE_H__
118#define __XGBE_H__
119
120#include <linux/dma-mapping.h>
121#include <linux/netdevice.h>
122#include <linux/workqueue.h>
123#include <linux/phy.h>
Lendacky, Thomas801c62d2014-06-24 16:19:24 -0500124#include <linux/if_vlan.h>
125#include <linux/bitops.h>
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500126#include <linux/ptp_clock_kernel.h>
Richard Cochran74d23cc2014-12-21 19:46:56 +0100127#include <linux/timecounter.h>
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500128#include <linux/net_tstamp.h>
Lendacky, Thomasfca2d992014-07-29 08:57:55 -0500129#include <net/dcbnl.h>
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -0600130#include <linux/completion.h>
Lendacky, Thomasf00ba492017-06-28 13:43:00 -0500131#include <linux/cpumask.h>
Florian Westphal0ab10312017-07-17 13:57:18 +0200132#include <linux/interrupt.h>
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500133
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500134#define XGBE_DRV_NAME "amd-xgbe"
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500135#define XGBE_DRV_VERSION "1.0.3"
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500136#define XGBE_DRV_DESC "AMD 10 Gigabit Ethernet Driver"
137
138/* Descriptor related defines */
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500139#define XGBE_TX_DESC_CNT 512
140#define XGBE_TX_DESC_MIN_FREE (XGBE_TX_DESC_CNT >> 3)
141#define XGBE_TX_DESC_MAX_PROC (XGBE_TX_DESC_CNT >> 1)
142#define XGBE_RX_DESC_CNT 512
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500143
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500144#define XGBE_TX_MAX_BUF_SIZE (0x3fff & ~(64 - 1))
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500145
Masahiro Yamadae1c05062015-07-07 10:14:59 +0900146/* Descriptors required for maximum contiguous TSO/GSO packet */
Lendacky, Thomas16958a22014-11-20 11:04:08 -0600147#define XGBE_TX_MAX_SPLIT ((GSO_MAX_SIZE / XGBE_TX_MAX_BUF_SIZE) + 1)
148
149/* Maximum possible descriptors needed for an SKB:
150 * - Maximum number of SKB frags
151 * - Maximum descriptors for contiguous TSO/GSO packet
152 * - Possible context descriptor
153 * - Possible TSO header descriptor
154 */
155#define XGBE_TX_MAX_DESCS (MAX_SKB_FRAGS + XGBE_TX_MAX_SPLIT + 2)
156
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500157#define XGBE_RX_MIN_BUF_SIZE (ETH_FRAME_LEN + ETH_FCS_LEN + VLAN_HLEN)
158#define XGBE_RX_BUF_ALIGN 64
Lendacky, Thomas08dcc472014-11-04 16:06:44 -0600159#define XGBE_SKB_ALLOC_SIZE 256
Lendacky, Thomas174fd252014-11-04 16:06:50 -0600160#define XGBE_SPH_HDSMS_SIZE 2 /* Keep in sync with SKB_ALLOC_SIZE */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500161
Lendacky, Thomasd5c48582014-06-09 09:19:32 -0500162#define XGBE_MAX_DMA_CHANNELS 16
Lendacky, Thomasfca2d992014-07-29 08:57:55 -0500163#define XGBE_MAX_QUEUES 16
Lendacky, Thomas43e0dcf2016-11-03 13:18:16 -0500164#define XGBE_PRIORITY_QUEUES 8
Lendacky, Thomas4b8acdf2016-11-03 13:19:17 -0500165#define XGBE_DMA_STOP_TIMEOUT 1
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500166
167/* DMA cache settings - Outer sharable, write-back, write-allocate */
Lendacky, Thomas99167162017-06-28 13:43:09 -0500168#define XGBE_DMA_OS_ARCR 0x002b2b2b
169#define XGBE_DMA_OS_AWCR 0x2f2f2f2f
Lendacky, Thomascfa50c72014-07-02 13:04:57 -0500170
171/* DMA cache settings - System, no caches used */
Lendacky, Thomas99167162017-06-28 13:43:09 -0500172#define XGBE_DMA_SYS_ARCR 0x00303030
173#define XGBE_DMA_SYS_AWCR 0x30303030
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500174
Lendacky, Thomas6f595952017-06-28 13:43:26 -0500175/* DMA cache settings - PCI device */
176#define XGBE_DMA_PCI_ARCR 0x00000003
177#define XGBE_DMA_PCI_AWCR 0x13131313
178#define XGBE_DMA_PCI_AWARCR 0x00000313
179
Lendacky, Thomas4c70dd82016-11-10 17:10:17 -0600180/* DMA channel interrupt modes */
181#define XGBE_IRQ_MODE_EDGE 0
182#define XGBE_IRQ_MODE_LEVEL 1
183
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500184#define XGBE_DMA_INTERRUPT_MASK 0x31c7
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500185
186#define XGMAC_MIN_PACKET 60
187#define XGMAC_STD_PACKET_MTU 1500
188#define XGMAC_MAX_STD_PACKET 1518
189#define XGMAC_JUMBO_PACKET_MTU 9000
190#define XGMAC_MAX_JUMBO_PACKET 9018
Lendacky, Thomas43e0dcf2016-11-03 13:18:16 -0500191#define XGMAC_ETH_PREAMBLE (12 + 8) /* Inter-frame gap + preamble */
192
193#define XGMAC_PFC_DATA_LEN 46
194#define XGMAC_PFC_DELAYS 14000
195
196#define XGMAC_PRIO_QUEUES(_cnt) \
197 min_t(unsigned int, IEEE_8021QAZ_MAX_TCS, (_cnt))
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500198
Lendacky, Thomas82a19032015-01-16 12:47:16 -0600199/* Common property names */
200#define XGBE_MAC_ADDR_PROPERTY "mac-address"
201#define XGBE_PHY_MODE_PROPERTY "phy-mode"
202#define XGBE_DMA_IRQS_PROPERTY "amd,per-channel-interrupt"
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500203#define XGBE_SPEEDSET_PROPERTY "amd,speed-set"
Lendacky, Thomas82a19032015-01-16 12:47:16 -0600204
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500205/* Device-tree clock names */
206#define XGBE_DMA_CLOCK "dma_clk"
207#define XGBE_PTP_CLOCK "ptp_clk"
Lendacky, Thomas82a19032015-01-16 12:47:16 -0600208
209/* ACPI property names */
210#define XGBE_ACPI_DMA_FREQ "amd,dma-freq"
211#define XGBE_ACPI_PTP_FREQ "amd,ptp-freq"
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500212
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600213/* PCI BAR mapping */
214#define XGBE_XGMAC_BAR 0
215#define XGBE_XPCS_BAR 1
216#define XGBE_MAC_PROP_OFFSET 0x1d000
217#define XGBE_I2C_CTRL_OFFSET 0x1e000
218
Tom Lendackye7537742017-01-13 09:05:53 +0100219/* PCI MSI/MSIx support */
220#define XGBE_MSI_BASE_COUNT 4
221#define XGBE_MSI_MIN_COUNT (XGBE_MSI_BASE_COUNT + 1)
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600222
223/* PCI clock frequencies */
224#define XGBE_V2_DMA_CLOCK_FREQ 500000000 /* 500 MHz */
225#define XGBE_V2_PTP_CLOCK_FREQ 125000000 /* 125 MHz */
226
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500227/* Timestamp support - values based on 50MHz PTP clock
228 * 50MHz => 20 nsec
229 */
230#define XGBE_TSTAMP_SSINC 20
231#define XGBE_TSTAMP_SNSINC 0
232
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500233/* Driver PMT macros */
234#define XGMAC_DRIVER_CONTEXT 1
235#define XGMAC_IOCTL_CONTEXT 2
236
Lendacky, Thomas43e0dcf2016-11-03 13:18:16 -0500237#define XGMAC_FIFO_MIN_ALLOC 2048
238#define XGMAC_FIFO_UNIT 256
239#define XGMAC_FIFO_ALIGN(_x) \
240 (((_x) + XGMAC_FIFO_UNIT - 1) & ~(XGMAC_FIFO_UNIT - 1))
241#define XGMAC_FIFO_FC_OFF 2048
242#define XGMAC_FIFO_FC_MIN 4096
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500243
Lendacky, Thomasfca2d992014-07-29 08:57:55 -0500244#define XGBE_TC_MIN_QUANTUM 10
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500245
246/* Helper macro for descriptor handling
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500247 * Always use XGBE_GET_DESC_DATA to access the descriptor data
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500248 * since the index is free-running and needs to be and-ed
249 * with the descriptor count value of the ring to index to
250 * the proper descriptor data.
251 */
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500252#define XGBE_GET_DESC_DATA(_ring, _idx) \
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500253 ((_ring)->rdata + \
254 ((_idx) & ((_ring)->rdesc_count - 1)))
255
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500256/* Default coalescing parameters */
Lendacky, Thomasc635eaa2015-03-20 11:50:28 -0500257#define XGMAC_INIT_DMA_TX_USECS 1000
Lendacky, Thomas9867e8f2014-07-02 13:04:46 -0500258#define XGMAC_INIT_DMA_TX_FRAMES 25
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500259
260#define XGMAC_MAX_DMA_RIWT 0xff
Lendacky, Thomas9867e8f2014-07-02 13:04:46 -0500261#define XGMAC_INIT_DMA_RX_USECS 30
262#define XGMAC_INIT_DMA_RX_FRAMES 25
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500263
264/* Flow control queue count */
265#define XGMAC_MAX_FLOW_CONTROL_QUEUES 8
266
Lendacky, Thomas43e0dcf2016-11-03 13:18:16 -0500267/* Flow control threshold units */
268#define XGMAC_FLOW_CONTROL_UNIT 512
269#define XGMAC_FLOW_CONTROL_ALIGN(_x) \
270 (((_x) + XGMAC_FLOW_CONTROL_UNIT - 1) & ~(XGMAC_FLOW_CONTROL_UNIT - 1))
271#define XGMAC_FLOW_CONTROL_VALUE(_x) \
272 (((_x) < 1024) ? 0 : ((_x) / XGMAC_FLOW_CONTROL_UNIT) - 2)
273#define XGMAC_FLOW_CONTROL_MAX 33280
274
Lendacky, Thomasb85e4d82014-06-24 16:19:29 -0500275/* Maximum MAC address hash table size (256 bits = 8 bytes) */
276#define XGBE_MAC_HASH_TABLE_SIZE 8
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500277
Lendacky, Thomas5b9dfe22014-11-04 16:07:02 -0600278/* Receive Side Scaling */
279#define XGBE_RSS_HASH_KEY_SIZE 40
280#define XGBE_RSS_MAX_TABLE_SIZE 256
281#define XGBE_RSS_LOOKUP_TABLE_TYPE 0
282#define XGBE_RSS_HASH_KEY_TYPE 1
283
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500284/* Auto-negotiation */
285#define XGBE_AN_MS_TIMEOUT 500
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500286#define XGBE_LINK_TIMEOUT 5
287
288#define XGBE_SGMII_AN_LINK_STATUS BIT(1)
289#define XGBE_SGMII_AN_LINK_SPEED (BIT(2) | BIT(3))
290#define XGBE_SGMII_AN_LINK_SPEED_100 0x04
291#define XGBE_SGMII_AN_LINK_SPEED_1000 0x08
292#define XGBE_SGMII_AN_LINK_DUPLEX BIT(4)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500293
Lendacky, Thomase78332b2016-11-10 17:10:26 -0600294/* ECC correctable error notification window (seconds) */
295#define XGBE_ECC_LIMIT 60
296
Lendacky, Thomas732f2ab2016-11-10 17:11:14 -0600297/* MDIO port types */
298#define XGMAC_MAX_C22_PORT 3
299
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500300struct xgbe_prv_data;
301
302struct xgbe_packet_data {
Lendacky, Thomas16958a22014-11-20 11:04:08 -0600303 struct sk_buff *skb;
304
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500305 unsigned int attributes;
306
307 unsigned int errors;
308
309 unsigned int rdesc_count;
310 unsigned int length;
311
312 unsigned int header_len;
313 unsigned int tcp_header_len;
314 unsigned int tcp_payload_len;
315 unsigned short mss;
316
317 unsigned short vlan_ctag;
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500318
319 u64 rx_tstamp;
Lendacky, Thomas5b9dfe22014-11-04 16:07:02 -0600320
321 u32 rss_hash;
322 enum pkt_hash_types rss_hash_type;
Lendacky, Thomas5fb4b862014-11-20 11:03:50 -0600323
324 unsigned int tx_packets;
325 unsigned int tx_bytes;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500326};
327
328/* Common Rx and Tx descriptor mapping */
329struct xgbe_ring_desc {
Lendacky, Thomas5226cfc2014-11-12 10:37:49 -0600330 __le32 desc0;
331 __le32 desc1;
332 __le32 desc2;
333 __le32 desc3;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500334};
335
Lendacky, Thomas08dcc472014-11-04 16:06:44 -0600336/* Page allocation related values */
337struct xgbe_page_alloc {
338 struct page *pages;
339 unsigned int pages_len;
340 unsigned int pages_offset;
341
342 dma_addr_t pages_dma;
343};
344
Lendacky, Thomas174fd252014-11-04 16:06:50 -0600345/* Ring entry buffer data */
346struct xgbe_buffer_data {
347 struct xgbe_page_alloc pa;
348 struct xgbe_page_alloc pa_unmap;
349
Lendacky, Thomascfbfd862015-07-06 11:57:37 -0500350 dma_addr_t dma_base;
351 unsigned long dma_off;
Lendacky, Thomas174fd252014-11-04 16:06:50 -0600352 unsigned int dma_len;
353};
354
Lendacky, Thomasc9f140e2014-11-20 11:03:44 -0600355/* Tx-related ring data */
356struct xgbe_tx_ring_data {
Lendacky, Thomas5fb4b862014-11-20 11:03:50 -0600357 unsigned int packets; /* BQL packet count */
358 unsigned int bytes; /* BQL byte count */
Lendacky, Thomasc9f140e2014-11-20 11:03:44 -0600359};
360
361/* Rx-related ring data */
362struct xgbe_rx_ring_data {
363 struct xgbe_buffer_data hdr; /* Header locations */
364 struct xgbe_buffer_data buf; /* Payload locations */
365
366 unsigned short hdr_len; /* Length of received header */
367 unsigned short len; /* Length of received packet */
368};
369
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500370/* Structure used to hold information related to the descriptor
371 * and the packet associated with the descriptor (always use
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500372 * use the XGBE_GET_DESC_DATA macro to access this data from the ring)
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500373 */
374struct xgbe_ring_data {
375 struct xgbe_ring_desc *rdesc; /* Virtual address of descriptor */
376 dma_addr_t rdesc_dma; /* DMA address of descriptor */
377
378 struct sk_buff *skb; /* Virtual address of SKB */
379 dma_addr_t skb_dma; /* DMA address of SKB data */
380 unsigned int skb_dma_len; /* Length of SKB DMA area */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500381
Lendacky, Thomasc9f140e2014-11-20 11:03:44 -0600382 struct xgbe_tx_ring_data tx; /* Tx-related data */
383 struct xgbe_rx_ring_data rx; /* Rx-related data */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500384
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500385 unsigned int mapped_as_page;
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500386
387 /* Incomplete receive save location. If the budget is exhausted
388 * or the last descriptor (last normal descriptor or a following
389 * context descriptor) has not been DMA'd yet the current state
390 * of the receive processing needs to be saved.
391 */
392 unsigned int state_saved;
393 struct {
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500394 struct sk_buff *skb;
395 unsigned int len;
396 unsigned int error;
397 } state;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500398};
399
400struct xgbe_ring {
401 /* Ring lock - used just for TX rings at the moment */
402 spinlock_t lock;
403
404 /* Per packet related information */
405 struct xgbe_packet_data packet_data;
406
407 /* Virtual/DMA addresses and count of allocated descriptor memory */
408 struct xgbe_ring_desc *rdesc;
409 dma_addr_t rdesc_dma;
410 unsigned int rdesc_count;
411
412 /* Array of descriptor data corresponding the descriptor memory
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500413 * (always use the XGBE_GET_DESC_DATA macro to access this data)
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500414 */
415 struct xgbe_ring_data *rdata;
416
Lendacky, Thomas08dcc472014-11-04 16:06:44 -0600417 /* Page allocation for RX buffers */
Lendacky, Thomas174fd252014-11-04 16:06:50 -0600418 struct xgbe_page_alloc rx_hdr_pa;
419 struct xgbe_page_alloc rx_buf_pa;
Lendacky, Thomas18f9f0a2017-06-28 13:42:51 -0500420 int node;
Lendacky, Thomas08dcc472014-11-04 16:06:44 -0600421
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500422 /* Ring index values
423 * cur - Tx: index of descriptor to be used for current transfer
424 * Rx: index of descriptor to check for packet availability
425 * dirty - Tx: index of descriptor to check for transfer complete
Lendacky, Thomas270894e2015-01-16 12:46:50 -0600426 * Rx: index of descriptor to check for buffer reallocation
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500427 */
428 unsigned int cur;
429 unsigned int dirty;
430
431 /* Coalesce frame count used for interrupt bit setting */
432 unsigned int coalesce_count;
433
434 union {
435 struct {
436 unsigned int queue_stopped;
Lendacky, Thomas16958a22014-11-20 11:04:08 -0600437 unsigned int xmit_more;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500438 unsigned short cur_mss;
439 unsigned short cur_vlan_ctag;
440 } tx;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500441 };
442} ____cacheline_aligned;
443
444/* Structure used to describe the descriptor rings associated with
445 * a DMA channel.
446 */
447struct xgbe_channel {
448 char name[16];
449
450 /* Address of private data area for device */
451 struct xgbe_prv_data *pdata;
452
453 /* Queue index and base address of queue's DMA registers */
454 unsigned int queue_index;
455 void __iomem *dma_regs;
456
Lendacky, Thomas9227dc52014-11-04 16:06:56 -0600457 /* Per channel interrupt irq number */
458 int dma_irq;
Lendacky, Thomas54ceb9e2014-12-02 18:07:18 -0600459 char dma_irq_name[IFNAMSIZ + 32];
Lendacky, Thomas9227dc52014-11-04 16:06:56 -0600460
461 /* Netdev related settings */
462 struct napi_struct napi;
463
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500464 unsigned int saved_ier;
465
466 unsigned int tx_timer_active;
Lendacky, Thomasc635eaa2015-03-20 11:50:28 -0500467 struct timer_list tx_timer;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500468
469 struct xgbe_ring *tx_ring;
470 struct xgbe_ring *rx_ring;
Lendacky, Thomas18f9f0a2017-06-28 13:42:51 -0500471
472 int node;
Lendacky, Thomasf00ba492017-06-28 13:43:00 -0500473 cpumask_t affinity_mask;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500474} ____cacheline_aligned;
475
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500476enum xgbe_state {
477 XGBE_DOWN,
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500478 XGBE_LINK_INIT,
479 XGBE_LINK_ERR,
Lendacky, Thomase78332b2016-11-10 17:10:26 -0600480 XGBE_STOPPED,
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500481};
482
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500483enum xgbe_int {
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500484 XGMAC_INT_DMA_CH_SR_TI,
485 XGMAC_INT_DMA_CH_SR_TPS,
486 XGMAC_INT_DMA_CH_SR_TBU,
487 XGMAC_INT_DMA_CH_SR_RI,
488 XGMAC_INT_DMA_CH_SR_RBU,
489 XGMAC_INT_DMA_CH_SR_RPS,
Lendacky, Thomas9867e8f2014-07-02 13:04:46 -0500490 XGMAC_INT_DMA_CH_SR_TI_RI,
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500491 XGMAC_INT_DMA_CH_SR_FBE,
492 XGMAC_INT_DMA_ALL,
493};
494
495enum xgbe_int_state {
496 XGMAC_INT_STATE_SAVE,
497 XGMAC_INT_STATE_RESTORE,
498};
499
Lendacky, Thomase78332b2016-11-10 17:10:26 -0600500enum xgbe_ecc_sec {
501 XGBE_ECC_SEC_TX,
502 XGBE_ECC_SEC_RX,
503 XGBE_ECC_SEC_DESC,
504};
505
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500506enum xgbe_speed {
507 XGBE_SPEED_1000 = 0,
508 XGBE_SPEED_2500,
509 XGBE_SPEED_10000,
510 XGBE_SPEEDS,
511};
512
Lendacky, Thomasb03a4a62016-11-03 13:18:56 -0500513enum xgbe_xpcs_access {
514 XGBE_XPCS_ACCESS_V1 = 0,
515 XGBE_XPCS_ACCESS_V2,
516};
517
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500518enum xgbe_an_mode {
519 XGBE_AN_MODE_CL73 = 0,
Lendacky, Thomasd7445d12016-11-10 17:11:41 -0600520 XGBE_AN_MODE_CL73_REDRV,
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500521 XGBE_AN_MODE_CL37,
522 XGBE_AN_MODE_CL37_SGMII,
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500523 XGBE_AN_MODE_NONE,
524};
525
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500526enum xgbe_an {
527 XGBE_AN_READY = 0,
528 XGBE_AN_PAGE_RECEIVED,
529 XGBE_AN_INCOMPAT_LINK,
530 XGBE_AN_COMPLETE,
531 XGBE_AN_NO_LINK,
532 XGBE_AN_ERROR,
533};
534
535enum xgbe_rx {
536 XGBE_RX_BPA = 0,
537 XGBE_RX_XNP,
538 XGBE_RX_COMPLETE,
539 XGBE_RX_ERROR,
540};
541
542enum xgbe_mode {
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500543 XGBE_MODE_KX_1000 = 0,
544 XGBE_MODE_KX_2500,
545 XGBE_MODE_KR,
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -0600546 XGBE_MODE_X,
547 XGBE_MODE_SGMII_100,
548 XGBE_MODE_SGMII_1000,
549 XGBE_MODE_SFI,
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500550 XGBE_MODE_UNKNOWN,
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500551};
552
553enum xgbe_speedset {
554 XGBE_SPEEDSET_1000_10000 = 0,
555 XGBE_SPEEDSET_2500_10000,
556};
557
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -0600558enum xgbe_mdio_mode {
559 XGBE_MDIO_MODE_NONE = 0,
560 XGBE_MDIO_MODE_CL22,
561 XGBE_MDIO_MODE_CL45,
562};
563
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500564struct xgbe_phy {
565 u32 supported;
566 u32 advertising;
567 u32 lp_advertising;
568
569 int address;
570
571 int autoneg;
572 int speed;
573 int duplex;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500574
575 int link;
Lendacky, Thomasc1ce2f72015-05-14 11:44:27 -0500576
577 int pause_autoneg;
578 int tx_pause;
579 int rx_pause;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500580};
581
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -0600582enum xgbe_i2c_cmd {
583 XGBE_I2C_CMD_READ = 0,
584 XGBE_I2C_CMD_WRITE,
585};
586
587struct xgbe_i2c_op {
588 enum xgbe_i2c_cmd cmd;
589
590 unsigned int target;
591
592 void *buf;
593 unsigned int len;
594};
595
596struct xgbe_i2c_op_state {
597 struct xgbe_i2c_op *op;
598
599 unsigned int tx_len;
600 unsigned char *tx_buf;
601
602 unsigned int rx_len;
603 unsigned char *rx_buf;
604
605 unsigned int tx_abort_source;
606
607 int ret;
608};
609
610struct xgbe_i2c {
611 unsigned int started;
612 unsigned int max_speed_mode;
613 unsigned int rx_fifo_size;
614 unsigned int tx_fifo_size;
615
616 struct xgbe_i2c_op_state op_state;
617};
618
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500619struct xgbe_mmc_stats {
620 /* Tx Stats */
621 u64 txoctetcount_gb;
622 u64 txframecount_gb;
623 u64 txbroadcastframes_g;
624 u64 txmulticastframes_g;
625 u64 tx64octets_gb;
626 u64 tx65to127octets_gb;
627 u64 tx128to255octets_gb;
628 u64 tx256to511octets_gb;
629 u64 tx512to1023octets_gb;
630 u64 tx1024tomaxoctets_gb;
631 u64 txunicastframes_gb;
632 u64 txmulticastframes_gb;
633 u64 txbroadcastframes_gb;
634 u64 txunderflowerror;
635 u64 txoctetcount_g;
636 u64 txframecount_g;
637 u64 txpauseframes;
638 u64 txvlanframes_g;
639
640 /* Rx Stats */
641 u64 rxframecount_gb;
642 u64 rxoctetcount_gb;
643 u64 rxoctetcount_g;
644 u64 rxbroadcastframes_g;
645 u64 rxmulticastframes_g;
646 u64 rxcrcerror;
647 u64 rxrunterror;
648 u64 rxjabbererror;
649 u64 rxundersize_g;
650 u64 rxoversize_g;
651 u64 rx64octets_gb;
652 u64 rx65to127octets_gb;
653 u64 rx128to255octets_gb;
654 u64 rx256to511octets_gb;
655 u64 rx512to1023octets_gb;
656 u64 rx1024tomaxoctets_gb;
657 u64 rxunicastframes_g;
658 u64 rxlengtherror;
659 u64 rxoutofrangetype;
660 u64 rxpauseframes;
661 u64 rxfifooverflow;
662 u64 rxvlanframes_gb;
663 u64 rxwatchdogerror;
664};
665
Lendacky, Thomas5452b2d2015-05-14 11:43:57 -0500666struct xgbe_ext_stats {
667 u64 tx_tso_packets;
668 u64 rx_split_header_packets;
Lendacky, Thomas72c9ac42015-09-30 08:53:10 -0500669 u64 rx_buffer_unavailable;
Lendacky, Thomas5452b2d2015-05-14 11:43:57 -0500670};
671
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500672struct xgbe_hw_if {
673 int (*tx_complete)(struct xgbe_ring_desc *);
674
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500675 int (*set_mac_address)(struct xgbe_prv_data *, u8 *addr);
Lendacky, Thomasb8763822015-04-09 12:11:57 -0500676 int (*config_rx_mode)(struct xgbe_prv_data *);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500677
678 int (*enable_rx_csum)(struct xgbe_prv_data *);
679 int (*disable_rx_csum)(struct xgbe_prv_data *);
680
681 int (*enable_rx_vlan_stripping)(struct xgbe_prv_data *);
682 int (*disable_rx_vlan_stripping)(struct xgbe_prv_data *);
Lendacky, Thomas801c62d2014-06-24 16:19:24 -0500683 int (*enable_rx_vlan_filtering)(struct xgbe_prv_data *);
684 int (*disable_rx_vlan_filtering)(struct xgbe_prv_data *);
685 int (*update_vlan_hash_table)(struct xgbe_prv_data *);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500686
687 int (*read_mmd_regs)(struct xgbe_prv_data *, int, int);
688 void (*write_mmd_regs)(struct xgbe_prv_data *, int, int, int);
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500689 int (*set_speed)(struct xgbe_prv_data *, int);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500690
Lendacky, Thomas732f2ab2016-11-10 17:11:14 -0600691 int (*set_ext_mii_mode)(struct xgbe_prv_data *, unsigned int,
692 enum xgbe_mdio_mode);
693 int (*read_ext_mii_regs)(struct xgbe_prv_data *, int, int);
694 int (*write_ext_mii_regs)(struct xgbe_prv_data *, int, int, u16);
695
696 int (*set_gpio)(struct xgbe_prv_data *, unsigned int);
697 int (*clr_gpio)(struct xgbe_prv_data *, unsigned int);
698
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500699 void (*enable_tx)(struct xgbe_prv_data *);
700 void (*disable_tx)(struct xgbe_prv_data *);
701 void (*enable_rx)(struct xgbe_prv_data *);
702 void (*disable_rx)(struct xgbe_prv_data *);
703
704 void (*powerup_tx)(struct xgbe_prv_data *);
705 void (*powerdown_tx)(struct xgbe_prv_data *);
706 void (*powerup_rx)(struct xgbe_prv_data *);
707 void (*powerdown_rx)(struct xgbe_prv_data *);
708
709 int (*init)(struct xgbe_prv_data *);
710 int (*exit)(struct xgbe_prv_data *);
711
712 int (*enable_int)(struct xgbe_channel *, enum xgbe_int);
713 int (*disable_int)(struct xgbe_channel *, enum xgbe_int);
Lendacky, Thomasa9d41982014-11-04 16:06:32 -0600714 void (*dev_xmit)(struct xgbe_channel *);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500715 int (*dev_read)(struct xgbe_channel *);
716 void (*tx_desc_init)(struct xgbe_channel *);
717 void (*rx_desc_init)(struct xgbe_channel *);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500718 void (*tx_desc_reset)(struct xgbe_ring_data *);
Lendacky, Thomas8dee19e2015-04-09 12:11:51 -0500719 void (*rx_desc_reset)(struct xgbe_prv_data *, struct xgbe_ring_data *,
720 unsigned int);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500721 int (*is_last_desc)(struct xgbe_ring_desc *);
722 int (*is_context_desc)(struct xgbe_ring_desc *);
Lendacky, Thomas16958a22014-11-20 11:04:08 -0600723 void (*tx_start_xmit)(struct xgbe_channel *, struct xgbe_ring *);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500724
725 /* For FLOW ctrl */
726 int (*config_tx_flow_control)(struct xgbe_prv_data *);
727 int (*config_rx_flow_control)(struct xgbe_prv_data *);
728
729 /* For RX coalescing */
730 int (*config_rx_coalesce)(struct xgbe_prv_data *);
731 int (*config_tx_coalesce)(struct xgbe_prv_data *);
732 unsigned int (*usec_to_riwt)(struct xgbe_prv_data *, unsigned int);
733 unsigned int (*riwt_to_usec)(struct xgbe_prv_data *, unsigned int);
734
735 /* For RX and TX threshold config */
736 int (*config_rx_threshold)(struct xgbe_prv_data *, unsigned int);
737 int (*config_tx_threshold)(struct xgbe_prv_data *, unsigned int);
738
739 /* For RX and TX Store and Forward Mode config */
740 int (*config_rsf_mode)(struct xgbe_prv_data *, unsigned int);
741 int (*config_tsf_mode)(struct xgbe_prv_data *, unsigned int);
742
743 /* For TX DMA Operate on Second Frame config */
744 int (*config_osp_mode)(struct xgbe_prv_data *);
745
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500746 /* For MMC statistics */
747 void (*rx_mmc_int)(struct xgbe_prv_data *);
748 void (*tx_mmc_int)(struct xgbe_prv_data *);
749 void (*read_mmc_stats)(struct xgbe_prv_data *);
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500750
751 /* For Timestamp config */
752 int (*config_tstamp)(struct xgbe_prv_data *, unsigned int);
753 void (*update_tstamp_addend)(struct xgbe_prv_data *, unsigned int);
754 void (*set_tstamp_time)(struct xgbe_prv_data *, unsigned int sec,
755 unsigned int nsec);
756 u64 (*get_tstamp_time)(struct xgbe_prv_data *);
757 u64 (*get_tx_tstamp)(struct xgbe_prv_data *);
Lendacky, Thomasfca2d992014-07-29 08:57:55 -0500758
759 /* For Data Center Bridging config */
Lendacky, Thomasb3b71592016-02-17 11:49:08 -0600760 void (*config_tc)(struct xgbe_prv_data *);
Lendacky, Thomasfca2d992014-07-29 08:57:55 -0500761 void (*config_dcb_tc)(struct xgbe_prv_data *);
762 void (*config_dcb_pfc)(struct xgbe_prv_data *);
Lendacky, Thomas5b9dfe22014-11-04 16:07:02 -0600763
764 /* For Receive Side Scaling */
765 int (*enable_rss)(struct xgbe_prv_data *);
766 int (*disable_rss)(struct xgbe_prv_data *);
Lendacky, Thomasf6ac8622014-11-04 16:07:23 -0600767 int (*set_rss_hash_key)(struct xgbe_prv_data *, const u8 *);
768 int (*set_rss_lookup_table)(struct xgbe_prv_data *, const u32 *);
Lendacky, Thomase78332b2016-11-10 17:10:26 -0600769
770 /* For ECC */
771 void (*disable_ecc_ded)(struct xgbe_prv_data *);
772 void (*disable_ecc_sec)(struct xgbe_prv_data *, enum xgbe_ecc_sec);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500773};
774
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500775/* This structure represents implementation specific routines for an
776 * implementation of a PHY. All routines are required unless noted below.
777 * Optional routines:
778 * kr_training_pre, kr_training_post
779 */
780struct xgbe_phy_impl_if {
781 /* Perform Setup/teardown actions */
782 int (*init)(struct xgbe_prv_data *);
783 void (*exit)(struct xgbe_prv_data *);
784
785 /* Perform start/stop specific actions */
786 int (*reset)(struct xgbe_prv_data *);
787 int (*start)(struct xgbe_prv_data *);
788 void (*stop)(struct xgbe_prv_data *);
789
790 /* Return the link status */
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -0600791 int (*link_status)(struct xgbe_prv_data *, int *);
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500792
793 /* Indicate if a particular speed is valid */
794 bool (*valid_speed)(struct xgbe_prv_data *, int);
795
796 /* Check if the specified mode can/should be used */
797 bool (*use_mode)(struct xgbe_prv_data *, enum xgbe_mode);
798 /* Switch the PHY into various modes */
799 void (*set_mode)(struct xgbe_prv_data *, enum xgbe_mode);
800 /* Retrieve mode needed for a specific speed */
801 enum xgbe_mode (*get_mode)(struct xgbe_prv_data *, int);
802 /* Retrieve new/next mode when trying to auto-negotiate */
803 enum xgbe_mode (*switch_mode)(struct xgbe_prv_data *);
804 /* Retrieve current mode */
805 enum xgbe_mode (*cur_mode)(struct xgbe_prv_data *);
806
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500807 /* Retrieve current auto-negotiation mode */
808 enum xgbe_an_mode (*an_mode)(struct xgbe_prv_data *);
809
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -0600810 /* Configure auto-negotiation settings */
811 int (*an_config)(struct xgbe_prv_data *);
812
Lendacky, Thomasd7445d12016-11-10 17:11:41 -0600813 /* Set/override auto-negotiation advertisement settings */
814 unsigned int (*an_advertising)(struct xgbe_prv_data *);
815
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500816 /* Process results of auto-negotiation */
817 enum xgbe_mode (*an_outcome)(struct xgbe_prv_data *);
818
819 /* Pre/Post KR training enablement support */
820 void (*kr_training_pre)(struct xgbe_prv_data *);
821 void (*kr_training_post)(struct xgbe_prv_data *);
822};
823
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500824struct xgbe_phy_if {
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500825 /* For PHY setup/teardown */
826 int (*phy_init)(struct xgbe_prv_data *);
827 void (*phy_exit)(struct xgbe_prv_data *);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500828
829 /* For PHY support when setting device up/down */
830 int (*phy_reset)(struct xgbe_prv_data *);
831 int (*phy_start)(struct xgbe_prv_data *);
832 void (*phy_stop)(struct xgbe_prv_data *);
833
834 /* For PHY support while device is up */
835 void (*phy_status)(struct xgbe_prv_data *);
836 int (*phy_config_aneg)(struct xgbe_prv_data *);
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500837
838 /* For PHY settings validation */
839 bool (*phy_valid_speed)(struct xgbe_prv_data *, int);
840
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600841 /* For single interrupt support */
Lendacky, Thomas85b85c82017-06-28 13:42:42 -0500842 irqreturn_t (*an_isr)(struct xgbe_prv_data *);
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600843
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500844 /* PHY implementation specific services */
845 struct xgbe_phy_impl_if phy_impl;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500846};
847
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -0600848struct xgbe_i2c_if {
849 /* For initial I2C setup */
850 int (*i2c_init)(struct xgbe_prv_data *);
851
852 /* For I2C support when setting device up/down */
853 int (*i2c_start)(struct xgbe_prv_data *);
854 void (*i2c_stop)(struct xgbe_prv_data *);
855
856 /* For performing I2C operations */
857 int (*i2c_xfer)(struct xgbe_prv_data *, struct xgbe_i2c_op *);
858
859 /* For single interrupt support */
Lendacky, Thomas85b85c82017-06-28 13:42:42 -0500860 irqreturn_t (*i2c_isr)(struct xgbe_prv_data *);
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -0600861};
862
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500863struct xgbe_desc_if {
864 int (*alloc_ring_resources)(struct xgbe_prv_data *);
865 void (*free_ring_resources)(struct xgbe_prv_data *);
866 int (*map_tx_skb)(struct xgbe_channel *, struct sk_buff *);
Lendacky, Thomas270894e2015-01-16 12:46:50 -0600867 int (*map_rx_buffer)(struct xgbe_prv_data *, struct xgbe_ring *,
868 struct xgbe_ring_data *);
Lendacky, Thomas08dcc472014-11-04 16:06:44 -0600869 void (*unmap_rdata)(struct xgbe_prv_data *, struct xgbe_ring_data *);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500870 void (*wrapper_tx_desc_init)(struct xgbe_prv_data *);
871 void (*wrapper_rx_desc_init)(struct xgbe_prv_data *);
872};
873
874/* This structure contains flags that indicate what hardware features
875 * or configurations are present in the device.
876 */
877struct xgbe_hw_features {
Lendacky, Thomasa9a4a2d2014-08-29 13:16:50 -0500878 /* HW Version */
879 unsigned int version;
880
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500881 /* HW Feature Register0 */
882 unsigned int gmii; /* 1000 Mbps support */
883 unsigned int vlhash; /* VLAN Hash Filter */
884 unsigned int sma; /* SMA(MDIO) Interface */
885 unsigned int rwk; /* PMT remote wake-up packet */
886 unsigned int mgk; /* PMT magic packet */
887 unsigned int mmc; /* RMON module */
888 unsigned int aoe; /* ARP Offload */
Joe Perchesdbedd442015-03-06 20:49:12 -0800889 unsigned int ts; /* IEEE 1588-2008 Advanced Timestamp */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500890 unsigned int eee; /* Energy Efficient Ethernet */
891 unsigned int tx_coe; /* Tx Checksum Offload */
892 unsigned int rx_coe; /* Rx Checksum Offload */
893 unsigned int addn_mac; /* Additional MAC Addresses */
894 unsigned int ts_src; /* Timestamp Source */
895 unsigned int sa_vlan_ins; /* Source Address or VLAN Insertion */
896
897 /* HW Feature Register1 */
898 unsigned int rx_fifo_size; /* MTL Receive FIFO Size */
899 unsigned int tx_fifo_size; /* MTL Transmit FIFO Size */
900 unsigned int adv_ts_hi; /* Advance Timestamping High Word */
Lendacky, Thomas386d3252015-03-20 11:50:22 -0500901 unsigned int dma_width; /* DMA width */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500902 unsigned int dcb; /* DCB Feature */
903 unsigned int sph; /* Split Header Feature */
904 unsigned int tso; /* TCP Segmentation Offload */
905 unsigned int dma_debug; /* DMA Debug Registers */
906 unsigned int rss; /* Receive Side Scaling */
Lendacky, Thomasfca2d992014-07-29 08:57:55 -0500907 unsigned int tc_cnt; /* Number of Traffic Classes */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500908 unsigned int hash_table_size; /* Hash Table Size */
909 unsigned int l3l4_filter_num; /* Number of L3-L4 Filters */
910
911 /* HW Feature Register2 */
912 unsigned int rx_q_cnt; /* Number of MTL Receive Queues */
913 unsigned int tx_q_cnt; /* Number of MTL Transmit Queues */
914 unsigned int rx_ch_cnt; /* Number of DMA Receive Channels */
915 unsigned int tx_ch_cnt; /* Number of DMA Transmit Channels */
916 unsigned int pps_out_num; /* Number of PPS outputs */
917 unsigned int aux_snap_num; /* Number of Aux snapshot inputs */
918};
919
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500920struct xgbe_version_data {
921 void (*init_function_ptrs_phy_impl)(struct xgbe_phy_if *);
Lendacky, Thomasb03a4a62016-11-03 13:18:56 -0500922 enum xgbe_xpcs_access xpcs_access;
Lendacky, Thomase5a20b92016-11-03 13:19:07 -0500923 unsigned int mmc_64bit;
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -0500924 unsigned int tx_max_fifo_size;
925 unsigned int rx_max_fifo_size;
Lendacky, Thomasaba97772016-11-10 17:09:45 -0600926 unsigned int tx_tstamp_workaround;
Lendacky, Thomase78332b2016-11-10 17:10:26 -0600927 unsigned int ecc_support;
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -0600928 unsigned int i2c_support;
Lendacky, Thomas85b85c82017-06-28 13:42:42 -0500929 unsigned int irq_reissue_support;
Lendacky, Thomas6f595952017-06-28 13:43:26 -0500930 unsigned int tx_desc_prefetch;
931 unsigned int rx_desc_prefetch;
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500932};
933
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500934struct xgbe_prv_data {
935 struct net_device *netdev;
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600936 struct pci_dev *pcidev;
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -0500937 struct platform_device *platdev;
Lendacky, Thomas82a19032015-01-16 12:47:16 -0600938 struct acpi_device *adev;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500939 struct device *dev;
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -0500940 struct platform_device *phy_platdev;
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500941 struct device *phy_dev;
942
943 /* Version related data */
944 struct xgbe_version_data *vdata;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500945
Lendacky, Thomas82a19032015-01-16 12:47:16 -0600946 /* ACPI or DT flag */
947 unsigned int use_acpi;
948
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500949 /* XGMAC/XPCS related mmio registers */
950 void __iomem *xgmac_regs; /* XGMAC CSRs */
951 void __iomem *xpcs_regs; /* XPCS MMD registers */
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500952 void __iomem *rxtx_regs; /* SerDes Rx/Tx CSRs */
953 void __iomem *sir0_regs; /* SerDes integration registers (1/2) */
954 void __iomem *sir1_regs; /* SerDes integration registers (2/2) */
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600955 void __iomem *xprop_regs; /* XGBE property registers */
956 void __iomem *xi2c_regs; /* XGBE I2C CSRs */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500957
958 /* Overall device lock */
959 spinlock_t lock;
960
Lendacky, Thomasced3fca2016-02-17 11:49:28 -0600961 /* XPCS indirect addressing lock */
962 spinlock_t xpcs_lock;
Lendacky, Thomas4eccbfc2017-01-20 12:14:03 -0600963 unsigned int xpcs_window_def_reg;
964 unsigned int xpcs_window_sel_reg;
Lendacky, Thomasb03a4a62016-11-03 13:18:56 -0500965 unsigned int xpcs_window;
966 unsigned int xpcs_window_size;
967 unsigned int xpcs_window_mask;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500968
Lendacky, Thomas5b9dfe22014-11-04 16:07:02 -0600969 /* RSS addressing mutex */
970 struct mutex rss_mutex;
971
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500972 /* Flags representing xgbe_state */
973 unsigned long dev_state;
974
Lendacky, Thomase78332b2016-11-10 17:10:26 -0600975 /* ECC support */
976 unsigned long tx_sec_period;
977 unsigned long tx_ded_period;
978 unsigned long rx_sec_period;
979 unsigned long rx_ded_period;
980 unsigned long desc_sec_period;
981 unsigned long desc_ded_period;
982
983 unsigned int tx_sec_count;
984 unsigned int tx_ded_count;
985 unsigned int rx_sec_count;
986 unsigned int rx_ded_count;
987 unsigned int desc_ded_count;
988 unsigned int desc_sec_count;
989
Lendacky, Thomas9227dc52014-11-04 16:06:56 -0600990 int dev_irq;
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600991 int ecc_irq;
992 int i2c_irq;
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -0500993 int channel_irq[XGBE_MAX_DMA_CHANNELS];
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500994
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600995 unsigned int per_channel_irq;
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600996 unsigned int irq_count;
997 unsigned int channel_irq_count;
Lendacky, Thomas4c70dd82016-11-10 17:10:17 -0600998 unsigned int channel_irq_mode;
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600999
Lendacky, Thomase78332b2016-11-10 17:10:26 -06001000 char ecc_name[IFNAMSIZ + 32];
1001
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001002 struct xgbe_hw_if hw_if;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001003 struct xgbe_phy_if phy_if;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001004 struct xgbe_desc_if desc_if;
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -06001005 struct xgbe_i2c_if i2c_if;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001006
Lendacky, Thomascfa50c72014-07-02 13:04:57 -05001007 /* AXI DMA settings */
Lendacky, Thomas82a19032015-01-16 12:47:16 -06001008 unsigned int coherent;
Lendacky, Thomas99167162017-06-28 13:43:09 -05001009 unsigned int arcr;
1010 unsigned int awcr;
Lendacky, Thomas6f595952017-06-28 13:43:26 -05001011 unsigned int awarcr;
Lendacky, Thomascfa50c72014-07-02 13:04:57 -05001012
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001013 /* Service routine support */
1014 struct workqueue_struct *dev_workqueue;
1015 struct work_struct service_work;
1016 struct timer_list service_timer;
1017
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001018 /* Rings for Tx/Rx on a DMA channel */
Lendacky, Thomas18f9f0a2017-06-28 13:42:51 -05001019 struct xgbe_channel *channel[XGBE_MAX_DMA_CHANNELS];
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -05001020 unsigned int tx_max_channel_count;
1021 unsigned int rx_max_channel_count;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001022 unsigned int channel_count;
1023 unsigned int tx_ring_count;
1024 unsigned int tx_desc_count;
1025 unsigned int rx_ring_count;
1026 unsigned int rx_desc_count;
1027
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -05001028 unsigned int tx_max_q_count;
1029 unsigned int rx_max_q_count;
Lendacky, Thomas853eb162014-07-29 08:57:31 -05001030 unsigned int tx_q_count;
1031 unsigned int rx_q_count;
1032
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001033 /* Tx/Rx common settings */
Lendacky, Thomas7e1e6b82017-06-28 13:43:18 -05001034 unsigned int blen;
1035 unsigned int pbl;
Lendacky, Thomas6f595952017-06-28 13:43:26 -05001036 unsigned int aal;
1037 unsigned int rd_osr_limit;
1038 unsigned int wr_osr_limit;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001039
1040 /* Tx settings */
1041 unsigned int tx_sf_mode;
1042 unsigned int tx_threshold;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001043 unsigned int tx_osp_mode;
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -05001044 unsigned int tx_max_fifo_size;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001045
1046 /* Rx settings */
1047 unsigned int rx_sf_mode;
1048 unsigned int rx_threshold;
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -05001049 unsigned int rx_max_fifo_size;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001050
1051 /* Tx coalescing settings */
1052 unsigned int tx_usecs;
1053 unsigned int tx_frames;
1054
1055 /* Rx coalescing settings */
1056 unsigned int rx_riwt;
Lendacky, Thomas4a57ebc2015-03-20 11:50:34 -05001057 unsigned int rx_usecs;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001058 unsigned int rx_frames;
1059
Lendacky, Thomas08dcc472014-11-04 16:06:44 -06001060 /* Current Rx buffer size */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001061 unsigned int rx_buf_size;
1062
1063 /* Flow control settings */
1064 unsigned int pause_autoneg;
1065 unsigned int tx_pause;
1066 unsigned int rx_pause;
Lendacky, Thomas43e0dcf2016-11-03 13:18:16 -05001067 unsigned int rx_rfa[XGBE_MAX_QUEUES];
1068 unsigned int rx_rfd[XGBE_MAX_QUEUES];
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001069
Lendacky, Thomas5b9dfe22014-11-04 16:07:02 -06001070 /* Receive Side Scaling settings */
1071 u8 rss_key[XGBE_RSS_HASH_KEY_SIZE];
1072 u32 rss_table[XGBE_RSS_MAX_TABLE_SIZE];
1073 u32 rss_options;
1074
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001075 /* Netdev related settings */
Lendacky, Thomas82a19032015-01-16 12:47:16 -06001076 unsigned char mac_addr[ETH_ALEN];
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001077 netdev_features_t netdev_features;
1078 struct napi_struct napi;
1079 struct xgbe_mmc_stats mmc_stats;
Lendacky, Thomas5452b2d2015-05-14 11:43:57 -05001080 struct xgbe_ext_stats ext_stats;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001081
Lendacky, Thomas801c62d2014-06-24 16:19:24 -05001082 /* Filtering support */
1083 unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
1084
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -05001085 /* Device clocks */
1086 struct clk *sysclk;
Lendacky, Thomas82a19032015-01-16 12:47:16 -06001087 unsigned long sysclk_rate;
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -05001088 struct clk *ptpclk;
Lendacky, Thomas82a19032015-01-16 12:47:16 -06001089 unsigned long ptpclk_rate;
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -05001090
1091 /* Timestamp support */
1092 spinlock_t tstamp_lock;
1093 struct ptp_clock_info ptp_clock_info;
1094 struct ptp_clock *ptp_clock;
1095 struct hwtstamp_config tstamp_config;
1096 struct cyclecounter tstamp_cc;
1097 struct timecounter tstamp_tc;
1098 unsigned int tstamp_addend;
1099 struct work_struct tx_tstamp_work;
1100 struct sk_buff *tx_tstamp_skb;
1101 u64 tx_tstamp;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001102
Lendacky, Thomasfca2d992014-07-29 08:57:55 -05001103 /* DCB support */
1104 struct ieee_ets *ets;
1105 struct ieee_pfc *pfc;
1106 unsigned int q2tc_map[XGBE_MAX_QUEUES];
1107 unsigned int prio2q_map[IEEE_8021QAZ_MAX_TCS];
Lendacky, Thomas43e0dcf2016-11-03 13:18:16 -05001108 unsigned int pfcq[XGBE_MAX_QUEUES];
1109 unsigned int pfc_rfa;
Lendacky, Thomasb3b71592016-02-17 11:49:08 -06001110 u8 num_tcs;
Lendacky, Thomasfca2d992014-07-29 08:57:55 -05001111
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001112 /* Hardware features of the device */
1113 struct xgbe_hw_features hw_feat;
1114
Lendacky, Thomase78332b2016-11-10 17:10:26 -06001115 /* Device work structures */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001116 struct work_struct restart_work;
Lendacky, Thomase78332b2016-11-10 17:10:26 -06001117 struct work_struct stopdev_work;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001118
1119 /* Keeps track of power mode */
1120 unsigned int power_down;
1121
Lendacky, Thomas34bf65d2015-05-14 11:44:03 -05001122 /* Network interface message level setting */
1123 u32 msg_enable;
1124
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001125 /* Current PHY settings */
1126 phy_interface_t phy_mode;
1127 int phy_link;
1128 int phy_speed;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001129
1130 /* MDIO/PHY related settings */
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001131 unsigned int phy_started;
1132 void *phy_data;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001133 struct xgbe_phy phy;
1134 int mdio_mmd;
1135 unsigned long link_check;
Lendacky, Thomas732f2ab2016-11-10 17:11:14 -06001136 struct completion mdio_complete;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001137
Lendacky, Thomasd7445d12016-11-10 17:11:41 -06001138 unsigned int kr_redrv;
1139
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001140 char an_name[IFNAMSIZ + 32];
1141 struct workqueue_struct *an_workqueue;
1142
1143 int an_irq;
1144 struct work_struct an_irq_work;
1145
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001146 /* Auto-negotiation state machine support */
Lendacky, Thomasced3fca2016-02-17 11:49:28 -06001147 unsigned int an_int;
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -05001148 unsigned int an_status;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001149 struct mutex an_mutex;
1150 enum xgbe_an an_result;
1151 enum xgbe_an an_state;
1152 enum xgbe_rx kr_state;
1153 enum xgbe_rx kx_state;
1154 struct work_struct an_work;
1155 unsigned int an_supported;
1156 unsigned int parallel_detect;
1157 unsigned int fec_ability;
1158 unsigned long an_start;
Lendacky, Thomasa64def42016-11-03 13:18:38 -05001159 enum xgbe_an_mode an_mode;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001160
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -06001161 /* I2C support */
1162 struct xgbe_i2c i2c;
1163 struct mutex i2c_mutex;
1164 struct completion i2c_complete;
1165 char i2c_name[IFNAMSIZ + 32];
1166
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001167 unsigned int lpm_ctrl; /* CTRL1 for resume */
1168
Lendacky, Thomas85b85c82017-06-28 13:42:42 -05001169 unsigned int isr_as_tasklet;
1170 struct tasklet_struct tasklet_dev;
1171 struct tasklet_struct tasklet_ecc;
1172 struct tasklet_struct tasklet_i2c;
1173 struct tasklet_struct tasklet_an;
1174
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001175#ifdef CONFIG_DEBUG_FS
1176 struct dentry *xgbe_debugfs;
1177
1178 unsigned int debugfs_xgmac_reg;
1179
1180 unsigned int debugfs_xpcs_mmd;
1181 unsigned int debugfs_xpcs_reg;
Lendacky, Thomas47f164d2016-11-10 17:09:55 -06001182
1183 unsigned int debugfs_xprop_reg;
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -06001184
1185 unsigned int debugfs_xi2c_reg;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001186#endif
1187};
1188
1189/* Function prototypes*/
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -05001190struct xgbe_prv_data *xgbe_alloc_pdata(struct device *);
1191void xgbe_free_pdata(struct xgbe_prv_data *);
1192void xgbe_set_counts(struct xgbe_prv_data *);
1193int xgbe_config_netdev(struct xgbe_prv_data *);
1194void xgbe_deconfig_netdev(struct xgbe_prv_data *);
1195
1196int xgbe_platform_init(void);
1197void xgbe_platform_exit(void);
Lendacky, Thomas47f164d2016-11-10 17:09:55 -06001198#ifdef CONFIG_PCI
1199int xgbe_pci_init(void);
1200void xgbe_pci_exit(void);
1201#else
1202static inline int xgbe_pci_init(void) { return 0; }
1203static inline void xgbe_pci_exit(void) { }
1204#endif
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001205
1206void xgbe_init_function_ptrs_dev(struct xgbe_hw_if *);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001207void xgbe_init_function_ptrs_phy(struct xgbe_phy_if *);
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001208void xgbe_init_function_ptrs_phy_v1(struct xgbe_phy_if *);
Lendacky, Thomas47f164d2016-11-10 17:09:55 -06001209void xgbe_init_function_ptrs_phy_v2(struct xgbe_phy_if *);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001210void xgbe_init_function_ptrs_desc(struct xgbe_desc_if *);
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -06001211void xgbe_init_function_ptrs_i2c(struct xgbe_i2c_if *);
stephen hemmingerce0b15d2016-08-31 08:57:36 -07001212const struct net_device_ops *xgbe_get_netdev_ops(void);
1213const struct ethtool_ops *xgbe_get_ethtool_ops(void);
1214
Lendacky, Thomasfca2d992014-07-29 08:57:55 -05001215#ifdef CONFIG_AMD_XGBE_DCB
1216const struct dcbnl_rtnl_ops *xgbe_get_dcbnl_ops(void);
1217#endif
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001218
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -05001219void xgbe_ptp_register(struct xgbe_prv_data *);
1220void xgbe_ptp_unregister(struct xgbe_prv_data *);
Lendacky, Thomas34bf65d2015-05-14 11:44:03 -05001221void xgbe_dump_tx_desc(struct xgbe_prv_data *, struct xgbe_ring *,
1222 unsigned int, unsigned int, unsigned int);
1223void xgbe_dump_rx_desc(struct xgbe_prv_data *, struct xgbe_ring *,
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001224 unsigned int);
1225void xgbe_print_pkt(struct net_device *, struct sk_buff *, bool);
1226void xgbe_get_all_hw_features(struct xgbe_prv_data *);
1227int xgbe_powerup(struct net_device *, unsigned int);
1228int xgbe_powerdown(struct net_device *, unsigned int);
1229void xgbe_init_rx_coalesce(struct xgbe_prv_data *);
1230void xgbe_init_tx_coalesce(struct xgbe_prv_data *);
1231
1232#ifdef CONFIG_DEBUG_FS
1233void xgbe_debugfs_init(struct xgbe_prv_data *);
1234void xgbe_debugfs_exit(struct xgbe_prv_data *);
1235#else
1236static inline void xgbe_debugfs_init(struct xgbe_prv_data *pdata) {}
1237static inline void xgbe_debugfs_exit(struct xgbe_prv_data *pdata) {}
1238#endif /* CONFIG_DEBUG_FS */
1239
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001240/* NOTE: Uncomment for function trace log messages in KERNEL LOG */
1241#if 0
1242#define YDEBUG
1243#define YDEBUG_MDIO
1244#endif
1245
1246/* For debug prints */
1247#ifdef YDEBUG
1248#define DBGPR(x...) pr_alert(x)
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001249#else
1250#define DBGPR(x...) do { } while (0)
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001251#endif
1252
1253#ifdef YDEBUG_MDIO
1254#define DBGPR_MDIO(x...) pr_alert(x)
1255#else
1256#define DBGPR_MDIO(x...) do { } while (0)
1257#endif
1258
1259#endif