blob: 2834961a9c2562802dcc211d1e3d9d35c880b652 [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, Thomasc5aa9e32014-06-05 09:15:06 -0500131
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500132#define XGBE_DRV_NAME "amd-xgbe"
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500133#define XGBE_DRV_VERSION "1.0.3"
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500134#define XGBE_DRV_DESC "AMD 10 Gigabit Ethernet Driver"
135
136/* Descriptor related defines */
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500137#define XGBE_TX_DESC_CNT 512
138#define XGBE_TX_DESC_MIN_FREE (XGBE_TX_DESC_CNT >> 3)
139#define XGBE_TX_DESC_MAX_PROC (XGBE_TX_DESC_CNT >> 1)
140#define XGBE_RX_DESC_CNT 512
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500141
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500142#define XGBE_TX_MAX_BUF_SIZE (0x3fff & ~(64 - 1))
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500143
Masahiro Yamadae1c05062015-07-07 10:14:59 +0900144/* Descriptors required for maximum contiguous TSO/GSO packet */
Lendacky, Thomas16958a22014-11-20 11:04:08 -0600145#define XGBE_TX_MAX_SPLIT ((GSO_MAX_SIZE / XGBE_TX_MAX_BUF_SIZE) + 1)
146
147/* Maximum possible descriptors needed for an SKB:
148 * - Maximum number of SKB frags
149 * - Maximum descriptors for contiguous TSO/GSO packet
150 * - Possible context descriptor
151 * - Possible TSO header descriptor
152 */
153#define XGBE_TX_MAX_DESCS (MAX_SKB_FRAGS + XGBE_TX_MAX_SPLIT + 2)
154
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500155#define XGBE_RX_MIN_BUF_SIZE (ETH_FRAME_LEN + ETH_FCS_LEN + VLAN_HLEN)
156#define XGBE_RX_BUF_ALIGN 64
Lendacky, Thomas08dcc472014-11-04 16:06:44 -0600157#define XGBE_SKB_ALLOC_SIZE 256
Lendacky, Thomas174fd252014-11-04 16:06:50 -0600158#define XGBE_SPH_HDSMS_SIZE 2 /* Keep in sync with SKB_ALLOC_SIZE */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500159
Lendacky, Thomasd5c48582014-06-09 09:19:32 -0500160#define XGBE_MAX_DMA_CHANNELS 16
Lendacky, Thomasfca2d992014-07-29 08:57:55 -0500161#define XGBE_MAX_QUEUES 16
Lendacky, Thomas43e0dcf2016-11-03 13:18:16 -0500162#define XGBE_PRIORITY_QUEUES 8
Lendacky, Thomas4b8acdf2016-11-03 13:19:17 -0500163#define XGBE_DMA_STOP_TIMEOUT 1
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500164
165/* DMA cache settings - Outer sharable, write-back, write-allocate */
Lendacky, Thomascfa50c72014-07-02 13:04:57 -0500166#define XGBE_DMA_OS_AXDOMAIN 0x2
167#define XGBE_DMA_OS_ARCACHE 0xb
168#define XGBE_DMA_OS_AWCACHE 0xf
169
170/* DMA cache settings - System, no caches used */
171#define XGBE_DMA_SYS_AXDOMAIN 0x3
172#define XGBE_DMA_SYS_ARCACHE 0x0
173#define XGBE_DMA_SYS_AWCACHE 0x0
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500174
Lendacky, Thomas4c70dd82016-11-10 17:10:17 -0600175/* DMA channel interrupt modes */
176#define XGBE_IRQ_MODE_EDGE 0
177#define XGBE_IRQ_MODE_LEVEL 1
178
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500179#define XGBE_DMA_INTERRUPT_MASK 0x31c7
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500180
181#define XGMAC_MIN_PACKET 60
182#define XGMAC_STD_PACKET_MTU 1500
183#define XGMAC_MAX_STD_PACKET 1518
184#define XGMAC_JUMBO_PACKET_MTU 9000
185#define XGMAC_MAX_JUMBO_PACKET 9018
Lendacky, Thomas43e0dcf2016-11-03 13:18:16 -0500186#define XGMAC_ETH_PREAMBLE (12 + 8) /* Inter-frame gap + preamble */
187
188#define XGMAC_PFC_DATA_LEN 46
189#define XGMAC_PFC_DELAYS 14000
190
191#define XGMAC_PRIO_QUEUES(_cnt) \
192 min_t(unsigned int, IEEE_8021QAZ_MAX_TCS, (_cnt))
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500193
Lendacky, Thomas82a19032015-01-16 12:47:16 -0600194/* Common property names */
195#define XGBE_MAC_ADDR_PROPERTY "mac-address"
196#define XGBE_PHY_MODE_PROPERTY "phy-mode"
197#define XGBE_DMA_IRQS_PROPERTY "amd,per-channel-interrupt"
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500198#define XGBE_SPEEDSET_PROPERTY "amd,speed-set"
Lendacky, Thomas82a19032015-01-16 12:47:16 -0600199
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500200/* Device-tree clock names */
201#define XGBE_DMA_CLOCK "dma_clk"
202#define XGBE_PTP_CLOCK "ptp_clk"
Lendacky, Thomas82a19032015-01-16 12:47:16 -0600203
204/* ACPI property names */
205#define XGBE_ACPI_DMA_FREQ "amd,dma-freq"
206#define XGBE_ACPI_PTP_FREQ "amd,ptp-freq"
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500207
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600208/* PCI BAR mapping */
209#define XGBE_XGMAC_BAR 0
210#define XGBE_XPCS_BAR 1
211#define XGBE_MAC_PROP_OFFSET 0x1d000
212#define XGBE_I2C_CTRL_OFFSET 0x1e000
213
Tom Lendackye7537742017-01-13 09:05:53 +0100214/* PCI MSI/MSIx support */
215#define XGBE_MSI_BASE_COUNT 4
216#define XGBE_MSI_MIN_COUNT (XGBE_MSI_BASE_COUNT + 1)
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600217
218/* PCI clock frequencies */
219#define XGBE_V2_DMA_CLOCK_FREQ 500000000 /* 500 MHz */
220#define XGBE_V2_PTP_CLOCK_FREQ 125000000 /* 125 MHz */
221
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500222/* Timestamp support - values based on 50MHz PTP clock
223 * 50MHz => 20 nsec
224 */
225#define XGBE_TSTAMP_SSINC 20
226#define XGBE_TSTAMP_SNSINC 0
227
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500228/* Driver PMT macros */
229#define XGMAC_DRIVER_CONTEXT 1
230#define XGMAC_IOCTL_CONTEXT 2
231
Lendacky, Thomas43e0dcf2016-11-03 13:18:16 -0500232#define XGMAC_FIFO_MIN_ALLOC 2048
233#define XGMAC_FIFO_UNIT 256
234#define XGMAC_FIFO_ALIGN(_x) \
235 (((_x) + XGMAC_FIFO_UNIT - 1) & ~(XGMAC_FIFO_UNIT - 1))
236#define XGMAC_FIFO_FC_OFF 2048
237#define XGMAC_FIFO_FC_MIN 4096
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500238
Lendacky, Thomasfca2d992014-07-29 08:57:55 -0500239#define XGBE_TC_MIN_QUANTUM 10
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500240
241/* Helper macro for descriptor handling
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500242 * Always use XGBE_GET_DESC_DATA to access the descriptor data
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500243 * since the index is free-running and needs to be and-ed
244 * with the descriptor count value of the ring to index to
245 * the proper descriptor data.
246 */
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500247#define XGBE_GET_DESC_DATA(_ring, _idx) \
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500248 ((_ring)->rdata + \
249 ((_idx) & ((_ring)->rdesc_count - 1)))
250
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500251/* Default coalescing parameters */
Lendacky, Thomasc635eaa2015-03-20 11:50:28 -0500252#define XGMAC_INIT_DMA_TX_USECS 1000
Lendacky, Thomas9867e8f2014-07-02 13:04:46 -0500253#define XGMAC_INIT_DMA_TX_FRAMES 25
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500254
255#define XGMAC_MAX_DMA_RIWT 0xff
Lendacky, Thomas9867e8f2014-07-02 13:04:46 -0500256#define XGMAC_INIT_DMA_RX_USECS 30
257#define XGMAC_INIT_DMA_RX_FRAMES 25
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500258
259/* Flow control queue count */
260#define XGMAC_MAX_FLOW_CONTROL_QUEUES 8
261
Lendacky, Thomas43e0dcf2016-11-03 13:18:16 -0500262/* Flow control threshold units */
263#define XGMAC_FLOW_CONTROL_UNIT 512
264#define XGMAC_FLOW_CONTROL_ALIGN(_x) \
265 (((_x) + XGMAC_FLOW_CONTROL_UNIT - 1) & ~(XGMAC_FLOW_CONTROL_UNIT - 1))
266#define XGMAC_FLOW_CONTROL_VALUE(_x) \
267 (((_x) < 1024) ? 0 : ((_x) / XGMAC_FLOW_CONTROL_UNIT) - 2)
268#define XGMAC_FLOW_CONTROL_MAX 33280
269
Lendacky, Thomasb85e4d82014-06-24 16:19:29 -0500270/* Maximum MAC address hash table size (256 bits = 8 bytes) */
271#define XGBE_MAC_HASH_TABLE_SIZE 8
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500272
Lendacky, Thomas5b9dfe22014-11-04 16:07:02 -0600273/* Receive Side Scaling */
274#define XGBE_RSS_HASH_KEY_SIZE 40
275#define XGBE_RSS_MAX_TABLE_SIZE 256
276#define XGBE_RSS_LOOKUP_TABLE_TYPE 0
277#define XGBE_RSS_HASH_KEY_TYPE 1
278
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500279/* Auto-negotiation */
280#define XGBE_AN_MS_TIMEOUT 500
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500281#define XGBE_LINK_TIMEOUT 5
282
283#define XGBE_SGMII_AN_LINK_STATUS BIT(1)
284#define XGBE_SGMII_AN_LINK_SPEED (BIT(2) | BIT(3))
285#define XGBE_SGMII_AN_LINK_SPEED_100 0x04
286#define XGBE_SGMII_AN_LINK_SPEED_1000 0x08
287#define XGBE_SGMII_AN_LINK_DUPLEX BIT(4)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500288
Lendacky, Thomase78332b2016-11-10 17:10:26 -0600289/* ECC correctable error notification window (seconds) */
290#define XGBE_ECC_LIMIT 60
291
Lendacky, Thomas732f2ab2016-11-10 17:11:14 -0600292/* MDIO port types */
293#define XGMAC_MAX_C22_PORT 3
294
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500295struct xgbe_prv_data;
296
297struct xgbe_packet_data {
Lendacky, Thomas16958a22014-11-20 11:04:08 -0600298 struct sk_buff *skb;
299
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500300 unsigned int attributes;
301
302 unsigned int errors;
303
304 unsigned int rdesc_count;
305 unsigned int length;
306
307 unsigned int header_len;
308 unsigned int tcp_header_len;
309 unsigned int tcp_payload_len;
310 unsigned short mss;
311
312 unsigned short vlan_ctag;
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500313
314 u64 rx_tstamp;
Lendacky, Thomas5b9dfe22014-11-04 16:07:02 -0600315
316 u32 rss_hash;
317 enum pkt_hash_types rss_hash_type;
Lendacky, Thomas5fb4b862014-11-20 11:03:50 -0600318
319 unsigned int tx_packets;
320 unsigned int tx_bytes;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500321};
322
323/* Common Rx and Tx descriptor mapping */
324struct xgbe_ring_desc {
Lendacky, Thomas5226cfc2014-11-12 10:37:49 -0600325 __le32 desc0;
326 __le32 desc1;
327 __le32 desc2;
328 __le32 desc3;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500329};
330
Lendacky, Thomas08dcc472014-11-04 16:06:44 -0600331/* Page allocation related values */
332struct xgbe_page_alloc {
333 struct page *pages;
334 unsigned int pages_len;
335 unsigned int pages_offset;
336
337 dma_addr_t pages_dma;
338};
339
Lendacky, Thomas174fd252014-11-04 16:06:50 -0600340/* Ring entry buffer data */
341struct xgbe_buffer_data {
342 struct xgbe_page_alloc pa;
343 struct xgbe_page_alloc pa_unmap;
344
Lendacky, Thomascfbfd862015-07-06 11:57:37 -0500345 dma_addr_t dma_base;
346 unsigned long dma_off;
Lendacky, Thomas174fd252014-11-04 16:06:50 -0600347 unsigned int dma_len;
348};
349
Lendacky, Thomasc9f140e2014-11-20 11:03:44 -0600350/* Tx-related ring data */
351struct xgbe_tx_ring_data {
Lendacky, Thomas5fb4b862014-11-20 11:03:50 -0600352 unsigned int packets; /* BQL packet count */
353 unsigned int bytes; /* BQL byte count */
Lendacky, Thomasc9f140e2014-11-20 11:03:44 -0600354};
355
356/* Rx-related ring data */
357struct xgbe_rx_ring_data {
358 struct xgbe_buffer_data hdr; /* Header locations */
359 struct xgbe_buffer_data buf; /* Payload locations */
360
361 unsigned short hdr_len; /* Length of received header */
362 unsigned short len; /* Length of received packet */
363};
364
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500365/* Structure used to hold information related to the descriptor
366 * and the packet associated with the descriptor (always use
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500367 * use the XGBE_GET_DESC_DATA macro to access this data from the ring)
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500368 */
369struct xgbe_ring_data {
370 struct xgbe_ring_desc *rdesc; /* Virtual address of descriptor */
371 dma_addr_t rdesc_dma; /* DMA address of descriptor */
372
373 struct sk_buff *skb; /* Virtual address of SKB */
374 dma_addr_t skb_dma; /* DMA address of SKB data */
375 unsigned int skb_dma_len; /* Length of SKB DMA area */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500376
Lendacky, Thomasc9f140e2014-11-20 11:03:44 -0600377 struct xgbe_tx_ring_data tx; /* Tx-related data */
378 struct xgbe_rx_ring_data rx; /* Rx-related data */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500379
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500380 unsigned int mapped_as_page;
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500381
382 /* Incomplete receive save location. If the budget is exhausted
383 * or the last descriptor (last normal descriptor or a following
384 * context descriptor) has not been DMA'd yet the current state
385 * of the receive processing needs to be saved.
386 */
387 unsigned int state_saved;
388 struct {
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500389 struct sk_buff *skb;
390 unsigned int len;
391 unsigned int error;
392 } state;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500393};
394
395struct xgbe_ring {
396 /* Ring lock - used just for TX rings at the moment */
397 spinlock_t lock;
398
399 /* Per packet related information */
400 struct xgbe_packet_data packet_data;
401
402 /* Virtual/DMA addresses and count of allocated descriptor memory */
403 struct xgbe_ring_desc *rdesc;
404 dma_addr_t rdesc_dma;
405 unsigned int rdesc_count;
406
407 /* Array of descriptor data corresponding the descriptor memory
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500408 * (always use the XGBE_GET_DESC_DATA macro to access this data)
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500409 */
410 struct xgbe_ring_data *rdata;
411
Lendacky, Thomas08dcc472014-11-04 16:06:44 -0600412 /* Page allocation for RX buffers */
Lendacky, Thomas174fd252014-11-04 16:06:50 -0600413 struct xgbe_page_alloc rx_hdr_pa;
414 struct xgbe_page_alloc rx_buf_pa;
Lendacky, Thomas08dcc472014-11-04 16:06:44 -0600415
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500416 /* Ring index values
417 * cur - Tx: index of descriptor to be used for current transfer
418 * Rx: index of descriptor to check for packet availability
419 * dirty - Tx: index of descriptor to check for transfer complete
Lendacky, Thomas270894e2015-01-16 12:46:50 -0600420 * Rx: index of descriptor to check for buffer reallocation
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500421 */
422 unsigned int cur;
423 unsigned int dirty;
424
425 /* Coalesce frame count used for interrupt bit setting */
426 unsigned int coalesce_count;
427
428 union {
429 struct {
430 unsigned int queue_stopped;
Lendacky, Thomas16958a22014-11-20 11:04:08 -0600431 unsigned int xmit_more;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500432 unsigned short cur_mss;
433 unsigned short cur_vlan_ctag;
434 } tx;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500435 };
436} ____cacheline_aligned;
437
438/* Structure used to describe the descriptor rings associated with
439 * a DMA channel.
440 */
441struct xgbe_channel {
442 char name[16];
443
444 /* Address of private data area for device */
445 struct xgbe_prv_data *pdata;
446
447 /* Queue index and base address of queue's DMA registers */
448 unsigned int queue_index;
449 void __iomem *dma_regs;
450
Lendacky, Thomas9227dc52014-11-04 16:06:56 -0600451 /* Per channel interrupt irq number */
452 int dma_irq;
Lendacky, Thomas54ceb9e2014-12-02 18:07:18 -0600453 char dma_irq_name[IFNAMSIZ + 32];
Lendacky, Thomas9227dc52014-11-04 16:06:56 -0600454
455 /* Netdev related settings */
456 struct napi_struct napi;
457
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500458 unsigned int saved_ier;
459
460 unsigned int tx_timer_active;
Lendacky, Thomasc635eaa2015-03-20 11:50:28 -0500461 struct timer_list tx_timer;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500462
463 struct xgbe_ring *tx_ring;
464 struct xgbe_ring *rx_ring;
465} ____cacheline_aligned;
466
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500467enum xgbe_state {
468 XGBE_DOWN,
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500469 XGBE_LINK_INIT,
470 XGBE_LINK_ERR,
Lendacky, Thomase78332b2016-11-10 17:10:26 -0600471 XGBE_STOPPED,
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500472};
473
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500474enum xgbe_int {
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500475 XGMAC_INT_DMA_CH_SR_TI,
476 XGMAC_INT_DMA_CH_SR_TPS,
477 XGMAC_INT_DMA_CH_SR_TBU,
478 XGMAC_INT_DMA_CH_SR_RI,
479 XGMAC_INT_DMA_CH_SR_RBU,
480 XGMAC_INT_DMA_CH_SR_RPS,
Lendacky, Thomas9867e8f2014-07-02 13:04:46 -0500481 XGMAC_INT_DMA_CH_SR_TI_RI,
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500482 XGMAC_INT_DMA_CH_SR_FBE,
483 XGMAC_INT_DMA_ALL,
484};
485
486enum xgbe_int_state {
487 XGMAC_INT_STATE_SAVE,
488 XGMAC_INT_STATE_RESTORE,
489};
490
Lendacky, Thomase78332b2016-11-10 17:10:26 -0600491enum xgbe_ecc_sec {
492 XGBE_ECC_SEC_TX,
493 XGBE_ECC_SEC_RX,
494 XGBE_ECC_SEC_DESC,
495};
496
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500497enum xgbe_speed {
498 XGBE_SPEED_1000 = 0,
499 XGBE_SPEED_2500,
500 XGBE_SPEED_10000,
501 XGBE_SPEEDS,
502};
503
Lendacky, Thomasb03a4a62016-11-03 13:18:56 -0500504enum xgbe_xpcs_access {
505 XGBE_XPCS_ACCESS_V1 = 0,
506 XGBE_XPCS_ACCESS_V2,
507};
508
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500509enum xgbe_an_mode {
510 XGBE_AN_MODE_CL73 = 0,
Lendacky, Thomasd7445d12016-11-10 17:11:41 -0600511 XGBE_AN_MODE_CL73_REDRV,
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500512 XGBE_AN_MODE_CL37,
513 XGBE_AN_MODE_CL37_SGMII,
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500514 XGBE_AN_MODE_NONE,
515};
516
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500517enum xgbe_an {
518 XGBE_AN_READY = 0,
519 XGBE_AN_PAGE_RECEIVED,
520 XGBE_AN_INCOMPAT_LINK,
521 XGBE_AN_COMPLETE,
522 XGBE_AN_NO_LINK,
523 XGBE_AN_ERROR,
524};
525
526enum xgbe_rx {
527 XGBE_RX_BPA = 0,
528 XGBE_RX_XNP,
529 XGBE_RX_COMPLETE,
530 XGBE_RX_ERROR,
531};
532
533enum xgbe_mode {
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500534 XGBE_MODE_KX_1000 = 0,
535 XGBE_MODE_KX_2500,
536 XGBE_MODE_KR,
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -0600537 XGBE_MODE_X,
538 XGBE_MODE_SGMII_100,
539 XGBE_MODE_SGMII_1000,
540 XGBE_MODE_SFI,
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500541 XGBE_MODE_UNKNOWN,
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500542};
543
544enum xgbe_speedset {
545 XGBE_SPEEDSET_1000_10000 = 0,
546 XGBE_SPEEDSET_2500_10000,
547};
548
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -0600549enum xgbe_mdio_mode {
550 XGBE_MDIO_MODE_NONE = 0,
551 XGBE_MDIO_MODE_CL22,
552 XGBE_MDIO_MODE_CL45,
553};
554
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500555struct xgbe_phy {
556 u32 supported;
557 u32 advertising;
558 u32 lp_advertising;
559
560 int address;
561
562 int autoneg;
563 int speed;
564 int duplex;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500565
566 int link;
Lendacky, Thomasc1ce2f72015-05-14 11:44:27 -0500567
568 int pause_autoneg;
569 int tx_pause;
570 int rx_pause;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500571};
572
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -0600573enum xgbe_i2c_cmd {
574 XGBE_I2C_CMD_READ = 0,
575 XGBE_I2C_CMD_WRITE,
576};
577
578struct xgbe_i2c_op {
579 enum xgbe_i2c_cmd cmd;
580
581 unsigned int target;
582
583 void *buf;
584 unsigned int len;
585};
586
587struct xgbe_i2c_op_state {
588 struct xgbe_i2c_op *op;
589
590 unsigned int tx_len;
591 unsigned char *tx_buf;
592
593 unsigned int rx_len;
594 unsigned char *rx_buf;
595
596 unsigned int tx_abort_source;
597
598 int ret;
599};
600
601struct xgbe_i2c {
602 unsigned int started;
603 unsigned int max_speed_mode;
604 unsigned int rx_fifo_size;
605 unsigned int tx_fifo_size;
606
607 struct xgbe_i2c_op_state op_state;
608};
609
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500610struct xgbe_mmc_stats {
611 /* Tx Stats */
612 u64 txoctetcount_gb;
613 u64 txframecount_gb;
614 u64 txbroadcastframes_g;
615 u64 txmulticastframes_g;
616 u64 tx64octets_gb;
617 u64 tx65to127octets_gb;
618 u64 tx128to255octets_gb;
619 u64 tx256to511octets_gb;
620 u64 tx512to1023octets_gb;
621 u64 tx1024tomaxoctets_gb;
622 u64 txunicastframes_gb;
623 u64 txmulticastframes_gb;
624 u64 txbroadcastframes_gb;
625 u64 txunderflowerror;
626 u64 txoctetcount_g;
627 u64 txframecount_g;
628 u64 txpauseframes;
629 u64 txvlanframes_g;
630
631 /* Rx Stats */
632 u64 rxframecount_gb;
633 u64 rxoctetcount_gb;
634 u64 rxoctetcount_g;
635 u64 rxbroadcastframes_g;
636 u64 rxmulticastframes_g;
637 u64 rxcrcerror;
638 u64 rxrunterror;
639 u64 rxjabbererror;
640 u64 rxundersize_g;
641 u64 rxoversize_g;
642 u64 rx64octets_gb;
643 u64 rx65to127octets_gb;
644 u64 rx128to255octets_gb;
645 u64 rx256to511octets_gb;
646 u64 rx512to1023octets_gb;
647 u64 rx1024tomaxoctets_gb;
648 u64 rxunicastframes_g;
649 u64 rxlengtherror;
650 u64 rxoutofrangetype;
651 u64 rxpauseframes;
652 u64 rxfifooverflow;
653 u64 rxvlanframes_gb;
654 u64 rxwatchdogerror;
655};
656
Lendacky, Thomas5452b2d2015-05-14 11:43:57 -0500657struct xgbe_ext_stats {
658 u64 tx_tso_packets;
659 u64 rx_split_header_packets;
Lendacky, Thomas72c9ac42015-09-30 08:53:10 -0500660 u64 rx_buffer_unavailable;
Lendacky, Thomas5452b2d2015-05-14 11:43:57 -0500661};
662
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500663struct xgbe_hw_if {
664 int (*tx_complete)(struct xgbe_ring_desc *);
665
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500666 int (*set_mac_address)(struct xgbe_prv_data *, u8 *addr);
Lendacky, Thomasb8763822015-04-09 12:11:57 -0500667 int (*config_rx_mode)(struct xgbe_prv_data *);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500668
669 int (*enable_rx_csum)(struct xgbe_prv_data *);
670 int (*disable_rx_csum)(struct xgbe_prv_data *);
671
672 int (*enable_rx_vlan_stripping)(struct xgbe_prv_data *);
673 int (*disable_rx_vlan_stripping)(struct xgbe_prv_data *);
Lendacky, Thomas801c62d2014-06-24 16:19:24 -0500674 int (*enable_rx_vlan_filtering)(struct xgbe_prv_data *);
675 int (*disable_rx_vlan_filtering)(struct xgbe_prv_data *);
676 int (*update_vlan_hash_table)(struct xgbe_prv_data *);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500677
678 int (*read_mmd_regs)(struct xgbe_prv_data *, int, int);
679 void (*write_mmd_regs)(struct xgbe_prv_data *, int, int, int);
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500680 int (*set_speed)(struct xgbe_prv_data *, int);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500681
Lendacky, Thomas732f2ab2016-11-10 17:11:14 -0600682 int (*set_ext_mii_mode)(struct xgbe_prv_data *, unsigned int,
683 enum xgbe_mdio_mode);
684 int (*read_ext_mii_regs)(struct xgbe_prv_data *, int, int);
685 int (*write_ext_mii_regs)(struct xgbe_prv_data *, int, int, u16);
686
687 int (*set_gpio)(struct xgbe_prv_data *, unsigned int);
688 int (*clr_gpio)(struct xgbe_prv_data *, unsigned int);
689
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500690 void (*enable_tx)(struct xgbe_prv_data *);
691 void (*disable_tx)(struct xgbe_prv_data *);
692 void (*enable_rx)(struct xgbe_prv_data *);
693 void (*disable_rx)(struct xgbe_prv_data *);
694
695 void (*powerup_tx)(struct xgbe_prv_data *);
696 void (*powerdown_tx)(struct xgbe_prv_data *);
697 void (*powerup_rx)(struct xgbe_prv_data *);
698 void (*powerdown_rx)(struct xgbe_prv_data *);
699
700 int (*init)(struct xgbe_prv_data *);
701 int (*exit)(struct xgbe_prv_data *);
702
703 int (*enable_int)(struct xgbe_channel *, enum xgbe_int);
704 int (*disable_int)(struct xgbe_channel *, enum xgbe_int);
Lendacky, Thomasa9d41982014-11-04 16:06:32 -0600705 void (*dev_xmit)(struct xgbe_channel *);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500706 int (*dev_read)(struct xgbe_channel *);
707 void (*tx_desc_init)(struct xgbe_channel *);
708 void (*rx_desc_init)(struct xgbe_channel *);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500709 void (*tx_desc_reset)(struct xgbe_ring_data *);
Lendacky, Thomas8dee19e2015-04-09 12:11:51 -0500710 void (*rx_desc_reset)(struct xgbe_prv_data *, struct xgbe_ring_data *,
711 unsigned int);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500712 int (*is_last_desc)(struct xgbe_ring_desc *);
713 int (*is_context_desc)(struct xgbe_ring_desc *);
Lendacky, Thomas16958a22014-11-20 11:04:08 -0600714 void (*tx_start_xmit)(struct xgbe_channel *, struct xgbe_ring *);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500715
716 /* For FLOW ctrl */
717 int (*config_tx_flow_control)(struct xgbe_prv_data *);
718 int (*config_rx_flow_control)(struct xgbe_prv_data *);
719
720 /* For RX coalescing */
721 int (*config_rx_coalesce)(struct xgbe_prv_data *);
722 int (*config_tx_coalesce)(struct xgbe_prv_data *);
723 unsigned int (*usec_to_riwt)(struct xgbe_prv_data *, unsigned int);
724 unsigned int (*riwt_to_usec)(struct xgbe_prv_data *, unsigned int);
725
726 /* For RX and TX threshold config */
727 int (*config_rx_threshold)(struct xgbe_prv_data *, unsigned int);
728 int (*config_tx_threshold)(struct xgbe_prv_data *, unsigned int);
729
730 /* For RX and TX Store and Forward Mode config */
731 int (*config_rsf_mode)(struct xgbe_prv_data *, unsigned int);
732 int (*config_tsf_mode)(struct xgbe_prv_data *, unsigned int);
733
734 /* For TX DMA Operate on Second Frame config */
735 int (*config_osp_mode)(struct xgbe_prv_data *);
736
737 /* For RX and TX PBL config */
738 int (*config_rx_pbl_val)(struct xgbe_prv_data *);
739 int (*get_rx_pbl_val)(struct xgbe_prv_data *);
740 int (*config_tx_pbl_val)(struct xgbe_prv_data *);
741 int (*get_tx_pbl_val)(struct xgbe_prv_data *);
742 int (*config_pblx8)(struct xgbe_prv_data *);
743
744 /* For MMC statistics */
745 void (*rx_mmc_int)(struct xgbe_prv_data *);
746 void (*tx_mmc_int)(struct xgbe_prv_data *);
747 void (*read_mmc_stats)(struct xgbe_prv_data *);
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500748
749 /* For Timestamp config */
750 int (*config_tstamp)(struct xgbe_prv_data *, unsigned int);
751 void (*update_tstamp_addend)(struct xgbe_prv_data *, unsigned int);
752 void (*set_tstamp_time)(struct xgbe_prv_data *, unsigned int sec,
753 unsigned int nsec);
754 u64 (*get_tstamp_time)(struct xgbe_prv_data *);
755 u64 (*get_tx_tstamp)(struct xgbe_prv_data *);
Lendacky, Thomasfca2d992014-07-29 08:57:55 -0500756
757 /* For Data Center Bridging config */
Lendacky, Thomasb3b71592016-02-17 11:49:08 -0600758 void (*config_tc)(struct xgbe_prv_data *);
Lendacky, Thomasfca2d992014-07-29 08:57:55 -0500759 void (*config_dcb_tc)(struct xgbe_prv_data *);
760 void (*config_dcb_pfc)(struct xgbe_prv_data *);
Lendacky, Thomas5b9dfe22014-11-04 16:07:02 -0600761
762 /* For Receive Side Scaling */
763 int (*enable_rss)(struct xgbe_prv_data *);
764 int (*disable_rss)(struct xgbe_prv_data *);
Lendacky, Thomasf6ac8622014-11-04 16:07:23 -0600765 int (*set_rss_hash_key)(struct xgbe_prv_data *, const u8 *);
766 int (*set_rss_lookup_table)(struct xgbe_prv_data *, const u32 *);
Lendacky, Thomase78332b2016-11-10 17:10:26 -0600767
768 /* For ECC */
769 void (*disable_ecc_ded)(struct xgbe_prv_data *);
770 void (*disable_ecc_sec)(struct xgbe_prv_data *, enum xgbe_ecc_sec);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500771};
772
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500773/* This structure represents implementation specific routines for an
774 * implementation of a PHY. All routines are required unless noted below.
775 * Optional routines:
776 * kr_training_pre, kr_training_post
777 */
778struct xgbe_phy_impl_if {
779 /* Perform Setup/teardown actions */
780 int (*init)(struct xgbe_prv_data *);
781 void (*exit)(struct xgbe_prv_data *);
782
783 /* Perform start/stop specific actions */
784 int (*reset)(struct xgbe_prv_data *);
785 int (*start)(struct xgbe_prv_data *);
786 void (*stop)(struct xgbe_prv_data *);
787
788 /* Return the link status */
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -0600789 int (*link_status)(struct xgbe_prv_data *, int *);
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500790
791 /* Indicate if a particular speed is valid */
792 bool (*valid_speed)(struct xgbe_prv_data *, int);
793
794 /* Check if the specified mode can/should be used */
795 bool (*use_mode)(struct xgbe_prv_data *, enum xgbe_mode);
796 /* Switch the PHY into various modes */
797 void (*set_mode)(struct xgbe_prv_data *, enum xgbe_mode);
798 /* Retrieve mode needed for a specific speed */
799 enum xgbe_mode (*get_mode)(struct xgbe_prv_data *, int);
800 /* Retrieve new/next mode when trying to auto-negotiate */
801 enum xgbe_mode (*switch_mode)(struct xgbe_prv_data *);
802 /* Retrieve current mode */
803 enum xgbe_mode (*cur_mode)(struct xgbe_prv_data *);
804
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500805 /* Retrieve current auto-negotiation mode */
806 enum xgbe_an_mode (*an_mode)(struct xgbe_prv_data *);
807
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -0600808 /* Configure auto-negotiation settings */
809 int (*an_config)(struct xgbe_prv_data *);
810
Lendacky, Thomasd7445d12016-11-10 17:11:41 -0600811 /* Set/override auto-negotiation advertisement settings */
812 unsigned int (*an_advertising)(struct xgbe_prv_data *);
813
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500814 /* Process results of auto-negotiation */
815 enum xgbe_mode (*an_outcome)(struct xgbe_prv_data *);
816
817 /* Pre/Post KR training enablement support */
818 void (*kr_training_pre)(struct xgbe_prv_data *);
819 void (*kr_training_post)(struct xgbe_prv_data *);
820};
821
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500822struct xgbe_phy_if {
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500823 /* For PHY setup/teardown */
824 int (*phy_init)(struct xgbe_prv_data *);
825 void (*phy_exit)(struct xgbe_prv_data *);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500826
827 /* For PHY support when setting device up/down */
828 int (*phy_reset)(struct xgbe_prv_data *);
829 int (*phy_start)(struct xgbe_prv_data *);
830 void (*phy_stop)(struct xgbe_prv_data *);
831
832 /* For PHY support while device is up */
833 void (*phy_status)(struct xgbe_prv_data *);
834 int (*phy_config_aneg)(struct xgbe_prv_data *);
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500835
836 /* For PHY settings validation */
837 bool (*phy_valid_speed)(struct xgbe_prv_data *, int);
838
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600839 /* For single interrupt support */
Lendacky, Thomas85b85c82017-06-28 13:42:42 -0500840 irqreturn_t (*an_isr)(struct xgbe_prv_data *);
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600841
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500842 /* PHY implementation specific services */
843 struct xgbe_phy_impl_if phy_impl;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500844};
845
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -0600846struct xgbe_i2c_if {
847 /* For initial I2C setup */
848 int (*i2c_init)(struct xgbe_prv_data *);
849
850 /* For I2C support when setting device up/down */
851 int (*i2c_start)(struct xgbe_prv_data *);
852 void (*i2c_stop)(struct xgbe_prv_data *);
853
854 /* For performing I2C operations */
855 int (*i2c_xfer)(struct xgbe_prv_data *, struct xgbe_i2c_op *);
856
857 /* For single interrupt support */
Lendacky, Thomas85b85c82017-06-28 13:42:42 -0500858 irqreturn_t (*i2c_isr)(struct xgbe_prv_data *);
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -0600859};
860
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500861struct xgbe_desc_if {
862 int (*alloc_ring_resources)(struct xgbe_prv_data *);
863 void (*free_ring_resources)(struct xgbe_prv_data *);
864 int (*map_tx_skb)(struct xgbe_channel *, struct sk_buff *);
Lendacky, Thomas270894e2015-01-16 12:46:50 -0600865 int (*map_rx_buffer)(struct xgbe_prv_data *, struct xgbe_ring *,
866 struct xgbe_ring_data *);
Lendacky, Thomas08dcc472014-11-04 16:06:44 -0600867 void (*unmap_rdata)(struct xgbe_prv_data *, struct xgbe_ring_data *);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500868 void (*wrapper_tx_desc_init)(struct xgbe_prv_data *);
869 void (*wrapper_rx_desc_init)(struct xgbe_prv_data *);
870};
871
872/* This structure contains flags that indicate what hardware features
873 * or configurations are present in the device.
874 */
875struct xgbe_hw_features {
Lendacky, Thomasa9a4a2d2014-08-29 13:16:50 -0500876 /* HW Version */
877 unsigned int version;
878
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500879 /* HW Feature Register0 */
880 unsigned int gmii; /* 1000 Mbps support */
881 unsigned int vlhash; /* VLAN Hash Filter */
882 unsigned int sma; /* SMA(MDIO) Interface */
883 unsigned int rwk; /* PMT remote wake-up packet */
884 unsigned int mgk; /* PMT magic packet */
885 unsigned int mmc; /* RMON module */
886 unsigned int aoe; /* ARP Offload */
Joe Perchesdbedd442015-03-06 20:49:12 -0800887 unsigned int ts; /* IEEE 1588-2008 Advanced Timestamp */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500888 unsigned int eee; /* Energy Efficient Ethernet */
889 unsigned int tx_coe; /* Tx Checksum Offload */
890 unsigned int rx_coe; /* Rx Checksum Offload */
891 unsigned int addn_mac; /* Additional MAC Addresses */
892 unsigned int ts_src; /* Timestamp Source */
893 unsigned int sa_vlan_ins; /* Source Address or VLAN Insertion */
894
895 /* HW Feature Register1 */
896 unsigned int rx_fifo_size; /* MTL Receive FIFO Size */
897 unsigned int tx_fifo_size; /* MTL Transmit FIFO Size */
898 unsigned int adv_ts_hi; /* Advance Timestamping High Word */
Lendacky, Thomas386d3252015-03-20 11:50:22 -0500899 unsigned int dma_width; /* DMA width */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500900 unsigned int dcb; /* DCB Feature */
901 unsigned int sph; /* Split Header Feature */
902 unsigned int tso; /* TCP Segmentation Offload */
903 unsigned int dma_debug; /* DMA Debug Registers */
904 unsigned int rss; /* Receive Side Scaling */
Lendacky, Thomasfca2d992014-07-29 08:57:55 -0500905 unsigned int tc_cnt; /* Number of Traffic Classes */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500906 unsigned int hash_table_size; /* Hash Table Size */
907 unsigned int l3l4_filter_num; /* Number of L3-L4 Filters */
908
909 /* HW Feature Register2 */
910 unsigned int rx_q_cnt; /* Number of MTL Receive Queues */
911 unsigned int tx_q_cnt; /* Number of MTL Transmit Queues */
912 unsigned int rx_ch_cnt; /* Number of DMA Receive Channels */
913 unsigned int tx_ch_cnt; /* Number of DMA Transmit Channels */
914 unsigned int pps_out_num; /* Number of PPS outputs */
915 unsigned int aux_snap_num; /* Number of Aux snapshot inputs */
916};
917
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500918struct xgbe_version_data {
919 void (*init_function_ptrs_phy_impl)(struct xgbe_phy_if *);
Lendacky, Thomasb03a4a62016-11-03 13:18:56 -0500920 enum xgbe_xpcs_access xpcs_access;
Lendacky, Thomase5a20b92016-11-03 13:19:07 -0500921 unsigned int mmc_64bit;
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -0500922 unsigned int tx_max_fifo_size;
923 unsigned int rx_max_fifo_size;
Lendacky, Thomasaba97772016-11-10 17:09:45 -0600924 unsigned int tx_tstamp_workaround;
Lendacky, Thomase78332b2016-11-10 17:10:26 -0600925 unsigned int ecc_support;
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -0600926 unsigned int i2c_support;
Lendacky, Thomas85b85c82017-06-28 13:42:42 -0500927 unsigned int irq_reissue_support;
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500928};
929
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500930struct xgbe_prv_data {
931 struct net_device *netdev;
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600932 struct pci_dev *pcidev;
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -0500933 struct platform_device *platdev;
Lendacky, Thomas82a19032015-01-16 12:47:16 -0600934 struct acpi_device *adev;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500935 struct device *dev;
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -0500936 struct platform_device *phy_platdev;
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500937 struct device *phy_dev;
938
939 /* Version related data */
940 struct xgbe_version_data *vdata;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500941
Lendacky, Thomas82a19032015-01-16 12:47:16 -0600942 /* ACPI or DT flag */
943 unsigned int use_acpi;
944
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500945 /* XGMAC/XPCS related mmio registers */
946 void __iomem *xgmac_regs; /* XGMAC CSRs */
947 void __iomem *xpcs_regs; /* XPCS MMD registers */
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500948 void __iomem *rxtx_regs; /* SerDes Rx/Tx CSRs */
949 void __iomem *sir0_regs; /* SerDes integration registers (1/2) */
950 void __iomem *sir1_regs; /* SerDes integration registers (2/2) */
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600951 void __iomem *xprop_regs; /* XGBE property registers */
952 void __iomem *xi2c_regs; /* XGBE I2C CSRs */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500953
954 /* Overall device lock */
955 spinlock_t lock;
956
Lendacky, Thomasced3fca2016-02-17 11:49:28 -0600957 /* XPCS indirect addressing lock */
958 spinlock_t xpcs_lock;
Lendacky, Thomas4eccbfc2017-01-20 12:14:03 -0600959 unsigned int xpcs_window_def_reg;
960 unsigned int xpcs_window_sel_reg;
Lendacky, Thomasb03a4a62016-11-03 13:18:56 -0500961 unsigned int xpcs_window;
962 unsigned int xpcs_window_size;
963 unsigned int xpcs_window_mask;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500964
Lendacky, Thomas5b9dfe22014-11-04 16:07:02 -0600965 /* RSS addressing mutex */
966 struct mutex rss_mutex;
967
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500968 /* Flags representing xgbe_state */
969 unsigned long dev_state;
970
Lendacky, Thomase78332b2016-11-10 17:10:26 -0600971 /* ECC support */
972 unsigned long tx_sec_period;
973 unsigned long tx_ded_period;
974 unsigned long rx_sec_period;
975 unsigned long rx_ded_period;
976 unsigned long desc_sec_period;
977 unsigned long desc_ded_period;
978
979 unsigned int tx_sec_count;
980 unsigned int tx_ded_count;
981 unsigned int rx_sec_count;
982 unsigned int rx_ded_count;
983 unsigned int desc_ded_count;
984 unsigned int desc_sec_count;
985
Lendacky, Thomas9227dc52014-11-04 16:06:56 -0600986 int dev_irq;
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600987 int ecc_irq;
988 int i2c_irq;
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -0500989 int channel_irq[XGBE_MAX_DMA_CHANNELS];
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500990
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600991 unsigned int per_channel_irq;
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600992 unsigned int irq_count;
993 unsigned int channel_irq_count;
Lendacky, Thomas4c70dd82016-11-10 17:10:17 -0600994 unsigned int channel_irq_mode;
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600995
Lendacky, Thomase78332b2016-11-10 17:10:26 -0600996 char ecc_name[IFNAMSIZ + 32];
997
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500998 struct xgbe_hw_if hw_if;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500999 struct xgbe_phy_if phy_if;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001000 struct xgbe_desc_if desc_if;
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -06001001 struct xgbe_i2c_if i2c_if;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001002
Lendacky, Thomascfa50c72014-07-02 13:04:57 -05001003 /* AXI DMA settings */
Lendacky, Thomas82a19032015-01-16 12:47:16 -06001004 unsigned int coherent;
Lendacky, Thomascfa50c72014-07-02 13:04:57 -05001005 unsigned int axdomain;
1006 unsigned int arcache;
1007 unsigned int awcache;
1008
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001009 /* Service routine support */
1010 struct workqueue_struct *dev_workqueue;
1011 struct work_struct service_work;
1012 struct timer_list service_timer;
1013
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001014 /* Rings for Tx/Rx on a DMA channel */
1015 struct xgbe_channel *channel;
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -05001016 unsigned int tx_max_channel_count;
1017 unsigned int rx_max_channel_count;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001018 unsigned int channel_count;
1019 unsigned int tx_ring_count;
1020 unsigned int tx_desc_count;
1021 unsigned int rx_ring_count;
1022 unsigned int rx_desc_count;
1023
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -05001024 unsigned int tx_max_q_count;
1025 unsigned int rx_max_q_count;
Lendacky, Thomas853eb162014-07-29 08:57:31 -05001026 unsigned int tx_q_count;
1027 unsigned int rx_q_count;
1028
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001029 /* Tx/Rx common settings */
1030 unsigned int pblx8;
1031
1032 /* Tx settings */
1033 unsigned int tx_sf_mode;
1034 unsigned int tx_threshold;
1035 unsigned int tx_pbl;
1036 unsigned int tx_osp_mode;
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -05001037 unsigned int tx_max_fifo_size;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001038
1039 /* Rx settings */
1040 unsigned int rx_sf_mode;
1041 unsigned int rx_threshold;
1042 unsigned int rx_pbl;
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -05001043 unsigned int rx_max_fifo_size;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001044
1045 /* Tx coalescing settings */
1046 unsigned int tx_usecs;
1047 unsigned int tx_frames;
1048
1049 /* Rx coalescing settings */
1050 unsigned int rx_riwt;
Lendacky, Thomas4a57ebc2015-03-20 11:50:34 -05001051 unsigned int rx_usecs;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001052 unsigned int rx_frames;
1053
Lendacky, Thomas08dcc472014-11-04 16:06:44 -06001054 /* Current Rx buffer size */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001055 unsigned int rx_buf_size;
1056
1057 /* Flow control settings */
1058 unsigned int pause_autoneg;
1059 unsigned int tx_pause;
1060 unsigned int rx_pause;
Lendacky, Thomas43e0dcf2016-11-03 13:18:16 -05001061 unsigned int rx_rfa[XGBE_MAX_QUEUES];
1062 unsigned int rx_rfd[XGBE_MAX_QUEUES];
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001063
Lendacky, Thomas5b9dfe22014-11-04 16:07:02 -06001064 /* Receive Side Scaling settings */
1065 u8 rss_key[XGBE_RSS_HASH_KEY_SIZE];
1066 u32 rss_table[XGBE_RSS_MAX_TABLE_SIZE];
1067 u32 rss_options;
1068
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001069 /* Netdev related settings */
Lendacky, Thomas82a19032015-01-16 12:47:16 -06001070 unsigned char mac_addr[ETH_ALEN];
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001071 netdev_features_t netdev_features;
1072 struct napi_struct napi;
1073 struct xgbe_mmc_stats mmc_stats;
Lendacky, Thomas5452b2d2015-05-14 11:43:57 -05001074 struct xgbe_ext_stats ext_stats;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001075
Lendacky, Thomas801c62d2014-06-24 16:19:24 -05001076 /* Filtering support */
1077 unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
1078
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -05001079 /* Device clocks */
1080 struct clk *sysclk;
Lendacky, Thomas82a19032015-01-16 12:47:16 -06001081 unsigned long sysclk_rate;
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -05001082 struct clk *ptpclk;
Lendacky, Thomas82a19032015-01-16 12:47:16 -06001083 unsigned long ptpclk_rate;
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -05001084
1085 /* Timestamp support */
1086 spinlock_t tstamp_lock;
1087 struct ptp_clock_info ptp_clock_info;
1088 struct ptp_clock *ptp_clock;
1089 struct hwtstamp_config tstamp_config;
1090 struct cyclecounter tstamp_cc;
1091 struct timecounter tstamp_tc;
1092 unsigned int tstamp_addend;
1093 struct work_struct tx_tstamp_work;
1094 struct sk_buff *tx_tstamp_skb;
1095 u64 tx_tstamp;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001096
Lendacky, Thomasfca2d992014-07-29 08:57:55 -05001097 /* DCB support */
1098 struct ieee_ets *ets;
1099 struct ieee_pfc *pfc;
1100 unsigned int q2tc_map[XGBE_MAX_QUEUES];
1101 unsigned int prio2q_map[IEEE_8021QAZ_MAX_TCS];
Lendacky, Thomas43e0dcf2016-11-03 13:18:16 -05001102 unsigned int pfcq[XGBE_MAX_QUEUES];
1103 unsigned int pfc_rfa;
Lendacky, Thomasb3b71592016-02-17 11:49:08 -06001104 u8 num_tcs;
Lendacky, Thomasfca2d992014-07-29 08:57:55 -05001105
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001106 /* Hardware features of the device */
1107 struct xgbe_hw_features hw_feat;
1108
Lendacky, Thomase78332b2016-11-10 17:10:26 -06001109 /* Device work structures */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001110 struct work_struct restart_work;
Lendacky, Thomase78332b2016-11-10 17:10:26 -06001111 struct work_struct stopdev_work;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001112
1113 /* Keeps track of power mode */
1114 unsigned int power_down;
1115
Lendacky, Thomas34bf65d2015-05-14 11:44:03 -05001116 /* Network interface message level setting */
1117 u32 msg_enable;
1118
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001119 /* Current PHY settings */
1120 phy_interface_t phy_mode;
1121 int phy_link;
1122 int phy_speed;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001123
1124 /* MDIO/PHY related settings */
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001125 unsigned int phy_started;
1126 void *phy_data;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001127 struct xgbe_phy phy;
1128 int mdio_mmd;
1129 unsigned long link_check;
Lendacky, Thomas732f2ab2016-11-10 17:11:14 -06001130 struct completion mdio_complete;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001131
Lendacky, Thomasd7445d12016-11-10 17:11:41 -06001132 unsigned int kr_redrv;
1133
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001134 char an_name[IFNAMSIZ + 32];
1135 struct workqueue_struct *an_workqueue;
1136
1137 int an_irq;
1138 struct work_struct an_irq_work;
1139
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001140 /* Auto-negotiation state machine support */
Lendacky, Thomasced3fca2016-02-17 11:49:28 -06001141 unsigned int an_int;
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -05001142 unsigned int an_status;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001143 struct mutex an_mutex;
1144 enum xgbe_an an_result;
1145 enum xgbe_an an_state;
1146 enum xgbe_rx kr_state;
1147 enum xgbe_rx kx_state;
1148 struct work_struct an_work;
1149 unsigned int an_supported;
1150 unsigned int parallel_detect;
1151 unsigned int fec_ability;
1152 unsigned long an_start;
Lendacky, Thomasa64def42016-11-03 13:18:38 -05001153 enum xgbe_an_mode an_mode;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001154
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -06001155 /* I2C support */
1156 struct xgbe_i2c i2c;
1157 struct mutex i2c_mutex;
1158 struct completion i2c_complete;
1159 char i2c_name[IFNAMSIZ + 32];
1160
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001161 unsigned int lpm_ctrl; /* CTRL1 for resume */
1162
Lendacky, Thomas85b85c82017-06-28 13:42:42 -05001163 unsigned int isr_as_tasklet;
1164 struct tasklet_struct tasklet_dev;
1165 struct tasklet_struct tasklet_ecc;
1166 struct tasklet_struct tasklet_i2c;
1167 struct tasklet_struct tasklet_an;
1168
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001169#ifdef CONFIG_DEBUG_FS
1170 struct dentry *xgbe_debugfs;
1171
1172 unsigned int debugfs_xgmac_reg;
1173
1174 unsigned int debugfs_xpcs_mmd;
1175 unsigned int debugfs_xpcs_reg;
Lendacky, Thomas47f164d2016-11-10 17:09:55 -06001176
1177 unsigned int debugfs_xprop_reg;
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -06001178
1179 unsigned int debugfs_xi2c_reg;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001180#endif
1181};
1182
1183/* Function prototypes*/
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -05001184struct xgbe_prv_data *xgbe_alloc_pdata(struct device *);
1185void xgbe_free_pdata(struct xgbe_prv_data *);
1186void xgbe_set_counts(struct xgbe_prv_data *);
1187int xgbe_config_netdev(struct xgbe_prv_data *);
1188void xgbe_deconfig_netdev(struct xgbe_prv_data *);
1189
1190int xgbe_platform_init(void);
1191void xgbe_platform_exit(void);
Lendacky, Thomas47f164d2016-11-10 17:09:55 -06001192#ifdef CONFIG_PCI
1193int xgbe_pci_init(void);
1194void xgbe_pci_exit(void);
1195#else
1196static inline int xgbe_pci_init(void) { return 0; }
1197static inline void xgbe_pci_exit(void) { }
1198#endif
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001199
1200void xgbe_init_function_ptrs_dev(struct xgbe_hw_if *);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001201void xgbe_init_function_ptrs_phy(struct xgbe_phy_if *);
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001202void xgbe_init_function_ptrs_phy_v1(struct xgbe_phy_if *);
Lendacky, Thomas47f164d2016-11-10 17:09:55 -06001203void xgbe_init_function_ptrs_phy_v2(struct xgbe_phy_if *);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001204void xgbe_init_function_ptrs_desc(struct xgbe_desc_if *);
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -06001205void xgbe_init_function_ptrs_i2c(struct xgbe_i2c_if *);
stephen hemmingerce0b15d2016-08-31 08:57:36 -07001206const struct net_device_ops *xgbe_get_netdev_ops(void);
1207const struct ethtool_ops *xgbe_get_ethtool_ops(void);
1208
Lendacky, Thomasfca2d992014-07-29 08:57:55 -05001209#ifdef CONFIG_AMD_XGBE_DCB
1210const struct dcbnl_rtnl_ops *xgbe_get_dcbnl_ops(void);
1211#endif
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001212
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -05001213void xgbe_ptp_register(struct xgbe_prv_data *);
1214void xgbe_ptp_unregister(struct xgbe_prv_data *);
Lendacky, Thomas34bf65d2015-05-14 11:44:03 -05001215void xgbe_dump_tx_desc(struct xgbe_prv_data *, struct xgbe_ring *,
1216 unsigned int, unsigned int, unsigned int);
1217void xgbe_dump_rx_desc(struct xgbe_prv_data *, struct xgbe_ring *,
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001218 unsigned int);
1219void xgbe_print_pkt(struct net_device *, struct sk_buff *, bool);
1220void xgbe_get_all_hw_features(struct xgbe_prv_data *);
1221int xgbe_powerup(struct net_device *, unsigned int);
1222int xgbe_powerdown(struct net_device *, unsigned int);
1223void xgbe_init_rx_coalesce(struct xgbe_prv_data *);
1224void xgbe_init_tx_coalesce(struct xgbe_prv_data *);
1225
1226#ifdef CONFIG_DEBUG_FS
1227void xgbe_debugfs_init(struct xgbe_prv_data *);
1228void xgbe_debugfs_exit(struct xgbe_prv_data *);
1229#else
1230static inline void xgbe_debugfs_init(struct xgbe_prv_data *pdata) {}
1231static inline void xgbe_debugfs_exit(struct xgbe_prv_data *pdata) {}
1232#endif /* CONFIG_DEBUG_FS */
1233
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001234/* NOTE: Uncomment for function trace log messages in KERNEL LOG */
1235#if 0
1236#define YDEBUG
1237#define YDEBUG_MDIO
1238#endif
1239
1240/* For debug prints */
1241#ifdef YDEBUG
1242#define DBGPR(x...) pr_alert(x)
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001243#else
1244#define DBGPR(x...) do { } while (0)
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001245#endif
1246
1247#ifdef YDEBUG_MDIO
1248#define DBGPR_MDIO(x...) pr_alert(x)
1249#else
1250#define DBGPR_MDIO(x...) do { } while (0)
1251#endif
1252
1253#endif