blob: 4bf82eb23ae6598edc326f7535cd28f55643ccd6 [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>
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500132
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500133#define XGBE_DRV_NAME "amd-xgbe"
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500134#define XGBE_DRV_VERSION "1.0.3"
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500135#define XGBE_DRV_DESC "AMD 10 Gigabit Ethernet Driver"
136
137/* Descriptor related defines */
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500138#define XGBE_TX_DESC_CNT 512
139#define XGBE_TX_DESC_MIN_FREE (XGBE_TX_DESC_CNT >> 3)
140#define XGBE_TX_DESC_MAX_PROC (XGBE_TX_DESC_CNT >> 1)
141#define XGBE_RX_DESC_CNT 512
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500142
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500143#define XGBE_TX_MAX_BUF_SIZE (0x3fff & ~(64 - 1))
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500144
Masahiro Yamadae1c05062015-07-07 10:14:59 +0900145/* Descriptors required for maximum contiguous TSO/GSO packet */
Lendacky, Thomas16958a22014-11-20 11:04:08 -0600146#define XGBE_TX_MAX_SPLIT ((GSO_MAX_SIZE / XGBE_TX_MAX_BUF_SIZE) + 1)
147
148/* Maximum possible descriptors needed for an SKB:
149 * - Maximum number of SKB frags
150 * - Maximum descriptors for contiguous TSO/GSO packet
151 * - Possible context descriptor
152 * - Possible TSO header descriptor
153 */
154#define XGBE_TX_MAX_DESCS (MAX_SKB_FRAGS + XGBE_TX_MAX_SPLIT + 2)
155
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500156#define XGBE_RX_MIN_BUF_SIZE (ETH_FRAME_LEN + ETH_FCS_LEN + VLAN_HLEN)
157#define XGBE_RX_BUF_ALIGN 64
Lendacky, Thomas08dcc472014-11-04 16:06:44 -0600158#define XGBE_SKB_ALLOC_SIZE 256
Lendacky, Thomas174fd252014-11-04 16:06:50 -0600159#define XGBE_SPH_HDSMS_SIZE 2 /* Keep in sync with SKB_ALLOC_SIZE */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500160
Lendacky, Thomasd5c48582014-06-09 09:19:32 -0500161#define XGBE_MAX_DMA_CHANNELS 16
Lendacky, Thomasfca2d992014-07-29 08:57:55 -0500162#define XGBE_MAX_QUEUES 16
Lendacky, Thomas43e0dcf2016-11-03 13:18:16 -0500163#define XGBE_PRIORITY_QUEUES 8
Lendacky, Thomas4b8acdf2016-11-03 13:19:17 -0500164#define XGBE_DMA_STOP_TIMEOUT 1
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500165
166/* DMA cache settings - Outer sharable, write-back, write-allocate */
Lendacky, Thomas99167162017-06-28 13:43:09 -0500167#define XGBE_DMA_OS_ARCR 0x002b2b2b
168#define XGBE_DMA_OS_AWCR 0x2f2f2f2f
Lendacky, Thomascfa50c72014-07-02 13:04:57 -0500169
170/* DMA cache settings - System, no caches used */
Lendacky, Thomas99167162017-06-28 13:43:09 -0500171#define XGBE_DMA_SYS_ARCR 0x00303030
172#define XGBE_DMA_SYS_AWCR 0x30303030
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500173
Lendacky, Thomas4c70dd82016-11-10 17:10:17 -0600174/* DMA channel interrupt modes */
175#define XGBE_IRQ_MODE_EDGE 0
176#define XGBE_IRQ_MODE_LEVEL 1
177
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500178#define XGBE_DMA_INTERRUPT_MASK 0x31c7
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500179
180#define XGMAC_MIN_PACKET 60
181#define XGMAC_STD_PACKET_MTU 1500
182#define XGMAC_MAX_STD_PACKET 1518
183#define XGMAC_JUMBO_PACKET_MTU 9000
184#define XGMAC_MAX_JUMBO_PACKET 9018
Lendacky, Thomas43e0dcf2016-11-03 13:18:16 -0500185#define XGMAC_ETH_PREAMBLE (12 + 8) /* Inter-frame gap + preamble */
186
187#define XGMAC_PFC_DATA_LEN 46
188#define XGMAC_PFC_DELAYS 14000
189
190#define XGMAC_PRIO_QUEUES(_cnt) \
191 min_t(unsigned int, IEEE_8021QAZ_MAX_TCS, (_cnt))
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500192
Lendacky, Thomas82a19032015-01-16 12:47:16 -0600193/* Common property names */
194#define XGBE_MAC_ADDR_PROPERTY "mac-address"
195#define XGBE_PHY_MODE_PROPERTY "phy-mode"
196#define XGBE_DMA_IRQS_PROPERTY "amd,per-channel-interrupt"
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500197#define XGBE_SPEEDSET_PROPERTY "amd,speed-set"
Lendacky, Thomas82a19032015-01-16 12:47:16 -0600198
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500199/* Device-tree clock names */
200#define XGBE_DMA_CLOCK "dma_clk"
201#define XGBE_PTP_CLOCK "ptp_clk"
Lendacky, Thomas82a19032015-01-16 12:47:16 -0600202
203/* ACPI property names */
204#define XGBE_ACPI_DMA_FREQ "amd,dma-freq"
205#define XGBE_ACPI_PTP_FREQ "amd,ptp-freq"
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500206
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600207/* PCI BAR mapping */
208#define XGBE_XGMAC_BAR 0
209#define XGBE_XPCS_BAR 1
210#define XGBE_MAC_PROP_OFFSET 0x1d000
211#define XGBE_I2C_CTRL_OFFSET 0x1e000
212
Tom Lendackye7537742017-01-13 09:05:53 +0100213/* PCI MSI/MSIx support */
214#define XGBE_MSI_BASE_COUNT 4
215#define XGBE_MSI_MIN_COUNT (XGBE_MSI_BASE_COUNT + 1)
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600216
217/* PCI clock frequencies */
218#define XGBE_V2_DMA_CLOCK_FREQ 500000000 /* 500 MHz */
219#define XGBE_V2_PTP_CLOCK_FREQ 125000000 /* 125 MHz */
220
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500221/* Timestamp support - values based on 50MHz PTP clock
222 * 50MHz => 20 nsec
223 */
224#define XGBE_TSTAMP_SSINC 20
225#define XGBE_TSTAMP_SNSINC 0
226
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500227/* Driver PMT macros */
228#define XGMAC_DRIVER_CONTEXT 1
229#define XGMAC_IOCTL_CONTEXT 2
230
Lendacky, Thomas43e0dcf2016-11-03 13:18:16 -0500231#define XGMAC_FIFO_MIN_ALLOC 2048
232#define XGMAC_FIFO_UNIT 256
233#define XGMAC_FIFO_ALIGN(_x) \
234 (((_x) + XGMAC_FIFO_UNIT - 1) & ~(XGMAC_FIFO_UNIT - 1))
235#define XGMAC_FIFO_FC_OFF 2048
236#define XGMAC_FIFO_FC_MIN 4096
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500237
Lendacky, Thomasfca2d992014-07-29 08:57:55 -0500238#define XGBE_TC_MIN_QUANTUM 10
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500239
240/* Helper macro for descriptor handling
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500241 * Always use XGBE_GET_DESC_DATA to access the descriptor data
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500242 * since the index is free-running and needs to be and-ed
243 * with the descriptor count value of the ring to index to
244 * the proper descriptor data.
245 */
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500246#define XGBE_GET_DESC_DATA(_ring, _idx) \
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500247 ((_ring)->rdata + \
248 ((_idx) & ((_ring)->rdesc_count - 1)))
249
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500250/* Default coalescing parameters */
Lendacky, Thomasc635eaa2015-03-20 11:50:28 -0500251#define XGMAC_INIT_DMA_TX_USECS 1000
Lendacky, Thomas9867e8f2014-07-02 13:04:46 -0500252#define XGMAC_INIT_DMA_TX_FRAMES 25
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500253
254#define XGMAC_MAX_DMA_RIWT 0xff
Lendacky, Thomas9867e8f2014-07-02 13:04:46 -0500255#define XGMAC_INIT_DMA_RX_USECS 30
256#define XGMAC_INIT_DMA_RX_FRAMES 25
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500257
258/* Flow control queue count */
259#define XGMAC_MAX_FLOW_CONTROL_QUEUES 8
260
Lendacky, Thomas43e0dcf2016-11-03 13:18:16 -0500261/* Flow control threshold units */
262#define XGMAC_FLOW_CONTROL_UNIT 512
263#define XGMAC_FLOW_CONTROL_ALIGN(_x) \
264 (((_x) + XGMAC_FLOW_CONTROL_UNIT - 1) & ~(XGMAC_FLOW_CONTROL_UNIT - 1))
265#define XGMAC_FLOW_CONTROL_VALUE(_x) \
266 (((_x) < 1024) ? 0 : ((_x) / XGMAC_FLOW_CONTROL_UNIT) - 2)
267#define XGMAC_FLOW_CONTROL_MAX 33280
268
Lendacky, Thomasb85e4d82014-06-24 16:19:29 -0500269/* Maximum MAC address hash table size (256 bits = 8 bytes) */
270#define XGBE_MAC_HASH_TABLE_SIZE 8
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500271
Lendacky, Thomas5b9dfe22014-11-04 16:07:02 -0600272/* Receive Side Scaling */
273#define XGBE_RSS_HASH_KEY_SIZE 40
274#define XGBE_RSS_MAX_TABLE_SIZE 256
275#define XGBE_RSS_LOOKUP_TABLE_TYPE 0
276#define XGBE_RSS_HASH_KEY_TYPE 1
277
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500278/* Auto-negotiation */
279#define XGBE_AN_MS_TIMEOUT 500
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500280#define XGBE_LINK_TIMEOUT 5
281
282#define XGBE_SGMII_AN_LINK_STATUS BIT(1)
283#define XGBE_SGMII_AN_LINK_SPEED (BIT(2) | BIT(3))
284#define XGBE_SGMII_AN_LINK_SPEED_100 0x04
285#define XGBE_SGMII_AN_LINK_SPEED_1000 0x08
286#define XGBE_SGMII_AN_LINK_DUPLEX BIT(4)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500287
Lendacky, Thomase78332b2016-11-10 17:10:26 -0600288/* ECC correctable error notification window (seconds) */
289#define XGBE_ECC_LIMIT 60
290
Lendacky, Thomas732f2ab2016-11-10 17:11:14 -0600291/* MDIO port types */
292#define XGMAC_MAX_C22_PORT 3
293
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500294struct xgbe_prv_data;
295
296struct xgbe_packet_data {
Lendacky, Thomas16958a22014-11-20 11:04:08 -0600297 struct sk_buff *skb;
298
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500299 unsigned int attributes;
300
301 unsigned int errors;
302
303 unsigned int rdesc_count;
304 unsigned int length;
305
306 unsigned int header_len;
307 unsigned int tcp_header_len;
308 unsigned int tcp_payload_len;
309 unsigned short mss;
310
311 unsigned short vlan_ctag;
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500312
313 u64 rx_tstamp;
Lendacky, Thomas5b9dfe22014-11-04 16:07:02 -0600314
315 u32 rss_hash;
316 enum pkt_hash_types rss_hash_type;
Lendacky, Thomas5fb4b862014-11-20 11:03:50 -0600317
318 unsigned int tx_packets;
319 unsigned int tx_bytes;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500320};
321
322/* Common Rx and Tx descriptor mapping */
323struct xgbe_ring_desc {
Lendacky, Thomas5226cfc2014-11-12 10:37:49 -0600324 __le32 desc0;
325 __le32 desc1;
326 __le32 desc2;
327 __le32 desc3;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500328};
329
Lendacky, Thomas08dcc472014-11-04 16:06:44 -0600330/* Page allocation related values */
331struct xgbe_page_alloc {
332 struct page *pages;
333 unsigned int pages_len;
334 unsigned int pages_offset;
335
336 dma_addr_t pages_dma;
337};
338
Lendacky, Thomas174fd252014-11-04 16:06:50 -0600339/* Ring entry buffer data */
340struct xgbe_buffer_data {
341 struct xgbe_page_alloc pa;
342 struct xgbe_page_alloc pa_unmap;
343
Lendacky, Thomascfbfd862015-07-06 11:57:37 -0500344 dma_addr_t dma_base;
345 unsigned long dma_off;
Lendacky, Thomas174fd252014-11-04 16:06:50 -0600346 unsigned int dma_len;
347};
348
Lendacky, Thomasc9f140e2014-11-20 11:03:44 -0600349/* Tx-related ring data */
350struct xgbe_tx_ring_data {
Lendacky, Thomas5fb4b862014-11-20 11:03:50 -0600351 unsigned int packets; /* BQL packet count */
352 unsigned int bytes; /* BQL byte count */
Lendacky, Thomasc9f140e2014-11-20 11:03:44 -0600353};
354
355/* Rx-related ring data */
356struct xgbe_rx_ring_data {
357 struct xgbe_buffer_data hdr; /* Header locations */
358 struct xgbe_buffer_data buf; /* Payload locations */
359
360 unsigned short hdr_len; /* Length of received header */
361 unsigned short len; /* Length of received packet */
362};
363
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500364/* Structure used to hold information related to the descriptor
365 * and the packet associated with the descriptor (always use
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500366 * use the XGBE_GET_DESC_DATA macro to access this data from the ring)
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500367 */
368struct xgbe_ring_data {
369 struct xgbe_ring_desc *rdesc; /* Virtual address of descriptor */
370 dma_addr_t rdesc_dma; /* DMA address of descriptor */
371
372 struct sk_buff *skb; /* Virtual address of SKB */
373 dma_addr_t skb_dma; /* DMA address of SKB data */
374 unsigned int skb_dma_len; /* Length of SKB DMA area */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500375
Lendacky, Thomasc9f140e2014-11-20 11:03:44 -0600376 struct xgbe_tx_ring_data tx; /* Tx-related data */
377 struct xgbe_rx_ring_data rx; /* Rx-related data */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500378
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500379 unsigned int mapped_as_page;
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500380
381 /* Incomplete receive save location. If the budget is exhausted
382 * or the last descriptor (last normal descriptor or a following
383 * context descriptor) has not been DMA'd yet the current state
384 * of the receive processing needs to be saved.
385 */
386 unsigned int state_saved;
387 struct {
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500388 struct sk_buff *skb;
389 unsigned int len;
390 unsigned int error;
391 } state;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500392};
393
394struct xgbe_ring {
395 /* Ring lock - used just for TX rings at the moment */
396 spinlock_t lock;
397
398 /* Per packet related information */
399 struct xgbe_packet_data packet_data;
400
401 /* Virtual/DMA addresses and count of allocated descriptor memory */
402 struct xgbe_ring_desc *rdesc;
403 dma_addr_t rdesc_dma;
404 unsigned int rdesc_count;
405
406 /* Array of descriptor data corresponding the descriptor memory
Lendacky, Thomasd0a8ba62014-06-24 16:19:06 -0500407 * (always use the XGBE_GET_DESC_DATA macro to access this data)
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500408 */
409 struct xgbe_ring_data *rdata;
410
Lendacky, Thomas08dcc472014-11-04 16:06:44 -0600411 /* Page allocation for RX buffers */
Lendacky, Thomas174fd252014-11-04 16:06:50 -0600412 struct xgbe_page_alloc rx_hdr_pa;
413 struct xgbe_page_alloc rx_buf_pa;
Lendacky, Thomas18f9f0a2017-06-28 13:42:51 -0500414 int node;
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;
Lendacky, Thomas18f9f0a2017-06-28 13:42:51 -0500465
466 int node;
Lendacky, Thomasf00ba492017-06-28 13:43:00 -0500467 cpumask_t affinity_mask;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500468} ____cacheline_aligned;
469
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500470enum xgbe_state {
471 XGBE_DOWN,
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500472 XGBE_LINK_INIT,
473 XGBE_LINK_ERR,
Lendacky, Thomase78332b2016-11-10 17:10:26 -0600474 XGBE_STOPPED,
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500475};
476
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500477enum xgbe_int {
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500478 XGMAC_INT_DMA_CH_SR_TI,
479 XGMAC_INT_DMA_CH_SR_TPS,
480 XGMAC_INT_DMA_CH_SR_TBU,
481 XGMAC_INT_DMA_CH_SR_RI,
482 XGMAC_INT_DMA_CH_SR_RBU,
483 XGMAC_INT_DMA_CH_SR_RPS,
Lendacky, Thomas9867e8f2014-07-02 13:04:46 -0500484 XGMAC_INT_DMA_CH_SR_TI_RI,
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500485 XGMAC_INT_DMA_CH_SR_FBE,
486 XGMAC_INT_DMA_ALL,
487};
488
489enum xgbe_int_state {
490 XGMAC_INT_STATE_SAVE,
491 XGMAC_INT_STATE_RESTORE,
492};
493
Lendacky, Thomase78332b2016-11-10 17:10:26 -0600494enum xgbe_ecc_sec {
495 XGBE_ECC_SEC_TX,
496 XGBE_ECC_SEC_RX,
497 XGBE_ECC_SEC_DESC,
498};
499
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500500enum xgbe_speed {
501 XGBE_SPEED_1000 = 0,
502 XGBE_SPEED_2500,
503 XGBE_SPEED_10000,
504 XGBE_SPEEDS,
505};
506
Lendacky, Thomasb03a4a62016-11-03 13:18:56 -0500507enum xgbe_xpcs_access {
508 XGBE_XPCS_ACCESS_V1 = 0,
509 XGBE_XPCS_ACCESS_V2,
510};
511
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500512enum xgbe_an_mode {
513 XGBE_AN_MODE_CL73 = 0,
Lendacky, Thomasd7445d12016-11-10 17:11:41 -0600514 XGBE_AN_MODE_CL73_REDRV,
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500515 XGBE_AN_MODE_CL37,
516 XGBE_AN_MODE_CL37_SGMII,
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500517 XGBE_AN_MODE_NONE,
518};
519
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500520enum xgbe_an {
521 XGBE_AN_READY = 0,
522 XGBE_AN_PAGE_RECEIVED,
523 XGBE_AN_INCOMPAT_LINK,
524 XGBE_AN_COMPLETE,
525 XGBE_AN_NO_LINK,
526 XGBE_AN_ERROR,
527};
528
529enum xgbe_rx {
530 XGBE_RX_BPA = 0,
531 XGBE_RX_XNP,
532 XGBE_RX_COMPLETE,
533 XGBE_RX_ERROR,
534};
535
536enum xgbe_mode {
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500537 XGBE_MODE_KX_1000 = 0,
538 XGBE_MODE_KX_2500,
539 XGBE_MODE_KR,
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -0600540 XGBE_MODE_X,
541 XGBE_MODE_SGMII_100,
542 XGBE_MODE_SGMII_1000,
543 XGBE_MODE_SFI,
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500544 XGBE_MODE_UNKNOWN,
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500545};
546
547enum xgbe_speedset {
548 XGBE_SPEEDSET_1000_10000 = 0,
549 XGBE_SPEEDSET_2500_10000,
550};
551
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -0600552enum xgbe_mdio_mode {
553 XGBE_MDIO_MODE_NONE = 0,
554 XGBE_MDIO_MODE_CL22,
555 XGBE_MDIO_MODE_CL45,
556};
557
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500558struct xgbe_phy {
559 u32 supported;
560 u32 advertising;
561 u32 lp_advertising;
562
563 int address;
564
565 int autoneg;
566 int speed;
567 int duplex;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500568
569 int link;
Lendacky, Thomasc1ce2f72015-05-14 11:44:27 -0500570
571 int pause_autoneg;
572 int tx_pause;
573 int rx_pause;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500574};
575
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -0600576enum xgbe_i2c_cmd {
577 XGBE_I2C_CMD_READ = 0,
578 XGBE_I2C_CMD_WRITE,
579};
580
581struct xgbe_i2c_op {
582 enum xgbe_i2c_cmd cmd;
583
584 unsigned int target;
585
586 void *buf;
587 unsigned int len;
588};
589
590struct xgbe_i2c_op_state {
591 struct xgbe_i2c_op *op;
592
593 unsigned int tx_len;
594 unsigned char *tx_buf;
595
596 unsigned int rx_len;
597 unsigned char *rx_buf;
598
599 unsigned int tx_abort_source;
600
601 int ret;
602};
603
604struct xgbe_i2c {
605 unsigned int started;
606 unsigned int max_speed_mode;
607 unsigned int rx_fifo_size;
608 unsigned int tx_fifo_size;
609
610 struct xgbe_i2c_op_state op_state;
611};
612
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500613struct xgbe_mmc_stats {
614 /* Tx Stats */
615 u64 txoctetcount_gb;
616 u64 txframecount_gb;
617 u64 txbroadcastframes_g;
618 u64 txmulticastframes_g;
619 u64 tx64octets_gb;
620 u64 tx65to127octets_gb;
621 u64 tx128to255octets_gb;
622 u64 tx256to511octets_gb;
623 u64 tx512to1023octets_gb;
624 u64 tx1024tomaxoctets_gb;
625 u64 txunicastframes_gb;
626 u64 txmulticastframes_gb;
627 u64 txbroadcastframes_gb;
628 u64 txunderflowerror;
629 u64 txoctetcount_g;
630 u64 txframecount_g;
631 u64 txpauseframes;
632 u64 txvlanframes_g;
633
634 /* Rx Stats */
635 u64 rxframecount_gb;
636 u64 rxoctetcount_gb;
637 u64 rxoctetcount_g;
638 u64 rxbroadcastframes_g;
639 u64 rxmulticastframes_g;
640 u64 rxcrcerror;
641 u64 rxrunterror;
642 u64 rxjabbererror;
643 u64 rxundersize_g;
644 u64 rxoversize_g;
645 u64 rx64octets_gb;
646 u64 rx65to127octets_gb;
647 u64 rx128to255octets_gb;
648 u64 rx256to511octets_gb;
649 u64 rx512to1023octets_gb;
650 u64 rx1024tomaxoctets_gb;
651 u64 rxunicastframes_g;
652 u64 rxlengtherror;
653 u64 rxoutofrangetype;
654 u64 rxpauseframes;
655 u64 rxfifooverflow;
656 u64 rxvlanframes_gb;
657 u64 rxwatchdogerror;
658};
659
Lendacky, Thomas5452b2d2015-05-14 11:43:57 -0500660struct xgbe_ext_stats {
661 u64 tx_tso_packets;
662 u64 rx_split_header_packets;
Lendacky, Thomas72c9ac42015-09-30 08:53:10 -0500663 u64 rx_buffer_unavailable;
Lendacky, Thomas5452b2d2015-05-14 11:43:57 -0500664};
665
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500666struct xgbe_hw_if {
667 int (*tx_complete)(struct xgbe_ring_desc *);
668
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500669 int (*set_mac_address)(struct xgbe_prv_data *, u8 *addr);
Lendacky, Thomasb8763822015-04-09 12:11:57 -0500670 int (*config_rx_mode)(struct xgbe_prv_data *);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500671
672 int (*enable_rx_csum)(struct xgbe_prv_data *);
673 int (*disable_rx_csum)(struct xgbe_prv_data *);
674
675 int (*enable_rx_vlan_stripping)(struct xgbe_prv_data *);
676 int (*disable_rx_vlan_stripping)(struct xgbe_prv_data *);
Lendacky, Thomas801c62d2014-06-24 16:19:24 -0500677 int (*enable_rx_vlan_filtering)(struct xgbe_prv_data *);
678 int (*disable_rx_vlan_filtering)(struct xgbe_prv_data *);
679 int (*update_vlan_hash_table)(struct xgbe_prv_data *);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500680
681 int (*read_mmd_regs)(struct xgbe_prv_data *, int, int);
682 void (*write_mmd_regs)(struct xgbe_prv_data *, int, int, int);
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500683 int (*set_speed)(struct xgbe_prv_data *, int);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500684
Lendacky, Thomas732f2ab2016-11-10 17:11:14 -0600685 int (*set_ext_mii_mode)(struct xgbe_prv_data *, unsigned int,
686 enum xgbe_mdio_mode);
687 int (*read_ext_mii_regs)(struct xgbe_prv_data *, int, int);
688 int (*write_ext_mii_regs)(struct xgbe_prv_data *, int, int, u16);
689
690 int (*set_gpio)(struct xgbe_prv_data *, unsigned int);
691 int (*clr_gpio)(struct xgbe_prv_data *, unsigned int);
692
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500693 void (*enable_tx)(struct xgbe_prv_data *);
694 void (*disable_tx)(struct xgbe_prv_data *);
695 void (*enable_rx)(struct xgbe_prv_data *);
696 void (*disable_rx)(struct xgbe_prv_data *);
697
698 void (*powerup_tx)(struct xgbe_prv_data *);
699 void (*powerdown_tx)(struct xgbe_prv_data *);
700 void (*powerup_rx)(struct xgbe_prv_data *);
701 void (*powerdown_rx)(struct xgbe_prv_data *);
702
703 int (*init)(struct xgbe_prv_data *);
704 int (*exit)(struct xgbe_prv_data *);
705
706 int (*enable_int)(struct xgbe_channel *, enum xgbe_int);
707 int (*disable_int)(struct xgbe_channel *, enum xgbe_int);
Lendacky, Thomasa9d41982014-11-04 16:06:32 -0600708 void (*dev_xmit)(struct xgbe_channel *);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500709 int (*dev_read)(struct xgbe_channel *);
710 void (*tx_desc_init)(struct xgbe_channel *);
711 void (*rx_desc_init)(struct xgbe_channel *);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500712 void (*tx_desc_reset)(struct xgbe_ring_data *);
Lendacky, Thomas8dee19e2015-04-09 12:11:51 -0500713 void (*rx_desc_reset)(struct xgbe_prv_data *, struct xgbe_ring_data *,
714 unsigned int);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500715 int (*is_last_desc)(struct xgbe_ring_desc *);
716 int (*is_context_desc)(struct xgbe_ring_desc *);
Lendacky, Thomas16958a22014-11-20 11:04:08 -0600717 void (*tx_start_xmit)(struct xgbe_channel *, struct xgbe_ring *);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500718
719 /* For FLOW ctrl */
720 int (*config_tx_flow_control)(struct xgbe_prv_data *);
721 int (*config_rx_flow_control)(struct xgbe_prv_data *);
722
723 /* For RX coalescing */
724 int (*config_rx_coalesce)(struct xgbe_prv_data *);
725 int (*config_tx_coalesce)(struct xgbe_prv_data *);
726 unsigned int (*usec_to_riwt)(struct xgbe_prv_data *, unsigned int);
727 unsigned int (*riwt_to_usec)(struct xgbe_prv_data *, unsigned int);
728
729 /* For RX and TX threshold config */
730 int (*config_rx_threshold)(struct xgbe_prv_data *, unsigned int);
731 int (*config_tx_threshold)(struct xgbe_prv_data *, unsigned int);
732
733 /* For RX and TX Store and Forward Mode config */
734 int (*config_rsf_mode)(struct xgbe_prv_data *, unsigned int);
735 int (*config_tsf_mode)(struct xgbe_prv_data *, unsigned int);
736
737 /* For TX DMA Operate on Second Frame config */
738 int (*config_osp_mode)(struct xgbe_prv_data *);
739
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500740 /* For MMC statistics */
741 void (*rx_mmc_int)(struct xgbe_prv_data *);
742 void (*tx_mmc_int)(struct xgbe_prv_data *);
743 void (*read_mmc_stats)(struct xgbe_prv_data *);
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -0500744
745 /* For Timestamp config */
746 int (*config_tstamp)(struct xgbe_prv_data *, unsigned int);
747 void (*update_tstamp_addend)(struct xgbe_prv_data *, unsigned int);
748 void (*set_tstamp_time)(struct xgbe_prv_data *, unsigned int sec,
749 unsigned int nsec);
750 u64 (*get_tstamp_time)(struct xgbe_prv_data *);
751 u64 (*get_tx_tstamp)(struct xgbe_prv_data *);
Lendacky, Thomasfca2d992014-07-29 08:57:55 -0500752
753 /* For Data Center Bridging config */
Lendacky, Thomasb3b71592016-02-17 11:49:08 -0600754 void (*config_tc)(struct xgbe_prv_data *);
Lendacky, Thomasfca2d992014-07-29 08:57:55 -0500755 void (*config_dcb_tc)(struct xgbe_prv_data *);
756 void (*config_dcb_pfc)(struct xgbe_prv_data *);
Lendacky, Thomas5b9dfe22014-11-04 16:07:02 -0600757
758 /* For Receive Side Scaling */
759 int (*enable_rss)(struct xgbe_prv_data *);
760 int (*disable_rss)(struct xgbe_prv_data *);
Lendacky, Thomasf6ac8622014-11-04 16:07:23 -0600761 int (*set_rss_hash_key)(struct xgbe_prv_data *, const u8 *);
762 int (*set_rss_lookup_table)(struct xgbe_prv_data *, const u32 *);
Lendacky, Thomase78332b2016-11-10 17:10:26 -0600763
764 /* For ECC */
765 void (*disable_ecc_ded)(struct xgbe_prv_data *);
766 void (*disable_ecc_sec)(struct xgbe_prv_data *, enum xgbe_ecc_sec);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500767};
768
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500769/* This structure represents implementation specific routines for an
770 * implementation of a PHY. All routines are required unless noted below.
771 * Optional routines:
772 * kr_training_pre, kr_training_post
773 */
774struct xgbe_phy_impl_if {
775 /* Perform Setup/teardown actions */
776 int (*init)(struct xgbe_prv_data *);
777 void (*exit)(struct xgbe_prv_data *);
778
779 /* Perform start/stop specific actions */
780 int (*reset)(struct xgbe_prv_data *);
781 int (*start)(struct xgbe_prv_data *);
782 void (*stop)(struct xgbe_prv_data *);
783
784 /* Return the link status */
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -0600785 int (*link_status)(struct xgbe_prv_data *, int *);
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500786
787 /* Indicate if a particular speed is valid */
788 bool (*valid_speed)(struct xgbe_prv_data *, int);
789
790 /* Check if the specified mode can/should be used */
791 bool (*use_mode)(struct xgbe_prv_data *, enum xgbe_mode);
792 /* Switch the PHY into various modes */
793 void (*set_mode)(struct xgbe_prv_data *, enum xgbe_mode);
794 /* Retrieve mode needed for a specific speed */
795 enum xgbe_mode (*get_mode)(struct xgbe_prv_data *, int);
796 /* Retrieve new/next mode when trying to auto-negotiate */
797 enum xgbe_mode (*switch_mode)(struct xgbe_prv_data *);
798 /* Retrieve current mode */
799 enum xgbe_mode (*cur_mode)(struct xgbe_prv_data *);
800
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500801 /* Retrieve current auto-negotiation mode */
802 enum xgbe_an_mode (*an_mode)(struct xgbe_prv_data *);
803
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -0600804 /* Configure auto-negotiation settings */
805 int (*an_config)(struct xgbe_prv_data *);
806
Lendacky, Thomasd7445d12016-11-10 17:11:41 -0600807 /* Set/override auto-negotiation advertisement settings */
808 unsigned int (*an_advertising)(struct xgbe_prv_data *);
809
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500810 /* Process results of auto-negotiation */
811 enum xgbe_mode (*an_outcome)(struct xgbe_prv_data *);
812
813 /* Pre/Post KR training enablement support */
814 void (*kr_training_pre)(struct xgbe_prv_data *);
815 void (*kr_training_post)(struct xgbe_prv_data *);
816};
817
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500818struct xgbe_phy_if {
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500819 /* For PHY setup/teardown */
820 int (*phy_init)(struct xgbe_prv_data *);
821 void (*phy_exit)(struct xgbe_prv_data *);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500822
823 /* For PHY support when setting device up/down */
824 int (*phy_reset)(struct xgbe_prv_data *);
825 int (*phy_start)(struct xgbe_prv_data *);
826 void (*phy_stop)(struct xgbe_prv_data *);
827
828 /* For PHY support while device is up */
829 void (*phy_status)(struct xgbe_prv_data *);
830 int (*phy_config_aneg)(struct xgbe_prv_data *);
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500831
832 /* For PHY settings validation */
833 bool (*phy_valid_speed)(struct xgbe_prv_data *, int);
834
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600835 /* For single interrupt support */
Lendacky, Thomas85b85c82017-06-28 13:42:42 -0500836 irqreturn_t (*an_isr)(struct xgbe_prv_data *);
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600837
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500838 /* PHY implementation specific services */
839 struct xgbe_phy_impl_if phy_impl;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500840};
841
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -0600842struct xgbe_i2c_if {
843 /* For initial I2C setup */
844 int (*i2c_init)(struct xgbe_prv_data *);
845
846 /* For I2C support when setting device up/down */
847 int (*i2c_start)(struct xgbe_prv_data *);
848 void (*i2c_stop)(struct xgbe_prv_data *);
849
850 /* For performing I2C operations */
851 int (*i2c_xfer)(struct xgbe_prv_data *, struct xgbe_i2c_op *);
852
853 /* For single interrupt support */
Lendacky, Thomas85b85c82017-06-28 13:42:42 -0500854 irqreturn_t (*i2c_isr)(struct xgbe_prv_data *);
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -0600855};
856
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500857struct xgbe_desc_if {
858 int (*alloc_ring_resources)(struct xgbe_prv_data *);
859 void (*free_ring_resources)(struct xgbe_prv_data *);
860 int (*map_tx_skb)(struct xgbe_channel *, struct sk_buff *);
Lendacky, Thomas270894e2015-01-16 12:46:50 -0600861 int (*map_rx_buffer)(struct xgbe_prv_data *, struct xgbe_ring *,
862 struct xgbe_ring_data *);
Lendacky, Thomas08dcc472014-11-04 16:06:44 -0600863 void (*unmap_rdata)(struct xgbe_prv_data *, struct xgbe_ring_data *);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500864 void (*wrapper_tx_desc_init)(struct xgbe_prv_data *);
865 void (*wrapper_rx_desc_init)(struct xgbe_prv_data *);
866};
867
868/* This structure contains flags that indicate what hardware features
869 * or configurations are present in the device.
870 */
871struct xgbe_hw_features {
Lendacky, Thomasa9a4a2d2014-08-29 13:16:50 -0500872 /* HW Version */
873 unsigned int version;
874
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500875 /* HW Feature Register0 */
876 unsigned int gmii; /* 1000 Mbps support */
877 unsigned int vlhash; /* VLAN Hash Filter */
878 unsigned int sma; /* SMA(MDIO) Interface */
879 unsigned int rwk; /* PMT remote wake-up packet */
880 unsigned int mgk; /* PMT magic packet */
881 unsigned int mmc; /* RMON module */
882 unsigned int aoe; /* ARP Offload */
Joe Perchesdbedd442015-03-06 20:49:12 -0800883 unsigned int ts; /* IEEE 1588-2008 Advanced Timestamp */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500884 unsigned int eee; /* Energy Efficient Ethernet */
885 unsigned int tx_coe; /* Tx Checksum Offload */
886 unsigned int rx_coe; /* Rx Checksum Offload */
887 unsigned int addn_mac; /* Additional MAC Addresses */
888 unsigned int ts_src; /* Timestamp Source */
889 unsigned int sa_vlan_ins; /* Source Address or VLAN Insertion */
890
891 /* HW Feature Register1 */
892 unsigned int rx_fifo_size; /* MTL Receive FIFO Size */
893 unsigned int tx_fifo_size; /* MTL Transmit FIFO Size */
894 unsigned int adv_ts_hi; /* Advance Timestamping High Word */
Lendacky, Thomas386d3252015-03-20 11:50:22 -0500895 unsigned int dma_width; /* DMA width */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500896 unsigned int dcb; /* DCB Feature */
897 unsigned int sph; /* Split Header Feature */
898 unsigned int tso; /* TCP Segmentation Offload */
899 unsigned int dma_debug; /* DMA Debug Registers */
900 unsigned int rss; /* Receive Side Scaling */
Lendacky, Thomasfca2d992014-07-29 08:57:55 -0500901 unsigned int tc_cnt; /* Number of Traffic Classes */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500902 unsigned int hash_table_size; /* Hash Table Size */
903 unsigned int l3l4_filter_num; /* Number of L3-L4 Filters */
904
905 /* HW Feature Register2 */
906 unsigned int rx_q_cnt; /* Number of MTL Receive Queues */
907 unsigned int tx_q_cnt; /* Number of MTL Transmit Queues */
908 unsigned int rx_ch_cnt; /* Number of DMA Receive Channels */
909 unsigned int tx_ch_cnt; /* Number of DMA Transmit Channels */
910 unsigned int pps_out_num; /* Number of PPS outputs */
911 unsigned int aux_snap_num; /* Number of Aux snapshot inputs */
912};
913
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500914struct xgbe_version_data {
915 void (*init_function_ptrs_phy_impl)(struct xgbe_phy_if *);
Lendacky, Thomasb03a4a62016-11-03 13:18:56 -0500916 enum xgbe_xpcs_access xpcs_access;
Lendacky, Thomase5a20b92016-11-03 13:19:07 -0500917 unsigned int mmc_64bit;
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -0500918 unsigned int tx_max_fifo_size;
919 unsigned int rx_max_fifo_size;
Lendacky, Thomasaba97772016-11-10 17:09:45 -0600920 unsigned int tx_tstamp_workaround;
Lendacky, Thomase78332b2016-11-10 17:10:26 -0600921 unsigned int ecc_support;
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -0600922 unsigned int i2c_support;
Lendacky, Thomas85b85c82017-06-28 13:42:42 -0500923 unsigned int irq_reissue_support;
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500924};
925
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500926struct xgbe_prv_data {
927 struct net_device *netdev;
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600928 struct pci_dev *pcidev;
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -0500929 struct platform_device *platdev;
Lendacky, Thomas82a19032015-01-16 12:47:16 -0600930 struct acpi_device *adev;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500931 struct device *dev;
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -0500932 struct platform_device *phy_platdev;
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500933 struct device *phy_dev;
934
935 /* Version related data */
936 struct xgbe_version_data *vdata;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500937
Lendacky, Thomas82a19032015-01-16 12:47:16 -0600938 /* ACPI or DT flag */
939 unsigned int use_acpi;
940
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500941 /* XGMAC/XPCS related mmio registers */
942 void __iomem *xgmac_regs; /* XGMAC CSRs */
943 void __iomem *xpcs_regs; /* XPCS MMD registers */
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500944 void __iomem *rxtx_regs; /* SerDes Rx/Tx CSRs */
945 void __iomem *sir0_regs; /* SerDes integration registers (1/2) */
946 void __iomem *sir1_regs; /* SerDes integration registers (2/2) */
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600947 void __iomem *xprop_regs; /* XGBE property registers */
948 void __iomem *xi2c_regs; /* XGBE I2C CSRs */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500949
950 /* Overall device lock */
951 spinlock_t lock;
952
Lendacky, Thomasced3fca2016-02-17 11:49:28 -0600953 /* XPCS indirect addressing lock */
954 spinlock_t xpcs_lock;
Lendacky, Thomas4eccbfc2017-01-20 12:14:03 -0600955 unsigned int xpcs_window_def_reg;
956 unsigned int xpcs_window_sel_reg;
Lendacky, Thomasb03a4a62016-11-03 13:18:56 -0500957 unsigned int xpcs_window;
958 unsigned int xpcs_window_size;
959 unsigned int xpcs_window_mask;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500960
Lendacky, Thomas5b9dfe22014-11-04 16:07:02 -0600961 /* RSS addressing mutex */
962 struct mutex rss_mutex;
963
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500964 /* Flags representing xgbe_state */
965 unsigned long dev_state;
966
Lendacky, Thomase78332b2016-11-10 17:10:26 -0600967 /* ECC support */
968 unsigned long tx_sec_period;
969 unsigned long tx_ded_period;
970 unsigned long rx_sec_period;
971 unsigned long rx_ded_period;
972 unsigned long desc_sec_period;
973 unsigned long desc_ded_period;
974
975 unsigned int tx_sec_count;
976 unsigned int tx_ded_count;
977 unsigned int rx_sec_count;
978 unsigned int rx_ded_count;
979 unsigned int desc_ded_count;
980 unsigned int desc_sec_count;
981
Lendacky, Thomas9227dc52014-11-04 16:06:56 -0600982 int dev_irq;
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600983 int ecc_irq;
984 int i2c_irq;
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -0500985 int channel_irq[XGBE_MAX_DMA_CHANNELS];
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500986
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600987 unsigned int per_channel_irq;
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600988 unsigned int irq_count;
989 unsigned int channel_irq_count;
Lendacky, Thomas4c70dd82016-11-10 17:10:17 -0600990 unsigned int channel_irq_mode;
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600991
Lendacky, Thomase78332b2016-11-10 17:10:26 -0600992 char ecc_name[IFNAMSIZ + 32];
993
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500994 struct xgbe_hw_if hw_if;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500995 struct xgbe_phy_if phy_if;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500996 struct xgbe_desc_if desc_if;
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -0600997 struct xgbe_i2c_if i2c_if;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500998
Lendacky, Thomascfa50c72014-07-02 13:04:57 -0500999 /* AXI DMA settings */
Lendacky, Thomas82a19032015-01-16 12:47:16 -06001000 unsigned int coherent;
Lendacky, Thomas99167162017-06-28 13:43:09 -05001001 unsigned int arcr;
1002 unsigned int awcr;
Lendacky, Thomascfa50c72014-07-02 13:04:57 -05001003
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001004 /* Service routine support */
1005 struct workqueue_struct *dev_workqueue;
1006 struct work_struct service_work;
1007 struct timer_list service_timer;
1008
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001009 /* Rings for Tx/Rx on a DMA channel */
Lendacky, Thomas18f9f0a2017-06-28 13:42:51 -05001010 struct xgbe_channel *channel[XGBE_MAX_DMA_CHANNELS];
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -05001011 unsigned int tx_max_channel_count;
1012 unsigned int rx_max_channel_count;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001013 unsigned int channel_count;
1014 unsigned int tx_ring_count;
1015 unsigned int tx_desc_count;
1016 unsigned int rx_ring_count;
1017 unsigned int rx_desc_count;
1018
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -05001019 unsigned int tx_max_q_count;
1020 unsigned int rx_max_q_count;
Lendacky, Thomas853eb162014-07-29 08:57:31 -05001021 unsigned int tx_q_count;
1022 unsigned int rx_q_count;
1023
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001024 /* Tx/Rx common settings */
Lendacky, Thomas7e1e6b82017-06-28 13:43:18 -05001025 unsigned int blen;
1026 unsigned int pbl;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001027
1028 /* Tx settings */
1029 unsigned int tx_sf_mode;
1030 unsigned int tx_threshold;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001031 unsigned int tx_osp_mode;
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -05001032 unsigned int tx_max_fifo_size;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001033
1034 /* Rx settings */
1035 unsigned int rx_sf_mode;
1036 unsigned int rx_threshold;
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -05001037 unsigned int rx_max_fifo_size;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001038
1039 /* Tx coalescing settings */
1040 unsigned int tx_usecs;
1041 unsigned int tx_frames;
1042
1043 /* Rx coalescing settings */
1044 unsigned int rx_riwt;
Lendacky, Thomas4a57ebc2015-03-20 11:50:34 -05001045 unsigned int rx_usecs;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001046 unsigned int rx_frames;
1047
Lendacky, Thomas08dcc472014-11-04 16:06:44 -06001048 /* Current Rx buffer size */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001049 unsigned int rx_buf_size;
1050
1051 /* Flow control settings */
1052 unsigned int pause_autoneg;
1053 unsigned int tx_pause;
1054 unsigned int rx_pause;
Lendacky, Thomas43e0dcf2016-11-03 13:18:16 -05001055 unsigned int rx_rfa[XGBE_MAX_QUEUES];
1056 unsigned int rx_rfd[XGBE_MAX_QUEUES];
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001057
Lendacky, Thomas5b9dfe22014-11-04 16:07:02 -06001058 /* Receive Side Scaling settings */
1059 u8 rss_key[XGBE_RSS_HASH_KEY_SIZE];
1060 u32 rss_table[XGBE_RSS_MAX_TABLE_SIZE];
1061 u32 rss_options;
1062
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001063 /* Netdev related settings */
Lendacky, Thomas82a19032015-01-16 12:47:16 -06001064 unsigned char mac_addr[ETH_ALEN];
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001065 netdev_features_t netdev_features;
1066 struct napi_struct napi;
1067 struct xgbe_mmc_stats mmc_stats;
Lendacky, Thomas5452b2d2015-05-14 11:43:57 -05001068 struct xgbe_ext_stats ext_stats;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001069
Lendacky, Thomas801c62d2014-06-24 16:19:24 -05001070 /* Filtering support */
1071 unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
1072
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -05001073 /* Device clocks */
1074 struct clk *sysclk;
Lendacky, Thomas82a19032015-01-16 12:47:16 -06001075 unsigned long sysclk_rate;
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -05001076 struct clk *ptpclk;
Lendacky, Thomas82a19032015-01-16 12:47:16 -06001077 unsigned long ptpclk_rate;
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -05001078
1079 /* Timestamp support */
1080 spinlock_t tstamp_lock;
1081 struct ptp_clock_info ptp_clock_info;
1082 struct ptp_clock *ptp_clock;
1083 struct hwtstamp_config tstamp_config;
1084 struct cyclecounter tstamp_cc;
1085 struct timecounter tstamp_tc;
1086 unsigned int tstamp_addend;
1087 struct work_struct tx_tstamp_work;
1088 struct sk_buff *tx_tstamp_skb;
1089 u64 tx_tstamp;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001090
Lendacky, Thomasfca2d992014-07-29 08:57:55 -05001091 /* DCB support */
1092 struct ieee_ets *ets;
1093 struct ieee_pfc *pfc;
1094 unsigned int q2tc_map[XGBE_MAX_QUEUES];
1095 unsigned int prio2q_map[IEEE_8021QAZ_MAX_TCS];
Lendacky, Thomas43e0dcf2016-11-03 13:18:16 -05001096 unsigned int pfcq[XGBE_MAX_QUEUES];
1097 unsigned int pfc_rfa;
Lendacky, Thomasb3b71592016-02-17 11:49:08 -06001098 u8 num_tcs;
Lendacky, Thomasfca2d992014-07-29 08:57:55 -05001099
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001100 /* Hardware features of the device */
1101 struct xgbe_hw_features hw_feat;
1102
Lendacky, Thomase78332b2016-11-10 17:10:26 -06001103 /* Device work structures */
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001104 struct work_struct restart_work;
Lendacky, Thomase78332b2016-11-10 17:10:26 -06001105 struct work_struct stopdev_work;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001106
1107 /* Keeps track of power mode */
1108 unsigned int power_down;
1109
Lendacky, Thomas34bf65d2015-05-14 11:44:03 -05001110 /* Network interface message level setting */
1111 u32 msg_enable;
1112
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001113 /* Current PHY settings */
1114 phy_interface_t phy_mode;
1115 int phy_link;
1116 int phy_speed;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001117
1118 /* MDIO/PHY related settings */
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001119 unsigned int phy_started;
1120 void *phy_data;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001121 struct xgbe_phy phy;
1122 int mdio_mmd;
1123 unsigned long link_check;
Lendacky, Thomas732f2ab2016-11-10 17:11:14 -06001124 struct completion mdio_complete;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001125
Lendacky, Thomasd7445d12016-11-10 17:11:41 -06001126 unsigned int kr_redrv;
1127
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001128 char an_name[IFNAMSIZ + 32];
1129 struct workqueue_struct *an_workqueue;
1130
1131 int an_irq;
1132 struct work_struct an_irq_work;
1133
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001134 /* Auto-negotiation state machine support */
Lendacky, Thomasced3fca2016-02-17 11:49:28 -06001135 unsigned int an_int;
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -05001136 unsigned int an_status;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001137 struct mutex an_mutex;
1138 enum xgbe_an an_result;
1139 enum xgbe_an an_state;
1140 enum xgbe_rx kr_state;
1141 enum xgbe_rx kx_state;
1142 struct work_struct an_work;
1143 unsigned int an_supported;
1144 unsigned int parallel_detect;
1145 unsigned int fec_ability;
1146 unsigned long an_start;
Lendacky, Thomasa64def42016-11-03 13:18:38 -05001147 enum xgbe_an_mode an_mode;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001148
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -06001149 /* I2C support */
1150 struct xgbe_i2c i2c;
1151 struct mutex i2c_mutex;
1152 struct completion i2c_complete;
1153 char i2c_name[IFNAMSIZ + 32];
1154
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001155 unsigned int lpm_ctrl; /* CTRL1 for resume */
1156
Lendacky, Thomas85b85c82017-06-28 13:42:42 -05001157 unsigned int isr_as_tasklet;
1158 struct tasklet_struct tasklet_dev;
1159 struct tasklet_struct tasklet_ecc;
1160 struct tasklet_struct tasklet_i2c;
1161 struct tasklet_struct tasklet_an;
1162
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001163#ifdef CONFIG_DEBUG_FS
1164 struct dentry *xgbe_debugfs;
1165
1166 unsigned int debugfs_xgmac_reg;
1167
1168 unsigned int debugfs_xpcs_mmd;
1169 unsigned int debugfs_xpcs_reg;
Lendacky, Thomas47f164d2016-11-10 17:09:55 -06001170
1171 unsigned int debugfs_xprop_reg;
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -06001172
1173 unsigned int debugfs_xi2c_reg;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001174#endif
1175};
1176
1177/* Function prototypes*/
Lendacky, Thomasbd8255d2016-11-03 13:19:27 -05001178struct xgbe_prv_data *xgbe_alloc_pdata(struct device *);
1179void xgbe_free_pdata(struct xgbe_prv_data *);
1180void xgbe_set_counts(struct xgbe_prv_data *);
1181int xgbe_config_netdev(struct xgbe_prv_data *);
1182void xgbe_deconfig_netdev(struct xgbe_prv_data *);
1183
1184int xgbe_platform_init(void);
1185void xgbe_platform_exit(void);
Lendacky, Thomas47f164d2016-11-10 17:09:55 -06001186#ifdef CONFIG_PCI
1187int xgbe_pci_init(void);
1188void xgbe_pci_exit(void);
1189#else
1190static inline int xgbe_pci_init(void) { return 0; }
1191static inline void xgbe_pci_exit(void) { }
1192#endif
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001193
1194void xgbe_init_function_ptrs_dev(struct xgbe_hw_if *);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001195void xgbe_init_function_ptrs_phy(struct xgbe_phy_if *);
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001196void xgbe_init_function_ptrs_phy_v1(struct xgbe_phy_if *);
Lendacky, Thomas47f164d2016-11-10 17:09:55 -06001197void xgbe_init_function_ptrs_phy_v2(struct xgbe_phy_if *);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001198void xgbe_init_function_ptrs_desc(struct xgbe_desc_if *);
Lendacky, Thomas5ab1dcd2016-11-10 17:10:36 -06001199void xgbe_init_function_ptrs_i2c(struct xgbe_i2c_if *);
stephen hemmingerce0b15d2016-08-31 08:57:36 -07001200const struct net_device_ops *xgbe_get_netdev_ops(void);
1201const struct ethtool_ops *xgbe_get_ethtool_ops(void);
1202
Lendacky, Thomasfca2d992014-07-29 08:57:55 -05001203#ifdef CONFIG_AMD_XGBE_DCB
1204const struct dcbnl_rtnl_ops *xgbe_get_dcbnl_ops(void);
1205#endif
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001206
Lendacky, Thomas23e4eef2014-07-29 08:57:19 -05001207void xgbe_ptp_register(struct xgbe_prv_data *);
1208void xgbe_ptp_unregister(struct xgbe_prv_data *);
Lendacky, Thomas34bf65d2015-05-14 11:44:03 -05001209void xgbe_dump_tx_desc(struct xgbe_prv_data *, struct xgbe_ring *,
1210 unsigned int, unsigned int, unsigned int);
1211void xgbe_dump_rx_desc(struct xgbe_prv_data *, struct xgbe_ring *,
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001212 unsigned int);
1213void xgbe_print_pkt(struct net_device *, struct sk_buff *, bool);
1214void xgbe_get_all_hw_features(struct xgbe_prv_data *);
1215int xgbe_powerup(struct net_device *, unsigned int);
1216int xgbe_powerdown(struct net_device *, unsigned int);
1217void xgbe_init_rx_coalesce(struct xgbe_prv_data *);
1218void xgbe_init_tx_coalesce(struct xgbe_prv_data *);
1219
1220#ifdef CONFIG_DEBUG_FS
1221void xgbe_debugfs_init(struct xgbe_prv_data *);
1222void xgbe_debugfs_exit(struct xgbe_prv_data *);
1223#else
1224static inline void xgbe_debugfs_init(struct xgbe_prv_data *pdata) {}
1225static inline void xgbe_debugfs_exit(struct xgbe_prv_data *pdata) {}
1226#endif /* CONFIG_DEBUG_FS */
1227
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001228/* NOTE: Uncomment for function trace log messages in KERNEL LOG */
1229#if 0
1230#define YDEBUG
1231#define YDEBUG_MDIO
1232#endif
1233
1234/* For debug prints */
1235#ifdef YDEBUG
1236#define DBGPR(x...) pr_alert(x)
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001237#else
1238#define DBGPR(x...) do { } while (0)
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001239#endif
1240
1241#ifdef YDEBUG_MDIO
1242#define DBGPR_MDIO(x...) pr_alert(x)
1243#else
1244#define DBGPR_MDIO(x...) do { } while (0)
1245#endif
1246
1247#endif