18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * AMD 10Gb Ethernet driver 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * This file is available to you under your choice of the following two 58c2ecf20Sopenharmony_ci * licenses: 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * License 1: GPLv2 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * Copyright (c) 2014-2016 Advanced Micro Devices, Inc. 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * This file is free software; you may copy, redistribute and/or modify 128c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License as published by 138c2ecf20Sopenharmony_ci * the Free Software Foundation, either version 2 of the License, or (at 148c2ecf20Sopenharmony_ci * your option) any later version. 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * This file is distributed in the hope that it will be useful, but 178c2ecf20Sopenharmony_ci * WITHOUT ANY WARRANTY; without even the implied warranty of 188c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 198c2ecf20Sopenharmony_ci * General Public License for more details. 208c2ecf20Sopenharmony_ci * 218c2ecf20Sopenharmony_ci * You should have received a copy of the GNU General Public License 228c2ecf20Sopenharmony_ci * along with this program. If not, see <http://www.gnu.org/licenses/>. 238c2ecf20Sopenharmony_ci * 248c2ecf20Sopenharmony_ci * This file incorporates work covered by the following copyright and 258c2ecf20Sopenharmony_ci * permission notice: 268c2ecf20Sopenharmony_ci * The Synopsys DWC ETHER XGMAC Software Driver and documentation 278c2ecf20Sopenharmony_ci * (hereinafter "Software") is an unsupported proprietary work of Synopsys, 288c2ecf20Sopenharmony_ci * Inc. unless otherwise expressly agreed to in writing between Synopsys 298c2ecf20Sopenharmony_ci * and you. 308c2ecf20Sopenharmony_ci * 318c2ecf20Sopenharmony_ci * The Software IS NOT an item of Licensed Software or Licensed Product 328c2ecf20Sopenharmony_ci * under any End User Software License Agreement or Agreement for Licensed 338c2ecf20Sopenharmony_ci * Product with Synopsys or any supplement thereto. Permission is hereby 348c2ecf20Sopenharmony_ci * granted, free of charge, to any person obtaining a copy of this software 358c2ecf20Sopenharmony_ci * annotated with this license and the Software, to deal in the Software 368c2ecf20Sopenharmony_ci * without restriction, including without limitation the rights to use, 378c2ecf20Sopenharmony_ci * copy, modify, merge, publish, distribute, sublicense, and/or sell copies 388c2ecf20Sopenharmony_ci * of the Software, and to permit persons to whom the Software is furnished 398c2ecf20Sopenharmony_ci * to do so, subject to the following conditions: 408c2ecf20Sopenharmony_ci * 418c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included 428c2ecf20Sopenharmony_ci * in all copies or substantial portions of the Software. 438c2ecf20Sopenharmony_ci * 448c2ecf20Sopenharmony_ci * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" 458c2ecf20Sopenharmony_ci * BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 468c2ecf20Sopenharmony_ci * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 478c2ecf20Sopenharmony_ci * PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS 488c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 498c2ecf20Sopenharmony_ci * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 508c2ecf20Sopenharmony_ci * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 518c2ecf20Sopenharmony_ci * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 528c2ecf20Sopenharmony_ci * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 538c2ecf20Sopenharmony_ci * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 548c2ecf20Sopenharmony_ci * THE POSSIBILITY OF SUCH DAMAGE. 558c2ecf20Sopenharmony_ci * 568c2ecf20Sopenharmony_ci * 578c2ecf20Sopenharmony_ci * License 2: Modified BSD 588c2ecf20Sopenharmony_ci * 598c2ecf20Sopenharmony_ci * Copyright (c) 2014-2016 Advanced Micro Devices, Inc. 608c2ecf20Sopenharmony_ci * All rights reserved. 618c2ecf20Sopenharmony_ci * 628c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without 638c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions are met: 648c2ecf20Sopenharmony_ci * * Redistributions of source code must retain the above copyright 658c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer. 668c2ecf20Sopenharmony_ci * * Redistributions in binary form must reproduce the above copyright 678c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer in the 688c2ecf20Sopenharmony_ci * documentation and/or other materials provided with the distribution. 698c2ecf20Sopenharmony_ci * * Neither the name of Advanced Micro Devices, Inc. nor the 708c2ecf20Sopenharmony_ci * names of its contributors may be used to endorse or promote products 718c2ecf20Sopenharmony_ci * derived from this software without specific prior written permission. 728c2ecf20Sopenharmony_ci * 738c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 748c2ecf20Sopenharmony_ci * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 758c2ecf20Sopenharmony_ci * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 768c2ecf20Sopenharmony_ci * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY 778c2ecf20Sopenharmony_ci * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 788c2ecf20Sopenharmony_ci * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 798c2ecf20Sopenharmony_ci * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 808c2ecf20Sopenharmony_ci * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 818c2ecf20Sopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 828c2ecf20Sopenharmony_ci * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 838c2ecf20Sopenharmony_ci * 848c2ecf20Sopenharmony_ci * This file incorporates work covered by the following copyright and 858c2ecf20Sopenharmony_ci * permission notice: 868c2ecf20Sopenharmony_ci * The Synopsys DWC ETHER XGMAC Software Driver and documentation 878c2ecf20Sopenharmony_ci * (hereinafter "Software") is an unsupported proprietary work of Synopsys, 888c2ecf20Sopenharmony_ci * Inc. unless otherwise expressly agreed to in writing between Synopsys 898c2ecf20Sopenharmony_ci * and you. 908c2ecf20Sopenharmony_ci * 918c2ecf20Sopenharmony_ci * The Software IS NOT an item of Licensed Software or Licensed Product 928c2ecf20Sopenharmony_ci * under any End User Software License Agreement or Agreement for Licensed 938c2ecf20Sopenharmony_ci * Product with Synopsys or any supplement thereto. Permission is hereby 948c2ecf20Sopenharmony_ci * granted, free of charge, to any person obtaining a copy of this software 958c2ecf20Sopenharmony_ci * annotated with this license and the Software, to deal in the Software 968c2ecf20Sopenharmony_ci * without restriction, including without limitation the rights to use, 978c2ecf20Sopenharmony_ci * copy, modify, merge, publish, distribute, sublicense, and/or sell copies 988c2ecf20Sopenharmony_ci * of the Software, and to permit persons to whom the Software is furnished 998c2ecf20Sopenharmony_ci * to do so, subject to the following conditions: 1008c2ecf20Sopenharmony_ci * 1018c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included 1028c2ecf20Sopenharmony_ci * in all copies or substantial portions of the Software. 1038c2ecf20Sopenharmony_ci * 1048c2ecf20Sopenharmony_ci * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" 1058c2ecf20Sopenharmony_ci * BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 1068c2ecf20Sopenharmony_ci * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 1078c2ecf20Sopenharmony_ci * PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS 1088c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 1098c2ecf20Sopenharmony_ci * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 1108c2ecf20Sopenharmony_ci * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 1118c2ecf20Sopenharmony_ci * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 1128c2ecf20Sopenharmony_ci * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 1138c2ecf20Sopenharmony_ci * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 1148c2ecf20Sopenharmony_ci * THE POSSIBILITY OF SUCH DAMAGE. 1158c2ecf20Sopenharmony_ci */ 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci#ifndef __XGBE_H__ 1188c2ecf20Sopenharmony_ci#define __XGBE_H__ 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci#include <linux/dma-mapping.h> 1218c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 1228c2ecf20Sopenharmony_ci#include <linux/workqueue.h> 1238c2ecf20Sopenharmony_ci#include <linux/phy.h> 1248c2ecf20Sopenharmony_ci#include <linux/if_vlan.h> 1258c2ecf20Sopenharmony_ci#include <linux/bitops.h> 1268c2ecf20Sopenharmony_ci#include <linux/ptp_clock_kernel.h> 1278c2ecf20Sopenharmony_ci#include <linux/timecounter.h> 1288c2ecf20Sopenharmony_ci#include <linux/net_tstamp.h> 1298c2ecf20Sopenharmony_ci#include <net/dcbnl.h> 1308c2ecf20Sopenharmony_ci#include <linux/completion.h> 1318c2ecf20Sopenharmony_ci#include <linux/cpumask.h> 1328c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 1338c2ecf20Sopenharmony_ci#include <linux/dcache.h> 1348c2ecf20Sopenharmony_ci#include <linux/ethtool.h> 1358c2ecf20Sopenharmony_ci#include <linux/list.h> 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci#define XGBE_DRV_NAME "amd-xgbe" 1388c2ecf20Sopenharmony_ci#define XGBE_DRV_DESC "AMD 10 Gigabit Ethernet Driver" 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci/* Descriptor related defines */ 1418c2ecf20Sopenharmony_ci#define XGBE_TX_DESC_CNT 512 1428c2ecf20Sopenharmony_ci#define XGBE_TX_DESC_MIN_FREE (XGBE_TX_DESC_CNT >> 3) 1438c2ecf20Sopenharmony_ci#define XGBE_TX_DESC_MAX_PROC (XGBE_TX_DESC_CNT >> 1) 1448c2ecf20Sopenharmony_ci#define XGBE_RX_DESC_CNT 512 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci#define XGBE_TX_DESC_CNT_MIN 64 1478c2ecf20Sopenharmony_ci#define XGBE_TX_DESC_CNT_MAX 4096 1488c2ecf20Sopenharmony_ci#define XGBE_RX_DESC_CNT_MIN 64 1498c2ecf20Sopenharmony_ci#define XGBE_RX_DESC_CNT_MAX 4096 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci#define XGBE_TX_MAX_BUF_SIZE (0x3fff & ~(64 - 1)) 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci/* Descriptors required for maximum contiguous TSO/GSO packet */ 1548c2ecf20Sopenharmony_ci#define XGBE_TX_MAX_SPLIT ((GSO_MAX_SIZE / XGBE_TX_MAX_BUF_SIZE) + 1) 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ci/* Maximum possible descriptors needed for an SKB: 1578c2ecf20Sopenharmony_ci * - Maximum number of SKB frags 1588c2ecf20Sopenharmony_ci * - Maximum descriptors for contiguous TSO/GSO packet 1598c2ecf20Sopenharmony_ci * - Possible context descriptor 1608c2ecf20Sopenharmony_ci * - Possible TSO header descriptor 1618c2ecf20Sopenharmony_ci */ 1628c2ecf20Sopenharmony_ci#define XGBE_TX_MAX_DESCS (MAX_SKB_FRAGS + XGBE_TX_MAX_SPLIT + 2) 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci#define XGBE_RX_MIN_BUF_SIZE (ETH_FRAME_LEN + ETH_FCS_LEN + VLAN_HLEN) 1658c2ecf20Sopenharmony_ci#define XGBE_RX_BUF_ALIGN 64 1668c2ecf20Sopenharmony_ci#define XGBE_SKB_ALLOC_SIZE 256 1678c2ecf20Sopenharmony_ci#define XGBE_SPH_HDSMS_SIZE 2 /* Keep in sync with SKB_ALLOC_SIZE */ 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_ci#define XGBE_MAX_DMA_CHANNELS 16 1708c2ecf20Sopenharmony_ci#define XGBE_MAX_QUEUES 16 1718c2ecf20Sopenharmony_ci#define XGBE_PRIORITY_QUEUES 8 1728c2ecf20Sopenharmony_ci#define XGBE_DMA_STOP_TIMEOUT 1 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci/* DMA cache settings - Outer sharable, write-back, write-allocate */ 1758c2ecf20Sopenharmony_ci#define XGBE_DMA_OS_ARCR 0x002b2b2b 1768c2ecf20Sopenharmony_ci#define XGBE_DMA_OS_AWCR 0x2f2f2f2f 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci/* DMA cache settings - System, no caches used */ 1798c2ecf20Sopenharmony_ci#define XGBE_DMA_SYS_ARCR 0x00303030 1808c2ecf20Sopenharmony_ci#define XGBE_DMA_SYS_AWCR 0x30303030 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci/* DMA cache settings - PCI device */ 1838c2ecf20Sopenharmony_ci#define XGBE_DMA_PCI_ARCR 0x000f0f0f 1848c2ecf20Sopenharmony_ci#define XGBE_DMA_PCI_AWCR 0x0f0f0f0f 1858c2ecf20Sopenharmony_ci#define XGBE_DMA_PCI_AWARCR 0x00000f0f 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci/* DMA channel interrupt modes */ 1888c2ecf20Sopenharmony_ci#define XGBE_IRQ_MODE_EDGE 0 1898c2ecf20Sopenharmony_ci#define XGBE_IRQ_MODE_LEVEL 1 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci#define XGMAC_MIN_PACKET 60 1928c2ecf20Sopenharmony_ci#define XGMAC_STD_PACKET_MTU 1500 1938c2ecf20Sopenharmony_ci#define XGMAC_MAX_STD_PACKET 1518 1948c2ecf20Sopenharmony_ci#define XGMAC_JUMBO_PACKET_MTU 9000 1958c2ecf20Sopenharmony_ci#define XGMAC_MAX_JUMBO_PACKET 9018 1968c2ecf20Sopenharmony_ci#define XGMAC_ETH_PREAMBLE (12 + 8) /* Inter-frame gap + preamble */ 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_ci#define XGMAC_PFC_DATA_LEN 46 1998c2ecf20Sopenharmony_ci#define XGMAC_PFC_DELAYS 14000 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci#define XGMAC_PRIO_QUEUES(_cnt) \ 2028c2ecf20Sopenharmony_ci min_t(unsigned int, IEEE_8021QAZ_MAX_TCS, (_cnt)) 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_ci/* Common property names */ 2058c2ecf20Sopenharmony_ci#define XGBE_MAC_ADDR_PROPERTY "mac-address" 2068c2ecf20Sopenharmony_ci#define XGBE_PHY_MODE_PROPERTY "phy-mode" 2078c2ecf20Sopenharmony_ci#define XGBE_DMA_IRQS_PROPERTY "amd,per-channel-interrupt" 2088c2ecf20Sopenharmony_ci#define XGBE_SPEEDSET_PROPERTY "amd,speed-set" 2098c2ecf20Sopenharmony_ci 2108c2ecf20Sopenharmony_ci/* Device-tree clock names */ 2118c2ecf20Sopenharmony_ci#define XGBE_DMA_CLOCK "dma_clk" 2128c2ecf20Sopenharmony_ci#define XGBE_PTP_CLOCK "ptp_clk" 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci/* ACPI property names */ 2158c2ecf20Sopenharmony_ci#define XGBE_ACPI_DMA_FREQ "amd,dma-freq" 2168c2ecf20Sopenharmony_ci#define XGBE_ACPI_PTP_FREQ "amd,ptp-freq" 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_ci/* PCI BAR mapping */ 2198c2ecf20Sopenharmony_ci#define XGBE_XGMAC_BAR 0 2208c2ecf20Sopenharmony_ci#define XGBE_XPCS_BAR 1 2218c2ecf20Sopenharmony_ci#define XGBE_MAC_PROP_OFFSET 0x1d000 2228c2ecf20Sopenharmony_ci#define XGBE_I2C_CTRL_OFFSET 0x1e000 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci/* PCI MSI/MSIx support */ 2258c2ecf20Sopenharmony_ci#define XGBE_MSI_BASE_COUNT 4 2268c2ecf20Sopenharmony_ci#define XGBE_MSI_MIN_COUNT (XGBE_MSI_BASE_COUNT + 1) 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_ci/* PCI clock frequencies */ 2298c2ecf20Sopenharmony_ci#define XGBE_V2_DMA_CLOCK_FREQ 500000000 /* 500 MHz */ 2308c2ecf20Sopenharmony_ci#define XGBE_V2_PTP_CLOCK_FREQ 125000000 /* 125 MHz */ 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci/* Timestamp support - values based on 50MHz PTP clock 2338c2ecf20Sopenharmony_ci * 50MHz => 20 nsec 2348c2ecf20Sopenharmony_ci */ 2358c2ecf20Sopenharmony_ci#define XGBE_TSTAMP_SSINC 20 2368c2ecf20Sopenharmony_ci#define XGBE_TSTAMP_SNSINC 0 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_ci/* Driver PMT macros */ 2398c2ecf20Sopenharmony_ci#define XGMAC_DRIVER_CONTEXT 1 2408c2ecf20Sopenharmony_ci#define XGMAC_IOCTL_CONTEXT 2 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci#define XGMAC_FIFO_MIN_ALLOC 2048 2438c2ecf20Sopenharmony_ci#define XGMAC_FIFO_UNIT 256 2448c2ecf20Sopenharmony_ci#define XGMAC_FIFO_ALIGN(_x) \ 2458c2ecf20Sopenharmony_ci (((_x) + XGMAC_FIFO_UNIT - 1) & ~(XGMAC_FIFO_UNIT - 1)) 2468c2ecf20Sopenharmony_ci#define XGMAC_FIFO_FC_OFF 2048 2478c2ecf20Sopenharmony_ci#define XGMAC_FIFO_FC_MIN 4096 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_ci#define XGBE_TC_MIN_QUANTUM 10 2508c2ecf20Sopenharmony_ci 2518c2ecf20Sopenharmony_ci/* Helper macro for descriptor handling 2528c2ecf20Sopenharmony_ci * Always use XGBE_GET_DESC_DATA to access the descriptor data 2538c2ecf20Sopenharmony_ci * since the index is free-running and needs to be and-ed 2548c2ecf20Sopenharmony_ci * with the descriptor count value of the ring to index to 2558c2ecf20Sopenharmony_ci * the proper descriptor data. 2568c2ecf20Sopenharmony_ci */ 2578c2ecf20Sopenharmony_ci#define XGBE_GET_DESC_DATA(_ring, _idx) \ 2588c2ecf20Sopenharmony_ci ((_ring)->rdata + \ 2598c2ecf20Sopenharmony_ci ((_idx) & ((_ring)->rdesc_count - 1))) 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci/* Default coalescing parameters */ 2628c2ecf20Sopenharmony_ci#define XGMAC_INIT_DMA_TX_USECS 1000 2638c2ecf20Sopenharmony_ci#define XGMAC_INIT_DMA_TX_FRAMES 25 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci#define XGMAC_MAX_DMA_RIWT 0xff 2668c2ecf20Sopenharmony_ci#define XGMAC_INIT_DMA_RX_USECS 30 2678c2ecf20Sopenharmony_ci#define XGMAC_INIT_DMA_RX_FRAMES 25 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_ci/* Flow control queue count */ 2708c2ecf20Sopenharmony_ci#define XGMAC_MAX_FLOW_CONTROL_QUEUES 8 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_ci/* Flow control threshold units */ 2738c2ecf20Sopenharmony_ci#define XGMAC_FLOW_CONTROL_UNIT 512 2748c2ecf20Sopenharmony_ci#define XGMAC_FLOW_CONTROL_ALIGN(_x) \ 2758c2ecf20Sopenharmony_ci (((_x) + XGMAC_FLOW_CONTROL_UNIT - 1) & ~(XGMAC_FLOW_CONTROL_UNIT - 1)) 2768c2ecf20Sopenharmony_ci#define XGMAC_FLOW_CONTROL_VALUE(_x) \ 2778c2ecf20Sopenharmony_ci (((_x) < 1024) ? 0 : ((_x) / XGMAC_FLOW_CONTROL_UNIT) - 2) 2788c2ecf20Sopenharmony_ci#define XGMAC_FLOW_CONTROL_MAX 33280 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_ci/* Maximum MAC address hash table size (256 bits = 8 bytes) */ 2818c2ecf20Sopenharmony_ci#define XGBE_MAC_HASH_TABLE_SIZE 8 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ci/* Receive Side Scaling */ 2848c2ecf20Sopenharmony_ci#define XGBE_RSS_HASH_KEY_SIZE 40 2858c2ecf20Sopenharmony_ci#define XGBE_RSS_MAX_TABLE_SIZE 256 2868c2ecf20Sopenharmony_ci#define XGBE_RSS_LOOKUP_TABLE_TYPE 0 2878c2ecf20Sopenharmony_ci#define XGBE_RSS_HASH_KEY_TYPE 1 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_ci/* Auto-negotiation */ 2908c2ecf20Sopenharmony_ci#define XGBE_AN_MS_TIMEOUT 500 2918c2ecf20Sopenharmony_ci#define XGBE_LINK_TIMEOUT 5 2928c2ecf20Sopenharmony_ci#define XGBE_KR_TRAINING_WAIT_ITER 50 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_ci#define XGBE_SGMII_AN_LINK_STATUS BIT(1) 2958c2ecf20Sopenharmony_ci#define XGBE_SGMII_AN_LINK_SPEED (BIT(2) | BIT(3)) 2968c2ecf20Sopenharmony_ci#define XGBE_SGMII_AN_LINK_SPEED_100 0x04 2978c2ecf20Sopenharmony_ci#define XGBE_SGMII_AN_LINK_SPEED_1000 0x08 2988c2ecf20Sopenharmony_ci#define XGBE_SGMII_AN_LINK_DUPLEX BIT(4) 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci/* ECC correctable error notification window (seconds) */ 3018c2ecf20Sopenharmony_ci#define XGBE_ECC_LIMIT 60 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_ci/* MDIO port types */ 3048c2ecf20Sopenharmony_ci#define XGMAC_MAX_C22_PORT 3 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_ci/* Link mode bit operations */ 3078c2ecf20Sopenharmony_ci#define XGBE_ZERO_SUP(_ls) \ 3088c2ecf20Sopenharmony_ci ethtool_link_ksettings_zero_link_mode((_ls), supported) 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_ci#define XGBE_SET_SUP(_ls, _mode) \ 3118c2ecf20Sopenharmony_ci ethtool_link_ksettings_add_link_mode((_ls), supported, _mode) 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_ci#define XGBE_CLR_SUP(_ls, _mode) \ 3148c2ecf20Sopenharmony_ci ethtool_link_ksettings_del_link_mode((_ls), supported, _mode) 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_ci#define XGBE_IS_SUP(_ls, _mode) \ 3178c2ecf20Sopenharmony_ci ethtool_link_ksettings_test_link_mode((_ls), supported, _mode) 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_ci#define XGBE_ZERO_ADV(_ls) \ 3208c2ecf20Sopenharmony_ci ethtool_link_ksettings_zero_link_mode((_ls), advertising) 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_ci#define XGBE_SET_ADV(_ls, _mode) \ 3238c2ecf20Sopenharmony_ci ethtool_link_ksettings_add_link_mode((_ls), advertising, _mode) 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_ci#define XGBE_CLR_ADV(_ls, _mode) \ 3268c2ecf20Sopenharmony_ci ethtool_link_ksettings_del_link_mode((_ls), advertising, _mode) 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_ci#define XGBE_ADV(_ls, _mode) \ 3298c2ecf20Sopenharmony_ci ethtool_link_ksettings_test_link_mode((_ls), advertising, _mode) 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ci#define XGBE_ZERO_LP_ADV(_ls) \ 3328c2ecf20Sopenharmony_ci ethtool_link_ksettings_zero_link_mode((_ls), lp_advertising) 3338c2ecf20Sopenharmony_ci 3348c2ecf20Sopenharmony_ci#define XGBE_SET_LP_ADV(_ls, _mode) \ 3358c2ecf20Sopenharmony_ci ethtool_link_ksettings_add_link_mode((_ls), lp_advertising, _mode) 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_ci#define XGBE_CLR_LP_ADV(_ls, _mode) \ 3388c2ecf20Sopenharmony_ci ethtool_link_ksettings_del_link_mode((_ls), lp_advertising, _mode) 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ci#define XGBE_LP_ADV(_ls, _mode) \ 3418c2ecf20Sopenharmony_ci ethtool_link_ksettings_test_link_mode((_ls), lp_advertising, _mode) 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_ci#define XGBE_LM_COPY(_dst, _dname, _src, _sname) \ 3448c2ecf20Sopenharmony_ci bitmap_copy((_dst)->link_modes._dname, \ 3458c2ecf20Sopenharmony_ci (_src)->link_modes._sname, \ 3468c2ecf20Sopenharmony_ci __ETHTOOL_LINK_MODE_MASK_NBITS) 3478c2ecf20Sopenharmony_ci 3488c2ecf20Sopenharmony_cistruct xgbe_prv_data; 3498c2ecf20Sopenharmony_ci 3508c2ecf20Sopenharmony_cistruct xgbe_packet_data { 3518c2ecf20Sopenharmony_ci struct sk_buff *skb; 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_ci unsigned int attributes; 3548c2ecf20Sopenharmony_ci 3558c2ecf20Sopenharmony_ci unsigned int errors; 3568c2ecf20Sopenharmony_ci 3578c2ecf20Sopenharmony_ci unsigned int rdesc_count; 3588c2ecf20Sopenharmony_ci unsigned int length; 3598c2ecf20Sopenharmony_ci 3608c2ecf20Sopenharmony_ci unsigned int header_len; 3618c2ecf20Sopenharmony_ci unsigned int tcp_header_len; 3628c2ecf20Sopenharmony_ci unsigned int tcp_payload_len; 3638c2ecf20Sopenharmony_ci unsigned short mss; 3648c2ecf20Sopenharmony_ci 3658c2ecf20Sopenharmony_ci unsigned short vlan_ctag; 3668c2ecf20Sopenharmony_ci 3678c2ecf20Sopenharmony_ci u64 rx_tstamp; 3688c2ecf20Sopenharmony_ci 3698c2ecf20Sopenharmony_ci u32 rss_hash; 3708c2ecf20Sopenharmony_ci enum pkt_hash_types rss_hash_type; 3718c2ecf20Sopenharmony_ci 3728c2ecf20Sopenharmony_ci unsigned int tx_packets; 3738c2ecf20Sopenharmony_ci unsigned int tx_bytes; 3748c2ecf20Sopenharmony_ci}; 3758c2ecf20Sopenharmony_ci 3768c2ecf20Sopenharmony_ci/* Common Rx and Tx descriptor mapping */ 3778c2ecf20Sopenharmony_cistruct xgbe_ring_desc { 3788c2ecf20Sopenharmony_ci __le32 desc0; 3798c2ecf20Sopenharmony_ci __le32 desc1; 3808c2ecf20Sopenharmony_ci __le32 desc2; 3818c2ecf20Sopenharmony_ci __le32 desc3; 3828c2ecf20Sopenharmony_ci}; 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_ci/* Page allocation related values */ 3858c2ecf20Sopenharmony_cistruct xgbe_page_alloc { 3868c2ecf20Sopenharmony_ci struct page *pages; 3878c2ecf20Sopenharmony_ci unsigned int pages_len; 3888c2ecf20Sopenharmony_ci unsigned int pages_offset; 3898c2ecf20Sopenharmony_ci 3908c2ecf20Sopenharmony_ci dma_addr_t pages_dma; 3918c2ecf20Sopenharmony_ci}; 3928c2ecf20Sopenharmony_ci 3938c2ecf20Sopenharmony_ci/* Ring entry buffer data */ 3948c2ecf20Sopenharmony_cistruct xgbe_buffer_data { 3958c2ecf20Sopenharmony_ci struct xgbe_page_alloc pa; 3968c2ecf20Sopenharmony_ci struct xgbe_page_alloc pa_unmap; 3978c2ecf20Sopenharmony_ci 3988c2ecf20Sopenharmony_ci dma_addr_t dma_base; 3998c2ecf20Sopenharmony_ci unsigned long dma_off; 4008c2ecf20Sopenharmony_ci unsigned int dma_len; 4018c2ecf20Sopenharmony_ci}; 4028c2ecf20Sopenharmony_ci 4038c2ecf20Sopenharmony_ci/* Tx-related ring data */ 4048c2ecf20Sopenharmony_cistruct xgbe_tx_ring_data { 4058c2ecf20Sopenharmony_ci unsigned int packets; /* BQL packet count */ 4068c2ecf20Sopenharmony_ci unsigned int bytes; /* BQL byte count */ 4078c2ecf20Sopenharmony_ci}; 4088c2ecf20Sopenharmony_ci 4098c2ecf20Sopenharmony_ci/* Rx-related ring data */ 4108c2ecf20Sopenharmony_cistruct xgbe_rx_ring_data { 4118c2ecf20Sopenharmony_ci struct xgbe_buffer_data hdr; /* Header locations */ 4128c2ecf20Sopenharmony_ci struct xgbe_buffer_data buf; /* Payload locations */ 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_ci unsigned short hdr_len; /* Length of received header */ 4158c2ecf20Sopenharmony_ci unsigned short len; /* Length of received packet */ 4168c2ecf20Sopenharmony_ci}; 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_ci/* Structure used to hold information related to the descriptor 4198c2ecf20Sopenharmony_ci * and the packet associated with the descriptor (always use 4208c2ecf20Sopenharmony_ci * use the XGBE_GET_DESC_DATA macro to access this data from the ring) 4218c2ecf20Sopenharmony_ci */ 4228c2ecf20Sopenharmony_cistruct xgbe_ring_data { 4238c2ecf20Sopenharmony_ci struct xgbe_ring_desc *rdesc; /* Virtual address of descriptor */ 4248c2ecf20Sopenharmony_ci dma_addr_t rdesc_dma; /* DMA address of descriptor */ 4258c2ecf20Sopenharmony_ci 4268c2ecf20Sopenharmony_ci struct sk_buff *skb; /* Virtual address of SKB */ 4278c2ecf20Sopenharmony_ci dma_addr_t skb_dma; /* DMA address of SKB data */ 4288c2ecf20Sopenharmony_ci unsigned int skb_dma_len; /* Length of SKB DMA area */ 4298c2ecf20Sopenharmony_ci 4308c2ecf20Sopenharmony_ci struct xgbe_tx_ring_data tx; /* Tx-related data */ 4318c2ecf20Sopenharmony_ci struct xgbe_rx_ring_data rx; /* Rx-related data */ 4328c2ecf20Sopenharmony_ci 4338c2ecf20Sopenharmony_ci unsigned int mapped_as_page; 4348c2ecf20Sopenharmony_ci 4358c2ecf20Sopenharmony_ci /* Incomplete receive save location. If the budget is exhausted 4368c2ecf20Sopenharmony_ci * or the last descriptor (last normal descriptor or a following 4378c2ecf20Sopenharmony_ci * context descriptor) has not been DMA'd yet the current state 4388c2ecf20Sopenharmony_ci * of the receive processing needs to be saved. 4398c2ecf20Sopenharmony_ci */ 4408c2ecf20Sopenharmony_ci unsigned int state_saved; 4418c2ecf20Sopenharmony_ci struct { 4428c2ecf20Sopenharmony_ci struct sk_buff *skb; 4438c2ecf20Sopenharmony_ci unsigned int len; 4448c2ecf20Sopenharmony_ci unsigned int error; 4458c2ecf20Sopenharmony_ci } state; 4468c2ecf20Sopenharmony_ci}; 4478c2ecf20Sopenharmony_ci 4488c2ecf20Sopenharmony_cistruct xgbe_ring { 4498c2ecf20Sopenharmony_ci /* Ring lock - used just for TX rings at the moment */ 4508c2ecf20Sopenharmony_ci spinlock_t lock; 4518c2ecf20Sopenharmony_ci 4528c2ecf20Sopenharmony_ci /* Per packet related information */ 4538c2ecf20Sopenharmony_ci struct xgbe_packet_data packet_data; 4548c2ecf20Sopenharmony_ci 4558c2ecf20Sopenharmony_ci /* Virtual/DMA addresses and count of allocated descriptor memory */ 4568c2ecf20Sopenharmony_ci struct xgbe_ring_desc *rdesc; 4578c2ecf20Sopenharmony_ci dma_addr_t rdesc_dma; 4588c2ecf20Sopenharmony_ci unsigned int rdesc_count; 4598c2ecf20Sopenharmony_ci 4608c2ecf20Sopenharmony_ci /* Array of descriptor data corresponding the descriptor memory 4618c2ecf20Sopenharmony_ci * (always use the XGBE_GET_DESC_DATA macro to access this data) 4628c2ecf20Sopenharmony_ci */ 4638c2ecf20Sopenharmony_ci struct xgbe_ring_data *rdata; 4648c2ecf20Sopenharmony_ci 4658c2ecf20Sopenharmony_ci /* Page allocation for RX buffers */ 4668c2ecf20Sopenharmony_ci struct xgbe_page_alloc rx_hdr_pa; 4678c2ecf20Sopenharmony_ci struct xgbe_page_alloc rx_buf_pa; 4688c2ecf20Sopenharmony_ci int node; 4698c2ecf20Sopenharmony_ci 4708c2ecf20Sopenharmony_ci /* Ring index values 4718c2ecf20Sopenharmony_ci * cur - Tx: index of descriptor to be used for current transfer 4728c2ecf20Sopenharmony_ci * Rx: index of descriptor to check for packet availability 4738c2ecf20Sopenharmony_ci * dirty - Tx: index of descriptor to check for transfer complete 4748c2ecf20Sopenharmony_ci * Rx: index of descriptor to check for buffer reallocation 4758c2ecf20Sopenharmony_ci */ 4768c2ecf20Sopenharmony_ci unsigned int cur; 4778c2ecf20Sopenharmony_ci unsigned int dirty; 4788c2ecf20Sopenharmony_ci 4798c2ecf20Sopenharmony_ci /* Coalesce frame count used for interrupt bit setting */ 4808c2ecf20Sopenharmony_ci unsigned int coalesce_count; 4818c2ecf20Sopenharmony_ci 4828c2ecf20Sopenharmony_ci union { 4838c2ecf20Sopenharmony_ci struct { 4848c2ecf20Sopenharmony_ci unsigned int queue_stopped; 4858c2ecf20Sopenharmony_ci unsigned int xmit_more; 4868c2ecf20Sopenharmony_ci unsigned short cur_mss; 4878c2ecf20Sopenharmony_ci unsigned short cur_vlan_ctag; 4888c2ecf20Sopenharmony_ci } tx; 4898c2ecf20Sopenharmony_ci }; 4908c2ecf20Sopenharmony_ci} ____cacheline_aligned; 4918c2ecf20Sopenharmony_ci 4928c2ecf20Sopenharmony_ci/* Structure used to describe the descriptor rings associated with 4938c2ecf20Sopenharmony_ci * a DMA channel. 4948c2ecf20Sopenharmony_ci */ 4958c2ecf20Sopenharmony_cistruct xgbe_channel { 4968c2ecf20Sopenharmony_ci char name[16]; 4978c2ecf20Sopenharmony_ci 4988c2ecf20Sopenharmony_ci /* Address of private data area for device */ 4998c2ecf20Sopenharmony_ci struct xgbe_prv_data *pdata; 5008c2ecf20Sopenharmony_ci 5018c2ecf20Sopenharmony_ci /* Queue index and base address of queue's DMA registers */ 5028c2ecf20Sopenharmony_ci unsigned int queue_index; 5038c2ecf20Sopenharmony_ci void __iomem *dma_regs; 5048c2ecf20Sopenharmony_ci 5058c2ecf20Sopenharmony_ci /* Per channel interrupt irq number */ 5068c2ecf20Sopenharmony_ci int dma_irq; 5078c2ecf20Sopenharmony_ci char dma_irq_name[IFNAMSIZ + 32]; 5088c2ecf20Sopenharmony_ci 5098c2ecf20Sopenharmony_ci /* Netdev related settings */ 5108c2ecf20Sopenharmony_ci struct napi_struct napi; 5118c2ecf20Sopenharmony_ci 5128c2ecf20Sopenharmony_ci /* Per channel interrupt enablement tracker */ 5138c2ecf20Sopenharmony_ci unsigned int curr_ier; 5148c2ecf20Sopenharmony_ci unsigned int saved_ier; 5158c2ecf20Sopenharmony_ci 5168c2ecf20Sopenharmony_ci unsigned int tx_timer_active; 5178c2ecf20Sopenharmony_ci struct timer_list tx_timer; 5188c2ecf20Sopenharmony_ci 5198c2ecf20Sopenharmony_ci struct xgbe_ring *tx_ring; 5208c2ecf20Sopenharmony_ci struct xgbe_ring *rx_ring; 5218c2ecf20Sopenharmony_ci 5228c2ecf20Sopenharmony_ci int node; 5238c2ecf20Sopenharmony_ci cpumask_t affinity_mask; 5248c2ecf20Sopenharmony_ci} ____cacheline_aligned; 5258c2ecf20Sopenharmony_ci 5268c2ecf20Sopenharmony_cienum xgbe_state { 5278c2ecf20Sopenharmony_ci XGBE_DOWN, 5288c2ecf20Sopenharmony_ci XGBE_LINK_INIT, 5298c2ecf20Sopenharmony_ci XGBE_LINK_ERR, 5308c2ecf20Sopenharmony_ci XGBE_STOPPED, 5318c2ecf20Sopenharmony_ci}; 5328c2ecf20Sopenharmony_ci 5338c2ecf20Sopenharmony_cienum xgbe_int { 5348c2ecf20Sopenharmony_ci XGMAC_INT_DMA_CH_SR_TI, 5358c2ecf20Sopenharmony_ci XGMAC_INT_DMA_CH_SR_TPS, 5368c2ecf20Sopenharmony_ci XGMAC_INT_DMA_CH_SR_TBU, 5378c2ecf20Sopenharmony_ci XGMAC_INT_DMA_CH_SR_RI, 5388c2ecf20Sopenharmony_ci XGMAC_INT_DMA_CH_SR_RBU, 5398c2ecf20Sopenharmony_ci XGMAC_INT_DMA_CH_SR_RPS, 5408c2ecf20Sopenharmony_ci XGMAC_INT_DMA_CH_SR_TI_RI, 5418c2ecf20Sopenharmony_ci XGMAC_INT_DMA_CH_SR_FBE, 5428c2ecf20Sopenharmony_ci XGMAC_INT_DMA_ALL, 5438c2ecf20Sopenharmony_ci}; 5448c2ecf20Sopenharmony_ci 5458c2ecf20Sopenharmony_cienum xgbe_int_state { 5468c2ecf20Sopenharmony_ci XGMAC_INT_STATE_SAVE, 5478c2ecf20Sopenharmony_ci XGMAC_INT_STATE_RESTORE, 5488c2ecf20Sopenharmony_ci}; 5498c2ecf20Sopenharmony_ci 5508c2ecf20Sopenharmony_cienum xgbe_ecc_sec { 5518c2ecf20Sopenharmony_ci XGBE_ECC_SEC_TX, 5528c2ecf20Sopenharmony_ci XGBE_ECC_SEC_RX, 5538c2ecf20Sopenharmony_ci XGBE_ECC_SEC_DESC, 5548c2ecf20Sopenharmony_ci}; 5558c2ecf20Sopenharmony_ci 5568c2ecf20Sopenharmony_cienum xgbe_speed { 5578c2ecf20Sopenharmony_ci XGBE_SPEED_1000 = 0, 5588c2ecf20Sopenharmony_ci XGBE_SPEED_2500, 5598c2ecf20Sopenharmony_ci XGBE_SPEED_10000, 5608c2ecf20Sopenharmony_ci XGBE_SPEEDS, 5618c2ecf20Sopenharmony_ci}; 5628c2ecf20Sopenharmony_ci 5638c2ecf20Sopenharmony_cienum xgbe_xpcs_access { 5648c2ecf20Sopenharmony_ci XGBE_XPCS_ACCESS_V1 = 0, 5658c2ecf20Sopenharmony_ci XGBE_XPCS_ACCESS_V2, 5668c2ecf20Sopenharmony_ci}; 5678c2ecf20Sopenharmony_ci 5688c2ecf20Sopenharmony_cienum xgbe_an_mode { 5698c2ecf20Sopenharmony_ci XGBE_AN_MODE_CL73 = 0, 5708c2ecf20Sopenharmony_ci XGBE_AN_MODE_CL73_REDRV, 5718c2ecf20Sopenharmony_ci XGBE_AN_MODE_CL37, 5728c2ecf20Sopenharmony_ci XGBE_AN_MODE_CL37_SGMII, 5738c2ecf20Sopenharmony_ci XGBE_AN_MODE_NONE, 5748c2ecf20Sopenharmony_ci}; 5758c2ecf20Sopenharmony_ci 5768c2ecf20Sopenharmony_cienum xgbe_an { 5778c2ecf20Sopenharmony_ci XGBE_AN_READY = 0, 5788c2ecf20Sopenharmony_ci XGBE_AN_PAGE_RECEIVED, 5798c2ecf20Sopenharmony_ci XGBE_AN_INCOMPAT_LINK, 5808c2ecf20Sopenharmony_ci XGBE_AN_COMPLETE, 5818c2ecf20Sopenharmony_ci XGBE_AN_NO_LINK, 5828c2ecf20Sopenharmony_ci XGBE_AN_ERROR, 5838c2ecf20Sopenharmony_ci}; 5848c2ecf20Sopenharmony_ci 5858c2ecf20Sopenharmony_cienum xgbe_rx { 5868c2ecf20Sopenharmony_ci XGBE_RX_BPA = 0, 5878c2ecf20Sopenharmony_ci XGBE_RX_XNP, 5888c2ecf20Sopenharmony_ci XGBE_RX_COMPLETE, 5898c2ecf20Sopenharmony_ci XGBE_RX_ERROR, 5908c2ecf20Sopenharmony_ci}; 5918c2ecf20Sopenharmony_ci 5928c2ecf20Sopenharmony_cienum xgbe_mode { 5938c2ecf20Sopenharmony_ci XGBE_MODE_KX_1000 = 0, 5948c2ecf20Sopenharmony_ci XGBE_MODE_KX_2500, 5958c2ecf20Sopenharmony_ci XGBE_MODE_KR, 5968c2ecf20Sopenharmony_ci XGBE_MODE_X, 5978c2ecf20Sopenharmony_ci XGBE_MODE_SGMII_100, 5988c2ecf20Sopenharmony_ci XGBE_MODE_SGMII_1000, 5998c2ecf20Sopenharmony_ci XGBE_MODE_SFI, 6008c2ecf20Sopenharmony_ci XGBE_MODE_UNKNOWN, 6018c2ecf20Sopenharmony_ci}; 6028c2ecf20Sopenharmony_ci 6038c2ecf20Sopenharmony_cienum xgbe_speedset { 6048c2ecf20Sopenharmony_ci XGBE_SPEEDSET_1000_10000 = 0, 6058c2ecf20Sopenharmony_ci XGBE_SPEEDSET_2500_10000, 6068c2ecf20Sopenharmony_ci}; 6078c2ecf20Sopenharmony_ci 6088c2ecf20Sopenharmony_cienum xgbe_mdio_mode { 6098c2ecf20Sopenharmony_ci XGBE_MDIO_MODE_NONE = 0, 6108c2ecf20Sopenharmony_ci XGBE_MDIO_MODE_CL22, 6118c2ecf20Sopenharmony_ci XGBE_MDIO_MODE_CL45, 6128c2ecf20Sopenharmony_ci}; 6138c2ecf20Sopenharmony_ci 6148c2ecf20Sopenharmony_cistruct xgbe_phy { 6158c2ecf20Sopenharmony_ci struct ethtool_link_ksettings lks; 6168c2ecf20Sopenharmony_ci 6178c2ecf20Sopenharmony_ci int address; 6188c2ecf20Sopenharmony_ci 6198c2ecf20Sopenharmony_ci int autoneg; 6208c2ecf20Sopenharmony_ci int speed; 6218c2ecf20Sopenharmony_ci int duplex; 6228c2ecf20Sopenharmony_ci 6238c2ecf20Sopenharmony_ci int link; 6248c2ecf20Sopenharmony_ci 6258c2ecf20Sopenharmony_ci int pause_autoneg; 6268c2ecf20Sopenharmony_ci int tx_pause; 6278c2ecf20Sopenharmony_ci int rx_pause; 6288c2ecf20Sopenharmony_ci}; 6298c2ecf20Sopenharmony_ci 6308c2ecf20Sopenharmony_cienum xgbe_i2c_cmd { 6318c2ecf20Sopenharmony_ci XGBE_I2C_CMD_READ = 0, 6328c2ecf20Sopenharmony_ci XGBE_I2C_CMD_WRITE, 6338c2ecf20Sopenharmony_ci}; 6348c2ecf20Sopenharmony_ci 6358c2ecf20Sopenharmony_cistruct xgbe_i2c_op { 6368c2ecf20Sopenharmony_ci enum xgbe_i2c_cmd cmd; 6378c2ecf20Sopenharmony_ci 6388c2ecf20Sopenharmony_ci unsigned int target; 6398c2ecf20Sopenharmony_ci 6408c2ecf20Sopenharmony_ci void *buf; 6418c2ecf20Sopenharmony_ci unsigned int len; 6428c2ecf20Sopenharmony_ci}; 6438c2ecf20Sopenharmony_ci 6448c2ecf20Sopenharmony_cistruct xgbe_i2c_op_state { 6458c2ecf20Sopenharmony_ci struct xgbe_i2c_op *op; 6468c2ecf20Sopenharmony_ci 6478c2ecf20Sopenharmony_ci unsigned int tx_len; 6488c2ecf20Sopenharmony_ci unsigned char *tx_buf; 6498c2ecf20Sopenharmony_ci 6508c2ecf20Sopenharmony_ci unsigned int rx_len; 6518c2ecf20Sopenharmony_ci unsigned char *rx_buf; 6528c2ecf20Sopenharmony_ci 6538c2ecf20Sopenharmony_ci unsigned int tx_abort_source; 6548c2ecf20Sopenharmony_ci 6558c2ecf20Sopenharmony_ci int ret; 6568c2ecf20Sopenharmony_ci}; 6578c2ecf20Sopenharmony_ci 6588c2ecf20Sopenharmony_cistruct xgbe_i2c { 6598c2ecf20Sopenharmony_ci unsigned int started; 6608c2ecf20Sopenharmony_ci unsigned int max_speed_mode; 6618c2ecf20Sopenharmony_ci unsigned int rx_fifo_size; 6628c2ecf20Sopenharmony_ci unsigned int tx_fifo_size; 6638c2ecf20Sopenharmony_ci 6648c2ecf20Sopenharmony_ci struct xgbe_i2c_op_state op_state; 6658c2ecf20Sopenharmony_ci}; 6668c2ecf20Sopenharmony_ci 6678c2ecf20Sopenharmony_cistruct xgbe_mmc_stats { 6688c2ecf20Sopenharmony_ci /* Tx Stats */ 6698c2ecf20Sopenharmony_ci u64 txoctetcount_gb; 6708c2ecf20Sopenharmony_ci u64 txframecount_gb; 6718c2ecf20Sopenharmony_ci u64 txbroadcastframes_g; 6728c2ecf20Sopenharmony_ci u64 txmulticastframes_g; 6738c2ecf20Sopenharmony_ci u64 tx64octets_gb; 6748c2ecf20Sopenharmony_ci u64 tx65to127octets_gb; 6758c2ecf20Sopenharmony_ci u64 tx128to255octets_gb; 6768c2ecf20Sopenharmony_ci u64 tx256to511octets_gb; 6778c2ecf20Sopenharmony_ci u64 tx512to1023octets_gb; 6788c2ecf20Sopenharmony_ci u64 tx1024tomaxoctets_gb; 6798c2ecf20Sopenharmony_ci u64 txunicastframes_gb; 6808c2ecf20Sopenharmony_ci u64 txmulticastframes_gb; 6818c2ecf20Sopenharmony_ci u64 txbroadcastframes_gb; 6828c2ecf20Sopenharmony_ci u64 txunderflowerror; 6838c2ecf20Sopenharmony_ci u64 txoctetcount_g; 6848c2ecf20Sopenharmony_ci u64 txframecount_g; 6858c2ecf20Sopenharmony_ci u64 txpauseframes; 6868c2ecf20Sopenharmony_ci u64 txvlanframes_g; 6878c2ecf20Sopenharmony_ci 6888c2ecf20Sopenharmony_ci /* Rx Stats */ 6898c2ecf20Sopenharmony_ci u64 rxframecount_gb; 6908c2ecf20Sopenharmony_ci u64 rxoctetcount_gb; 6918c2ecf20Sopenharmony_ci u64 rxoctetcount_g; 6928c2ecf20Sopenharmony_ci u64 rxbroadcastframes_g; 6938c2ecf20Sopenharmony_ci u64 rxmulticastframes_g; 6948c2ecf20Sopenharmony_ci u64 rxcrcerror; 6958c2ecf20Sopenharmony_ci u64 rxrunterror; 6968c2ecf20Sopenharmony_ci u64 rxjabbererror; 6978c2ecf20Sopenharmony_ci u64 rxundersize_g; 6988c2ecf20Sopenharmony_ci u64 rxoversize_g; 6998c2ecf20Sopenharmony_ci u64 rx64octets_gb; 7008c2ecf20Sopenharmony_ci u64 rx65to127octets_gb; 7018c2ecf20Sopenharmony_ci u64 rx128to255octets_gb; 7028c2ecf20Sopenharmony_ci u64 rx256to511octets_gb; 7038c2ecf20Sopenharmony_ci u64 rx512to1023octets_gb; 7048c2ecf20Sopenharmony_ci u64 rx1024tomaxoctets_gb; 7058c2ecf20Sopenharmony_ci u64 rxunicastframes_g; 7068c2ecf20Sopenharmony_ci u64 rxlengtherror; 7078c2ecf20Sopenharmony_ci u64 rxoutofrangetype; 7088c2ecf20Sopenharmony_ci u64 rxpauseframes; 7098c2ecf20Sopenharmony_ci u64 rxfifooverflow; 7108c2ecf20Sopenharmony_ci u64 rxvlanframes_gb; 7118c2ecf20Sopenharmony_ci u64 rxwatchdogerror; 7128c2ecf20Sopenharmony_ci}; 7138c2ecf20Sopenharmony_ci 7148c2ecf20Sopenharmony_cistruct xgbe_ext_stats { 7158c2ecf20Sopenharmony_ci u64 tx_tso_packets; 7168c2ecf20Sopenharmony_ci u64 rx_split_header_packets; 7178c2ecf20Sopenharmony_ci u64 rx_buffer_unavailable; 7188c2ecf20Sopenharmony_ci 7198c2ecf20Sopenharmony_ci u64 txq_packets[XGBE_MAX_DMA_CHANNELS]; 7208c2ecf20Sopenharmony_ci u64 txq_bytes[XGBE_MAX_DMA_CHANNELS]; 7218c2ecf20Sopenharmony_ci u64 rxq_packets[XGBE_MAX_DMA_CHANNELS]; 7228c2ecf20Sopenharmony_ci u64 rxq_bytes[XGBE_MAX_DMA_CHANNELS]; 7238c2ecf20Sopenharmony_ci 7248c2ecf20Sopenharmony_ci u64 tx_vxlan_packets; 7258c2ecf20Sopenharmony_ci u64 rx_vxlan_packets; 7268c2ecf20Sopenharmony_ci u64 rx_csum_errors; 7278c2ecf20Sopenharmony_ci u64 rx_vxlan_csum_errors; 7288c2ecf20Sopenharmony_ci}; 7298c2ecf20Sopenharmony_ci 7308c2ecf20Sopenharmony_cistruct xgbe_hw_if { 7318c2ecf20Sopenharmony_ci int (*tx_complete)(struct xgbe_ring_desc *); 7328c2ecf20Sopenharmony_ci 7338c2ecf20Sopenharmony_ci int (*set_mac_address)(struct xgbe_prv_data *, u8 *addr); 7348c2ecf20Sopenharmony_ci int (*config_rx_mode)(struct xgbe_prv_data *); 7358c2ecf20Sopenharmony_ci 7368c2ecf20Sopenharmony_ci int (*enable_rx_csum)(struct xgbe_prv_data *); 7378c2ecf20Sopenharmony_ci int (*disable_rx_csum)(struct xgbe_prv_data *); 7388c2ecf20Sopenharmony_ci 7398c2ecf20Sopenharmony_ci int (*enable_rx_vlan_stripping)(struct xgbe_prv_data *); 7408c2ecf20Sopenharmony_ci int (*disable_rx_vlan_stripping)(struct xgbe_prv_data *); 7418c2ecf20Sopenharmony_ci int (*enable_rx_vlan_filtering)(struct xgbe_prv_data *); 7428c2ecf20Sopenharmony_ci int (*disable_rx_vlan_filtering)(struct xgbe_prv_data *); 7438c2ecf20Sopenharmony_ci int (*update_vlan_hash_table)(struct xgbe_prv_data *); 7448c2ecf20Sopenharmony_ci 7458c2ecf20Sopenharmony_ci int (*read_mmd_regs)(struct xgbe_prv_data *, int, int); 7468c2ecf20Sopenharmony_ci void (*write_mmd_regs)(struct xgbe_prv_data *, int, int, int); 7478c2ecf20Sopenharmony_ci int (*set_speed)(struct xgbe_prv_data *, int); 7488c2ecf20Sopenharmony_ci 7498c2ecf20Sopenharmony_ci int (*set_ext_mii_mode)(struct xgbe_prv_data *, unsigned int, 7508c2ecf20Sopenharmony_ci enum xgbe_mdio_mode); 7518c2ecf20Sopenharmony_ci int (*read_ext_mii_regs)(struct xgbe_prv_data *, int, int); 7528c2ecf20Sopenharmony_ci int (*write_ext_mii_regs)(struct xgbe_prv_data *, int, int, u16); 7538c2ecf20Sopenharmony_ci 7548c2ecf20Sopenharmony_ci int (*set_gpio)(struct xgbe_prv_data *, unsigned int); 7558c2ecf20Sopenharmony_ci int (*clr_gpio)(struct xgbe_prv_data *, unsigned int); 7568c2ecf20Sopenharmony_ci 7578c2ecf20Sopenharmony_ci void (*enable_tx)(struct xgbe_prv_data *); 7588c2ecf20Sopenharmony_ci void (*disable_tx)(struct xgbe_prv_data *); 7598c2ecf20Sopenharmony_ci void (*enable_rx)(struct xgbe_prv_data *); 7608c2ecf20Sopenharmony_ci void (*disable_rx)(struct xgbe_prv_data *); 7618c2ecf20Sopenharmony_ci 7628c2ecf20Sopenharmony_ci void (*powerup_tx)(struct xgbe_prv_data *); 7638c2ecf20Sopenharmony_ci void (*powerdown_tx)(struct xgbe_prv_data *); 7648c2ecf20Sopenharmony_ci void (*powerup_rx)(struct xgbe_prv_data *); 7658c2ecf20Sopenharmony_ci void (*powerdown_rx)(struct xgbe_prv_data *); 7668c2ecf20Sopenharmony_ci 7678c2ecf20Sopenharmony_ci int (*init)(struct xgbe_prv_data *); 7688c2ecf20Sopenharmony_ci int (*exit)(struct xgbe_prv_data *); 7698c2ecf20Sopenharmony_ci 7708c2ecf20Sopenharmony_ci int (*enable_int)(struct xgbe_channel *, enum xgbe_int); 7718c2ecf20Sopenharmony_ci int (*disable_int)(struct xgbe_channel *, enum xgbe_int); 7728c2ecf20Sopenharmony_ci void (*dev_xmit)(struct xgbe_channel *); 7738c2ecf20Sopenharmony_ci int (*dev_read)(struct xgbe_channel *); 7748c2ecf20Sopenharmony_ci void (*tx_desc_init)(struct xgbe_channel *); 7758c2ecf20Sopenharmony_ci void (*rx_desc_init)(struct xgbe_channel *); 7768c2ecf20Sopenharmony_ci void (*tx_desc_reset)(struct xgbe_ring_data *); 7778c2ecf20Sopenharmony_ci void (*rx_desc_reset)(struct xgbe_prv_data *, struct xgbe_ring_data *, 7788c2ecf20Sopenharmony_ci unsigned int); 7798c2ecf20Sopenharmony_ci int (*is_last_desc)(struct xgbe_ring_desc *); 7808c2ecf20Sopenharmony_ci int (*is_context_desc)(struct xgbe_ring_desc *); 7818c2ecf20Sopenharmony_ci void (*tx_start_xmit)(struct xgbe_channel *, struct xgbe_ring *); 7828c2ecf20Sopenharmony_ci 7838c2ecf20Sopenharmony_ci /* For FLOW ctrl */ 7848c2ecf20Sopenharmony_ci int (*config_tx_flow_control)(struct xgbe_prv_data *); 7858c2ecf20Sopenharmony_ci int (*config_rx_flow_control)(struct xgbe_prv_data *); 7868c2ecf20Sopenharmony_ci 7878c2ecf20Sopenharmony_ci /* For RX coalescing */ 7888c2ecf20Sopenharmony_ci int (*config_rx_coalesce)(struct xgbe_prv_data *); 7898c2ecf20Sopenharmony_ci int (*config_tx_coalesce)(struct xgbe_prv_data *); 7908c2ecf20Sopenharmony_ci unsigned int (*usec_to_riwt)(struct xgbe_prv_data *, unsigned int); 7918c2ecf20Sopenharmony_ci unsigned int (*riwt_to_usec)(struct xgbe_prv_data *, unsigned int); 7928c2ecf20Sopenharmony_ci 7938c2ecf20Sopenharmony_ci /* For RX and TX threshold config */ 7948c2ecf20Sopenharmony_ci int (*config_rx_threshold)(struct xgbe_prv_data *, unsigned int); 7958c2ecf20Sopenharmony_ci int (*config_tx_threshold)(struct xgbe_prv_data *, unsigned int); 7968c2ecf20Sopenharmony_ci 7978c2ecf20Sopenharmony_ci /* For RX and TX Store and Forward Mode config */ 7988c2ecf20Sopenharmony_ci int (*config_rsf_mode)(struct xgbe_prv_data *, unsigned int); 7998c2ecf20Sopenharmony_ci int (*config_tsf_mode)(struct xgbe_prv_data *, unsigned int); 8008c2ecf20Sopenharmony_ci 8018c2ecf20Sopenharmony_ci /* For TX DMA Operate on Second Frame config */ 8028c2ecf20Sopenharmony_ci int (*config_osp_mode)(struct xgbe_prv_data *); 8038c2ecf20Sopenharmony_ci 8048c2ecf20Sopenharmony_ci /* For MMC statistics */ 8058c2ecf20Sopenharmony_ci void (*rx_mmc_int)(struct xgbe_prv_data *); 8068c2ecf20Sopenharmony_ci void (*tx_mmc_int)(struct xgbe_prv_data *); 8078c2ecf20Sopenharmony_ci void (*read_mmc_stats)(struct xgbe_prv_data *); 8088c2ecf20Sopenharmony_ci 8098c2ecf20Sopenharmony_ci /* For Timestamp config */ 8108c2ecf20Sopenharmony_ci int (*config_tstamp)(struct xgbe_prv_data *, unsigned int); 8118c2ecf20Sopenharmony_ci void (*update_tstamp_addend)(struct xgbe_prv_data *, unsigned int); 8128c2ecf20Sopenharmony_ci void (*set_tstamp_time)(struct xgbe_prv_data *, unsigned int sec, 8138c2ecf20Sopenharmony_ci unsigned int nsec); 8148c2ecf20Sopenharmony_ci u64 (*get_tstamp_time)(struct xgbe_prv_data *); 8158c2ecf20Sopenharmony_ci u64 (*get_tx_tstamp)(struct xgbe_prv_data *); 8168c2ecf20Sopenharmony_ci 8178c2ecf20Sopenharmony_ci /* For Data Center Bridging config */ 8188c2ecf20Sopenharmony_ci void (*config_tc)(struct xgbe_prv_data *); 8198c2ecf20Sopenharmony_ci void (*config_dcb_tc)(struct xgbe_prv_data *); 8208c2ecf20Sopenharmony_ci void (*config_dcb_pfc)(struct xgbe_prv_data *); 8218c2ecf20Sopenharmony_ci 8228c2ecf20Sopenharmony_ci /* For Receive Side Scaling */ 8238c2ecf20Sopenharmony_ci int (*enable_rss)(struct xgbe_prv_data *); 8248c2ecf20Sopenharmony_ci int (*disable_rss)(struct xgbe_prv_data *); 8258c2ecf20Sopenharmony_ci int (*set_rss_hash_key)(struct xgbe_prv_data *, const u8 *); 8268c2ecf20Sopenharmony_ci int (*set_rss_lookup_table)(struct xgbe_prv_data *, const u32 *); 8278c2ecf20Sopenharmony_ci 8288c2ecf20Sopenharmony_ci /* For ECC */ 8298c2ecf20Sopenharmony_ci void (*disable_ecc_ded)(struct xgbe_prv_data *); 8308c2ecf20Sopenharmony_ci void (*disable_ecc_sec)(struct xgbe_prv_data *, enum xgbe_ecc_sec); 8318c2ecf20Sopenharmony_ci 8328c2ecf20Sopenharmony_ci /* For VXLAN */ 8338c2ecf20Sopenharmony_ci void (*enable_vxlan)(struct xgbe_prv_data *); 8348c2ecf20Sopenharmony_ci void (*disable_vxlan)(struct xgbe_prv_data *); 8358c2ecf20Sopenharmony_ci void (*set_vxlan_id)(struct xgbe_prv_data *); 8368c2ecf20Sopenharmony_ci}; 8378c2ecf20Sopenharmony_ci 8388c2ecf20Sopenharmony_ci/* This structure represents implementation specific routines for an 8398c2ecf20Sopenharmony_ci * implementation of a PHY. All routines are required unless noted below. 8408c2ecf20Sopenharmony_ci * Optional routines: 8418c2ecf20Sopenharmony_ci * an_pre, an_post 8428c2ecf20Sopenharmony_ci * kr_training_pre, kr_training_post 8438c2ecf20Sopenharmony_ci * module_info, module_eeprom 8448c2ecf20Sopenharmony_ci */ 8458c2ecf20Sopenharmony_cistruct xgbe_phy_impl_if { 8468c2ecf20Sopenharmony_ci /* Perform Setup/teardown actions */ 8478c2ecf20Sopenharmony_ci int (*init)(struct xgbe_prv_data *); 8488c2ecf20Sopenharmony_ci void (*exit)(struct xgbe_prv_data *); 8498c2ecf20Sopenharmony_ci 8508c2ecf20Sopenharmony_ci /* Perform start/stop specific actions */ 8518c2ecf20Sopenharmony_ci int (*reset)(struct xgbe_prv_data *); 8528c2ecf20Sopenharmony_ci int (*start)(struct xgbe_prv_data *); 8538c2ecf20Sopenharmony_ci void (*stop)(struct xgbe_prv_data *); 8548c2ecf20Sopenharmony_ci 8558c2ecf20Sopenharmony_ci /* Return the link status */ 8568c2ecf20Sopenharmony_ci int (*link_status)(struct xgbe_prv_data *, int *); 8578c2ecf20Sopenharmony_ci 8588c2ecf20Sopenharmony_ci /* Indicate if a particular speed is valid */ 8598c2ecf20Sopenharmony_ci bool (*valid_speed)(struct xgbe_prv_data *, int); 8608c2ecf20Sopenharmony_ci 8618c2ecf20Sopenharmony_ci /* Check if the specified mode can/should be used */ 8628c2ecf20Sopenharmony_ci bool (*use_mode)(struct xgbe_prv_data *, enum xgbe_mode); 8638c2ecf20Sopenharmony_ci /* Switch the PHY into various modes */ 8648c2ecf20Sopenharmony_ci void (*set_mode)(struct xgbe_prv_data *, enum xgbe_mode); 8658c2ecf20Sopenharmony_ci /* Retrieve mode needed for a specific speed */ 8668c2ecf20Sopenharmony_ci enum xgbe_mode (*get_mode)(struct xgbe_prv_data *, int); 8678c2ecf20Sopenharmony_ci /* Retrieve new/next mode when trying to auto-negotiate */ 8688c2ecf20Sopenharmony_ci enum xgbe_mode (*switch_mode)(struct xgbe_prv_data *); 8698c2ecf20Sopenharmony_ci /* Retrieve current mode */ 8708c2ecf20Sopenharmony_ci enum xgbe_mode (*cur_mode)(struct xgbe_prv_data *); 8718c2ecf20Sopenharmony_ci 8728c2ecf20Sopenharmony_ci /* Retrieve current auto-negotiation mode */ 8738c2ecf20Sopenharmony_ci enum xgbe_an_mode (*an_mode)(struct xgbe_prv_data *); 8748c2ecf20Sopenharmony_ci 8758c2ecf20Sopenharmony_ci /* Configure auto-negotiation settings */ 8768c2ecf20Sopenharmony_ci int (*an_config)(struct xgbe_prv_data *); 8778c2ecf20Sopenharmony_ci 8788c2ecf20Sopenharmony_ci /* Set/override auto-negotiation advertisement settings */ 8798c2ecf20Sopenharmony_ci void (*an_advertising)(struct xgbe_prv_data *, 8808c2ecf20Sopenharmony_ci struct ethtool_link_ksettings *); 8818c2ecf20Sopenharmony_ci 8828c2ecf20Sopenharmony_ci /* Process results of auto-negotiation */ 8838c2ecf20Sopenharmony_ci enum xgbe_mode (*an_outcome)(struct xgbe_prv_data *); 8848c2ecf20Sopenharmony_ci 8858c2ecf20Sopenharmony_ci /* Pre/Post auto-negotiation support */ 8868c2ecf20Sopenharmony_ci void (*an_pre)(struct xgbe_prv_data *); 8878c2ecf20Sopenharmony_ci void (*an_post)(struct xgbe_prv_data *); 8888c2ecf20Sopenharmony_ci 8898c2ecf20Sopenharmony_ci /* Pre/Post KR training enablement support */ 8908c2ecf20Sopenharmony_ci void (*kr_training_pre)(struct xgbe_prv_data *); 8918c2ecf20Sopenharmony_ci void (*kr_training_post)(struct xgbe_prv_data *); 8928c2ecf20Sopenharmony_ci 8938c2ecf20Sopenharmony_ci /* SFP module related info */ 8948c2ecf20Sopenharmony_ci int (*module_info)(struct xgbe_prv_data *pdata, 8958c2ecf20Sopenharmony_ci struct ethtool_modinfo *modinfo); 8968c2ecf20Sopenharmony_ci int (*module_eeprom)(struct xgbe_prv_data *pdata, 8978c2ecf20Sopenharmony_ci struct ethtool_eeprom *eeprom, u8 *data); 8988c2ecf20Sopenharmony_ci}; 8998c2ecf20Sopenharmony_ci 9008c2ecf20Sopenharmony_cistruct xgbe_phy_if { 9018c2ecf20Sopenharmony_ci /* For PHY setup/teardown */ 9028c2ecf20Sopenharmony_ci int (*phy_init)(struct xgbe_prv_data *); 9038c2ecf20Sopenharmony_ci void (*phy_exit)(struct xgbe_prv_data *); 9048c2ecf20Sopenharmony_ci 9058c2ecf20Sopenharmony_ci /* For PHY support when setting device up/down */ 9068c2ecf20Sopenharmony_ci int (*phy_reset)(struct xgbe_prv_data *); 9078c2ecf20Sopenharmony_ci int (*phy_start)(struct xgbe_prv_data *); 9088c2ecf20Sopenharmony_ci void (*phy_stop)(struct xgbe_prv_data *); 9098c2ecf20Sopenharmony_ci 9108c2ecf20Sopenharmony_ci /* For PHY support while device is up */ 9118c2ecf20Sopenharmony_ci void (*phy_status)(struct xgbe_prv_data *); 9128c2ecf20Sopenharmony_ci int (*phy_config_aneg)(struct xgbe_prv_data *); 9138c2ecf20Sopenharmony_ci 9148c2ecf20Sopenharmony_ci /* For PHY settings validation */ 9158c2ecf20Sopenharmony_ci bool (*phy_valid_speed)(struct xgbe_prv_data *, int); 9168c2ecf20Sopenharmony_ci 9178c2ecf20Sopenharmony_ci /* For single interrupt support */ 9188c2ecf20Sopenharmony_ci irqreturn_t (*an_isr)(struct xgbe_prv_data *); 9198c2ecf20Sopenharmony_ci 9208c2ecf20Sopenharmony_ci /* For ethtool PHY support */ 9218c2ecf20Sopenharmony_ci int (*module_info)(struct xgbe_prv_data *pdata, 9228c2ecf20Sopenharmony_ci struct ethtool_modinfo *modinfo); 9238c2ecf20Sopenharmony_ci int (*module_eeprom)(struct xgbe_prv_data *pdata, 9248c2ecf20Sopenharmony_ci struct ethtool_eeprom *eeprom, u8 *data); 9258c2ecf20Sopenharmony_ci 9268c2ecf20Sopenharmony_ci /* PHY implementation specific services */ 9278c2ecf20Sopenharmony_ci struct xgbe_phy_impl_if phy_impl; 9288c2ecf20Sopenharmony_ci}; 9298c2ecf20Sopenharmony_ci 9308c2ecf20Sopenharmony_cistruct xgbe_i2c_if { 9318c2ecf20Sopenharmony_ci /* For initial I2C setup */ 9328c2ecf20Sopenharmony_ci int (*i2c_init)(struct xgbe_prv_data *); 9338c2ecf20Sopenharmony_ci 9348c2ecf20Sopenharmony_ci /* For I2C support when setting device up/down */ 9358c2ecf20Sopenharmony_ci int (*i2c_start)(struct xgbe_prv_data *); 9368c2ecf20Sopenharmony_ci void (*i2c_stop)(struct xgbe_prv_data *); 9378c2ecf20Sopenharmony_ci 9388c2ecf20Sopenharmony_ci /* For performing I2C operations */ 9398c2ecf20Sopenharmony_ci int (*i2c_xfer)(struct xgbe_prv_data *, struct xgbe_i2c_op *); 9408c2ecf20Sopenharmony_ci 9418c2ecf20Sopenharmony_ci /* For single interrupt support */ 9428c2ecf20Sopenharmony_ci irqreturn_t (*i2c_isr)(struct xgbe_prv_data *); 9438c2ecf20Sopenharmony_ci}; 9448c2ecf20Sopenharmony_ci 9458c2ecf20Sopenharmony_cistruct xgbe_desc_if { 9468c2ecf20Sopenharmony_ci int (*alloc_ring_resources)(struct xgbe_prv_data *); 9478c2ecf20Sopenharmony_ci void (*free_ring_resources)(struct xgbe_prv_data *); 9488c2ecf20Sopenharmony_ci int (*map_tx_skb)(struct xgbe_channel *, struct sk_buff *); 9498c2ecf20Sopenharmony_ci int (*map_rx_buffer)(struct xgbe_prv_data *, struct xgbe_ring *, 9508c2ecf20Sopenharmony_ci struct xgbe_ring_data *); 9518c2ecf20Sopenharmony_ci void (*unmap_rdata)(struct xgbe_prv_data *, struct xgbe_ring_data *); 9528c2ecf20Sopenharmony_ci void (*wrapper_tx_desc_init)(struct xgbe_prv_data *); 9538c2ecf20Sopenharmony_ci void (*wrapper_rx_desc_init)(struct xgbe_prv_data *); 9548c2ecf20Sopenharmony_ci}; 9558c2ecf20Sopenharmony_ci 9568c2ecf20Sopenharmony_ci/* This structure contains flags that indicate what hardware features 9578c2ecf20Sopenharmony_ci * or configurations are present in the device. 9588c2ecf20Sopenharmony_ci */ 9598c2ecf20Sopenharmony_cistruct xgbe_hw_features { 9608c2ecf20Sopenharmony_ci /* HW Version */ 9618c2ecf20Sopenharmony_ci unsigned int version; 9628c2ecf20Sopenharmony_ci 9638c2ecf20Sopenharmony_ci /* HW Feature Register0 */ 9648c2ecf20Sopenharmony_ci unsigned int gmii; /* 1000 Mbps support */ 9658c2ecf20Sopenharmony_ci unsigned int vlhash; /* VLAN Hash Filter */ 9668c2ecf20Sopenharmony_ci unsigned int sma; /* SMA(MDIO) Interface */ 9678c2ecf20Sopenharmony_ci unsigned int rwk; /* PMT remote wake-up packet */ 9688c2ecf20Sopenharmony_ci unsigned int mgk; /* PMT magic packet */ 9698c2ecf20Sopenharmony_ci unsigned int mmc; /* RMON module */ 9708c2ecf20Sopenharmony_ci unsigned int aoe; /* ARP Offload */ 9718c2ecf20Sopenharmony_ci unsigned int ts; /* IEEE 1588-2008 Advanced Timestamp */ 9728c2ecf20Sopenharmony_ci unsigned int eee; /* Energy Efficient Ethernet */ 9738c2ecf20Sopenharmony_ci unsigned int tx_coe; /* Tx Checksum Offload */ 9748c2ecf20Sopenharmony_ci unsigned int rx_coe; /* Rx Checksum Offload */ 9758c2ecf20Sopenharmony_ci unsigned int addn_mac; /* Additional MAC Addresses */ 9768c2ecf20Sopenharmony_ci unsigned int ts_src; /* Timestamp Source */ 9778c2ecf20Sopenharmony_ci unsigned int sa_vlan_ins; /* Source Address or VLAN Insertion */ 9788c2ecf20Sopenharmony_ci unsigned int vxn; /* VXLAN/NVGRE */ 9798c2ecf20Sopenharmony_ci 9808c2ecf20Sopenharmony_ci /* HW Feature Register1 */ 9818c2ecf20Sopenharmony_ci unsigned int rx_fifo_size; /* MTL Receive FIFO Size */ 9828c2ecf20Sopenharmony_ci unsigned int tx_fifo_size; /* MTL Transmit FIFO Size */ 9838c2ecf20Sopenharmony_ci unsigned int adv_ts_hi; /* Advance Timestamping High Word */ 9848c2ecf20Sopenharmony_ci unsigned int dma_width; /* DMA width */ 9858c2ecf20Sopenharmony_ci unsigned int dcb; /* DCB Feature */ 9868c2ecf20Sopenharmony_ci unsigned int sph; /* Split Header Feature */ 9878c2ecf20Sopenharmony_ci unsigned int tso; /* TCP Segmentation Offload */ 9888c2ecf20Sopenharmony_ci unsigned int dma_debug; /* DMA Debug Registers */ 9898c2ecf20Sopenharmony_ci unsigned int rss; /* Receive Side Scaling */ 9908c2ecf20Sopenharmony_ci unsigned int tc_cnt; /* Number of Traffic Classes */ 9918c2ecf20Sopenharmony_ci unsigned int hash_table_size; /* Hash Table Size */ 9928c2ecf20Sopenharmony_ci unsigned int l3l4_filter_num; /* Number of L3-L4 Filters */ 9938c2ecf20Sopenharmony_ci 9948c2ecf20Sopenharmony_ci /* HW Feature Register2 */ 9958c2ecf20Sopenharmony_ci unsigned int rx_q_cnt; /* Number of MTL Receive Queues */ 9968c2ecf20Sopenharmony_ci unsigned int tx_q_cnt; /* Number of MTL Transmit Queues */ 9978c2ecf20Sopenharmony_ci unsigned int rx_ch_cnt; /* Number of DMA Receive Channels */ 9988c2ecf20Sopenharmony_ci unsigned int tx_ch_cnt; /* Number of DMA Transmit Channels */ 9998c2ecf20Sopenharmony_ci unsigned int pps_out_num; /* Number of PPS outputs */ 10008c2ecf20Sopenharmony_ci unsigned int aux_snap_num; /* Number of Aux snapshot inputs */ 10018c2ecf20Sopenharmony_ci}; 10028c2ecf20Sopenharmony_ci 10038c2ecf20Sopenharmony_cistruct xgbe_version_data { 10048c2ecf20Sopenharmony_ci void (*init_function_ptrs_phy_impl)(struct xgbe_phy_if *); 10058c2ecf20Sopenharmony_ci enum xgbe_xpcs_access xpcs_access; 10068c2ecf20Sopenharmony_ci unsigned int mmc_64bit; 10078c2ecf20Sopenharmony_ci unsigned int tx_max_fifo_size; 10088c2ecf20Sopenharmony_ci unsigned int rx_max_fifo_size; 10098c2ecf20Sopenharmony_ci unsigned int tx_tstamp_workaround; 10108c2ecf20Sopenharmony_ci unsigned int ecc_support; 10118c2ecf20Sopenharmony_ci unsigned int i2c_support; 10128c2ecf20Sopenharmony_ci unsigned int irq_reissue_support; 10138c2ecf20Sopenharmony_ci unsigned int tx_desc_prefetch; 10148c2ecf20Sopenharmony_ci unsigned int rx_desc_prefetch; 10158c2ecf20Sopenharmony_ci unsigned int an_cdr_workaround; 10168c2ecf20Sopenharmony_ci}; 10178c2ecf20Sopenharmony_ci 10188c2ecf20Sopenharmony_cistruct xgbe_prv_data { 10198c2ecf20Sopenharmony_ci struct net_device *netdev; 10208c2ecf20Sopenharmony_ci struct pci_dev *pcidev; 10218c2ecf20Sopenharmony_ci struct platform_device *platdev; 10228c2ecf20Sopenharmony_ci struct acpi_device *adev; 10238c2ecf20Sopenharmony_ci struct device *dev; 10248c2ecf20Sopenharmony_ci struct platform_device *phy_platdev; 10258c2ecf20Sopenharmony_ci struct device *phy_dev; 10268c2ecf20Sopenharmony_ci 10278c2ecf20Sopenharmony_ci /* Version related data */ 10288c2ecf20Sopenharmony_ci struct xgbe_version_data *vdata; 10298c2ecf20Sopenharmony_ci 10308c2ecf20Sopenharmony_ci /* ACPI or DT flag */ 10318c2ecf20Sopenharmony_ci unsigned int use_acpi; 10328c2ecf20Sopenharmony_ci 10338c2ecf20Sopenharmony_ci /* XGMAC/XPCS related mmio registers */ 10348c2ecf20Sopenharmony_ci void __iomem *xgmac_regs; /* XGMAC CSRs */ 10358c2ecf20Sopenharmony_ci void __iomem *xpcs_regs; /* XPCS MMD registers */ 10368c2ecf20Sopenharmony_ci void __iomem *rxtx_regs; /* SerDes Rx/Tx CSRs */ 10378c2ecf20Sopenharmony_ci void __iomem *sir0_regs; /* SerDes integration registers (1/2) */ 10388c2ecf20Sopenharmony_ci void __iomem *sir1_regs; /* SerDes integration registers (2/2) */ 10398c2ecf20Sopenharmony_ci void __iomem *xprop_regs; /* XGBE property registers */ 10408c2ecf20Sopenharmony_ci void __iomem *xi2c_regs; /* XGBE I2C CSRs */ 10418c2ecf20Sopenharmony_ci 10428c2ecf20Sopenharmony_ci /* Port property registers */ 10438c2ecf20Sopenharmony_ci unsigned int pp0; 10448c2ecf20Sopenharmony_ci unsigned int pp1; 10458c2ecf20Sopenharmony_ci unsigned int pp2; 10468c2ecf20Sopenharmony_ci unsigned int pp3; 10478c2ecf20Sopenharmony_ci unsigned int pp4; 10488c2ecf20Sopenharmony_ci 10498c2ecf20Sopenharmony_ci /* Overall device lock */ 10508c2ecf20Sopenharmony_ci spinlock_t lock; 10518c2ecf20Sopenharmony_ci 10528c2ecf20Sopenharmony_ci /* XPCS indirect addressing lock */ 10538c2ecf20Sopenharmony_ci spinlock_t xpcs_lock; 10548c2ecf20Sopenharmony_ci unsigned int xpcs_window_def_reg; 10558c2ecf20Sopenharmony_ci unsigned int xpcs_window_sel_reg; 10568c2ecf20Sopenharmony_ci unsigned int xpcs_window; 10578c2ecf20Sopenharmony_ci unsigned int xpcs_window_size; 10588c2ecf20Sopenharmony_ci unsigned int xpcs_window_mask; 10598c2ecf20Sopenharmony_ci 10608c2ecf20Sopenharmony_ci /* RSS addressing mutex */ 10618c2ecf20Sopenharmony_ci struct mutex rss_mutex; 10628c2ecf20Sopenharmony_ci 10638c2ecf20Sopenharmony_ci /* Flags representing xgbe_state */ 10648c2ecf20Sopenharmony_ci unsigned long dev_state; 10658c2ecf20Sopenharmony_ci 10668c2ecf20Sopenharmony_ci /* ECC support */ 10678c2ecf20Sopenharmony_ci unsigned long tx_sec_period; 10688c2ecf20Sopenharmony_ci unsigned long tx_ded_period; 10698c2ecf20Sopenharmony_ci unsigned long rx_sec_period; 10708c2ecf20Sopenharmony_ci unsigned long rx_ded_period; 10718c2ecf20Sopenharmony_ci unsigned long desc_sec_period; 10728c2ecf20Sopenharmony_ci unsigned long desc_ded_period; 10738c2ecf20Sopenharmony_ci 10748c2ecf20Sopenharmony_ci unsigned int tx_sec_count; 10758c2ecf20Sopenharmony_ci unsigned int tx_ded_count; 10768c2ecf20Sopenharmony_ci unsigned int rx_sec_count; 10778c2ecf20Sopenharmony_ci unsigned int rx_ded_count; 10788c2ecf20Sopenharmony_ci unsigned int desc_ded_count; 10798c2ecf20Sopenharmony_ci unsigned int desc_sec_count; 10808c2ecf20Sopenharmony_ci 10818c2ecf20Sopenharmony_ci int dev_irq; 10828c2ecf20Sopenharmony_ci int ecc_irq; 10838c2ecf20Sopenharmony_ci int i2c_irq; 10848c2ecf20Sopenharmony_ci int channel_irq[XGBE_MAX_DMA_CHANNELS]; 10858c2ecf20Sopenharmony_ci 10868c2ecf20Sopenharmony_ci unsigned int per_channel_irq; 10878c2ecf20Sopenharmony_ci unsigned int irq_count; 10888c2ecf20Sopenharmony_ci unsigned int channel_irq_count; 10898c2ecf20Sopenharmony_ci unsigned int channel_irq_mode; 10908c2ecf20Sopenharmony_ci 10918c2ecf20Sopenharmony_ci char ecc_name[IFNAMSIZ + 32]; 10928c2ecf20Sopenharmony_ci 10938c2ecf20Sopenharmony_ci struct xgbe_hw_if hw_if; 10948c2ecf20Sopenharmony_ci struct xgbe_phy_if phy_if; 10958c2ecf20Sopenharmony_ci struct xgbe_desc_if desc_if; 10968c2ecf20Sopenharmony_ci struct xgbe_i2c_if i2c_if; 10978c2ecf20Sopenharmony_ci 10988c2ecf20Sopenharmony_ci /* AXI DMA settings */ 10998c2ecf20Sopenharmony_ci unsigned int coherent; 11008c2ecf20Sopenharmony_ci unsigned int arcr; 11018c2ecf20Sopenharmony_ci unsigned int awcr; 11028c2ecf20Sopenharmony_ci unsigned int awarcr; 11038c2ecf20Sopenharmony_ci 11048c2ecf20Sopenharmony_ci /* Service routine support */ 11058c2ecf20Sopenharmony_ci struct workqueue_struct *dev_workqueue; 11068c2ecf20Sopenharmony_ci struct work_struct service_work; 11078c2ecf20Sopenharmony_ci struct timer_list service_timer; 11088c2ecf20Sopenharmony_ci 11098c2ecf20Sopenharmony_ci /* Rings for Tx/Rx on a DMA channel */ 11108c2ecf20Sopenharmony_ci struct xgbe_channel *channel[XGBE_MAX_DMA_CHANNELS]; 11118c2ecf20Sopenharmony_ci unsigned int tx_max_channel_count; 11128c2ecf20Sopenharmony_ci unsigned int rx_max_channel_count; 11138c2ecf20Sopenharmony_ci unsigned int channel_count; 11148c2ecf20Sopenharmony_ci unsigned int tx_ring_count; 11158c2ecf20Sopenharmony_ci unsigned int tx_desc_count; 11168c2ecf20Sopenharmony_ci unsigned int rx_ring_count; 11178c2ecf20Sopenharmony_ci unsigned int rx_desc_count; 11188c2ecf20Sopenharmony_ci 11198c2ecf20Sopenharmony_ci unsigned int new_tx_ring_count; 11208c2ecf20Sopenharmony_ci unsigned int new_rx_ring_count; 11218c2ecf20Sopenharmony_ci 11228c2ecf20Sopenharmony_ci unsigned int tx_max_q_count; 11238c2ecf20Sopenharmony_ci unsigned int rx_max_q_count; 11248c2ecf20Sopenharmony_ci unsigned int tx_q_count; 11258c2ecf20Sopenharmony_ci unsigned int rx_q_count; 11268c2ecf20Sopenharmony_ci 11278c2ecf20Sopenharmony_ci /* Tx/Rx common settings */ 11288c2ecf20Sopenharmony_ci unsigned int blen; 11298c2ecf20Sopenharmony_ci unsigned int pbl; 11308c2ecf20Sopenharmony_ci unsigned int aal; 11318c2ecf20Sopenharmony_ci unsigned int rd_osr_limit; 11328c2ecf20Sopenharmony_ci unsigned int wr_osr_limit; 11338c2ecf20Sopenharmony_ci 11348c2ecf20Sopenharmony_ci /* Tx settings */ 11358c2ecf20Sopenharmony_ci unsigned int tx_sf_mode; 11368c2ecf20Sopenharmony_ci unsigned int tx_threshold; 11378c2ecf20Sopenharmony_ci unsigned int tx_osp_mode; 11388c2ecf20Sopenharmony_ci unsigned int tx_max_fifo_size; 11398c2ecf20Sopenharmony_ci 11408c2ecf20Sopenharmony_ci /* Rx settings */ 11418c2ecf20Sopenharmony_ci unsigned int rx_sf_mode; 11428c2ecf20Sopenharmony_ci unsigned int rx_threshold; 11438c2ecf20Sopenharmony_ci unsigned int rx_max_fifo_size; 11448c2ecf20Sopenharmony_ci 11458c2ecf20Sopenharmony_ci /* Tx coalescing settings */ 11468c2ecf20Sopenharmony_ci unsigned int tx_usecs; 11478c2ecf20Sopenharmony_ci unsigned int tx_frames; 11488c2ecf20Sopenharmony_ci 11498c2ecf20Sopenharmony_ci /* Rx coalescing settings */ 11508c2ecf20Sopenharmony_ci unsigned int rx_riwt; 11518c2ecf20Sopenharmony_ci unsigned int rx_usecs; 11528c2ecf20Sopenharmony_ci unsigned int rx_frames; 11538c2ecf20Sopenharmony_ci 11548c2ecf20Sopenharmony_ci /* Current Rx buffer size */ 11558c2ecf20Sopenharmony_ci unsigned int rx_buf_size; 11568c2ecf20Sopenharmony_ci 11578c2ecf20Sopenharmony_ci /* Flow control settings */ 11588c2ecf20Sopenharmony_ci unsigned int pause_autoneg; 11598c2ecf20Sopenharmony_ci unsigned int tx_pause; 11608c2ecf20Sopenharmony_ci unsigned int rx_pause; 11618c2ecf20Sopenharmony_ci unsigned int rx_rfa[XGBE_MAX_QUEUES]; 11628c2ecf20Sopenharmony_ci unsigned int rx_rfd[XGBE_MAX_QUEUES]; 11638c2ecf20Sopenharmony_ci 11648c2ecf20Sopenharmony_ci /* Receive Side Scaling settings */ 11658c2ecf20Sopenharmony_ci u8 rss_key[XGBE_RSS_HASH_KEY_SIZE]; 11668c2ecf20Sopenharmony_ci u32 rss_table[XGBE_RSS_MAX_TABLE_SIZE]; 11678c2ecf20Sopenharmony_ci u32 rss_options; 11688c2ecf20Sopenharmony_ci 11698c2ecf20Sopenharmony_ci /* VXLAN settings */ 11708c2ecf20Sopenharmony_ci u16 vxlan_port; 11718c2ecf20Sopenharmony_ci 11728c2ecf20Sopenharmony_ci /* Netdev related settings */ 11738c2ecf20Sopenharmony_ci unsigned char mac_addr[ETH_ALEN]; 11748c2ecf20Sopenharmony_ci netdev_features_t netdev_features; 11758c2ecf20Sopenharmony_ci struct napi_struct napi; 11768c2ecf20Sopenharmony_ci struct xgbe_mmc_stats mmc_stats; 11778c2ecf20Sopenharmony_ci struct xgbe_ext_stats ext_stats; 11788c2ecf20Sopenharmony_ci 11798c2ecf20Sopenharmony_ci /* Filtering support */ 11808c2ecf20Sopenharmony_ci unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; 11818c2ecf20Sopenharmony_ci 11828c2ecf20Sopenharmony_ci /* Device clocks */ 11838c2ecf20Sopenharmony_ci struct clk *sysclk; 11848c2ecf20Sopenharmony_ci unsigned long sysclk_rate; 11858c2ecf20Sopenharmony_ci struct clk *ptpclk; 11868c2ecf20Sopenharmony_ci unsigned long ptpclk_rate; 11878c2ecf20Sopenharmony_ci 11888c2ecf20Sopenharmony_ci /* Timestamp support */ 11898c2ecf20Sopenharmony_ci spinlock_t tstamp_lock; 11908c2ecf20Sopenharmony_ci struct ptp_clock_info ptp_clock_info; 11918c2ecf20Sopenharmony_ci struct ptp_clock *ptp_clock; 11928c2ecf20Sopenharmony_ci struct hwtstamp_config tstamp_config; 11938c2ecf20Sopenharmony_ci struct cyclecounter tstamp_cc; 11948c2ecf20Sopenharmony_ci struct timecounter tstamp_tc; 11958c2ecf20Sopenharmony_ci unsigned int tstamp_addend; 11968c2ecf20Sopenharmony_ci struct work_struct tx_tstamp_work; 11978c2ecf20Sopenharmony_ci struct sk_buff *tx_tstamp_skb; 11988c2ecf20Sopenharmony_ci u64 tx_tstamp; 11998c2ecf20Sopenharmony_ci 12008c2ecf20Sopenharmony_ci /* DCB support */ 12018c2ecf20Sopenharmony_ci struct ieee_ets *ets; 12028c2ecf20Sopenharmony_ci struct ieee_pfc *pfc; 12038c2ecf20Sopenharmony_ci unsigned int q2tc_map[XGBE_MAX_QUEUES]; 12048c2ecf20Sopenharmony_ci unsigned int prio2q_map[IEEE_8021QAZ_MAX_TCS]; 12058c2ecf20Sopenharmony_ci unsigned int pfcq[XGBE_MAX_QUEUES]; 12068c2ecf20Sopenharmony_ci unsigned int pfc_rfa; 12078c2ecf20Sopenharmony_ci u8 num_tcs; 12088c2ecf20Sopenharmony_ci 12098c2ecf20Sopenharmony_ci /* Hardware features of the device */ 12108c2ecf20Sopenharmony_ci struct xgbe_hw_features hw_feat; 12118c2ecf20Sopenharmony_ci 12128c2ecf20Sopenharmony_ci /* Device work structures */ 12138c2ecf20Sopenharmony_ci struct work_struct restart_work; 12148c2ecf20Sopenharmony_ci struct work_struct stopdev_work; 12158c2ecf20Sopenharmony_ci 12168c2ecf20Sopenharmony_ci /* Keeps track of power mode */ 12178c2ecf20Sopenharmony_ci unsigned int power_down; 12188c2ecf20Sopenharmony_ci 12198c2ecf20Sopenharmony_ci /* Network interface message level setting */ 12208c2ecf20Sopenharmony_ci u32 msg_enable; 12218c2ecf20Sopenharmony_ci 12228c2ecf20Sopenharmony_ci /* Current PHY settings */ 12238c2ecf20Sopenharmony_ci phy_interface_t phy_mode; 12248c2ecf20Sopenharmony_ci int phy_link; 12258c2ecf20Sopenharmony_ci int phy_speed; 12268c2ecf20Sopenharmony_ci 12278c2ecf20Sopenharmony_ci /* MDIO/PHY related settings */ 12288c2ecf20Sopenharmony_ci unsigned int phy_started; 12298c2ecf20Sopenharmony_ci void *phy_data; 12308c2ecf20Sopenharmony_ci struct xgbe_phy phy; 12318c2ecf20Sopenharmony_ci int mdio_mmd; 12328c2ecf20Sopenharmony_ci unsigned long link_check; 12338c2ecf20Sopenharmony_ci struct completion mdio_complete; 12348c2ecf20Sopenharmony_ci 12358c2ecf20Sopenharmony_ci unsigned int kr_redrv; 12368c2ecf20Sopenharmony_ci 12378c2ecf20Sopenharmony_ci char an_name[IFNAMSIZ + 32]; 12388c2ecf20Sopenharmony_ci struct workqueue_struct *an_workqueue; 12398c2ecf20Sopenharmony_ci 12408c2ecf20Sopenharmony_ci int an_irq; 12418c2ecf20Sopenharmony_ci struct work_struct an_irq_work; 12428c2ecf20Sopenharmony_ci 12438c2ecf20Sopenharmony_ci /* Auto-negotiation state machine support */ 12448c2ecf20Sopenharmony_ci unsigned int an_int; 12458c2ecf20Sopenharmony_ci unsigned int an_status; 12468c2ecf20Sopenharmony_ci struct mutex an_mutex; 12478c2ecf20Sopenharmony_ci enum xgbe_an an_result; 12488c2ecf20Sopenharmony_ci enum xgbe_an an_state; 12498c2ecf20Sopenharmony_ci enum xgbe_rx kr_state; 12508c2ecf20Sopenharmony_ci enum xgbe_rx kx_state; 12518c2ecf20Sopenharmony_ci struct work_struct an_work; 12528c2ecf20Sopenharmony_ci unsigned int an_again; 12538c2ecf20Sopenharmony_ci unsigned int an_supported; 12548c2ecf20Sopenharmony_ci unsigned int parallel_detect; 12558c2ecf20Sopenharmony_ci unsigned int fec_ability; 12568c2ecf20Sopenharmony_ci unsigned long an_start; 12578c2ecf20Sopenharmony_ci unsigned long kr_start_time; 12588c2ecf20Sopenharmony_ci enum xgbe_an_mode an_mode; 12598c2ecf20Sopenharmony_ci 12608c2ecf20Sopenharmony_ci /* I2C support */ 12618c2ecf20Sopenharmony_ci struct xgbe_i2c i2c; 12628c2ecf20Sopenharmony_ci struct mutex i2c_mutex; 12638c2ecf20Sopenharmony_ci struct completion i2c_complete; 12648c2ecf20Sopenharmony_ci char i2c_name[IFNAMSIZ + 32]; 12658c2ecf20Sopenharmony_ci 12668c2ecf20Sopenharmony_ci unsigned int lpm_ctrl; /* CTRL1 for resume */ 12678c2ecf20Sopenharmony_ci 12688c2ecf20Sopenharmony_ci unsigned int isr_as_tasklet; 12698c2ecf20Sopenharmony_ci struct tasklet_struct tasklet_dev; 12708c2ecf20Sopenharmony_ci struct tasklet_struct tasklet_ecc; 12718c2ecf20Sopenharmony_ci struct tasklet_struct tasklet_i2c; 12728c2ecf20Sopenharmony_ci struct tasklet_struct tasklet_an; 12738c2ecf20Sopenharmony_ci 12748c2ecf20Sopenharmony_ci struct dentry *xgbe_debugfs; 12758c2ecf20Sopenharmony_ci 12768c2ecf20Sopenharmony_ci unsigned int debugfs_xgmac_reg; 12778c2ecf20Sopenharmony_ci 12788c2ecf20Sopenharmony_ci unsigned int debugfs_xpcs_mmd; 12798c2ecf20Sopenharmony_ci unsigned int debugfs_xpcs_reg; 12808c2ecf20Sopenharmony_ci 12818c2ecf20Sopenharmony_ci unsigned int debugfs_xprop_reg; 12828c2ecf20Sopenharmony_ci 12838c2ecf20Sopenharmony_ci unsigned int debugfs_xi2c_reg; 12848c2ecf20Sopenharmony_ci 12858c2ecf20Sopenharmony_ci bool debugfs_an_cdr_workaround; 12868c2ecf20Sopenharmony_ci bool debugfs_an_cdr_track_early; 12878c2ecf20Sopenharmony_ci}; 12888c2ecf20Sopenharmony_ci 12898c2ecf20Sopenharmony_ci/* Function prototypes*/ 12908c2ecf20Sopenharmony_cistruct xgbe_prv_data *xgbe_alloc_pdata(struct device *); 12918c2ecf20Sopenharmony_civoid xgbe_free_pdata(struct xgbe_prv_data *); 12928c2ecf20Sopenharmony_civoid xgbe_set_counts(struct xgbe_prv_data *); 12938c2ecf20Sopenharmony_ciint xgbe_config_netdev(struct xgbe_prv_data *); 12948c2ecf20Sopenharmony_civoid xgbe_deconfig_netdev(struct xgbe_prv_data *); 12958c2ecf20Sopenharmony_ci 12968c2ecf20Sopenharmony_ciint xgbe_platform_init(void); 12978c2ecf20Sopenharmony_civoid xgbe_platform_exit(void); 12988c2ecf20Sopenharmony_ci#ifdef CONFIG_PCI 12998c2ecf20Sopenharmony_ciint xgbe_pci_init(void); 13008c2ecf20Sopenharmony_civoid xgbe_pci_exit(void); 13018c2ecf20Sopenharmony_ci#else 13028c2ecf20Sopenharmony_cistatic inline int xgbe_pci_init(void) { return 0; } 13038c2ecf20Sopenharmony_cistatic inline void xgbe_pci_exit(void) { } 13048c2ecf20Sopenharmony_ci#endif 13058c2ecf20Sopenharmony_ci 13068c2ecf20Sopenharmony_civoid xgbe_init_function_ptrs_dev(struct xgbe_hw_if *); 13078c2ecf20Sopenharmony_civoid xgbe_init_function_ptrs_phy(struct xgbe_phy_if *); 13088c2ecf20Sopenharmony_civoid xgbe_init_function_ptrs_phy_v1(struct xgbe_phy_if *); 13098c2ecf20Sopenharmony_civoid xgbe_init_function_ptrs_phy_v2(struct xgbe_phy_if *); 13108c2ecf20Sopenharmony_civoid xgbe_init_function_ptrs_desc(struct xgbe_desc_if *); 13118c2ecf20Sopenharmony_civoid xgbe_init_function_ptrs_i2c(struct xgbe_i2c_if *); 13128c2ecf20Sopenharmony_ciconst struct net_device_ops *xgbe_get_netdev_ops(void); 13138c2ecf20Sopenharmony_ciconst struct ethtool_ops *xgbe_get_ethtool_ops(void); 13148c2ecf20Sopenharmony_ciconst struct udp_tunnel_nic_info *xgbe_get_udp_tunnel_info(void); 13158c2ecf20Sopenharmony_ci 13168c2ecf20Sopenharmony_ci#ifdef CONFIG_AMD_XGBE_DCB 13178c2ecf20Sopenharmony_ciconst struct dcbnl_rtnl_ops *xgbe_get_dcbnl_ops(void); 13188c2ecf20Sopenharmony_ci#endif 13198c2ecf20Sopenharmony_ci 13208c2ecf20Sopenharmony_civoid xgbe_ptp_register(struct xgbe_prv_data *); 13218c2ecf20Sopenharmony_civoid xgbe_ptp_unregister(struct xgbe_prv_data *); 13228c2ecf20Sopenharmony_civoid xgbe_dump_tx_desc(struct xgbe_prv_data *, struct xgbe_ring *, 13238c2ecf20Sopenharmony_ci unsigned int, unsigned int, unsigned int); 13248c2ecf20Sopenharmony_civoid xgbe_dump_rx_desc(struct xgbe_prv_data *, struct xgbe_ring *, 13258c2ecf20Sopenharmony_ci unsigned int); 13268c2ecf20Sopenharmony_civoid xgbe_print_pkt(struct net_device *, struct sk_buff *, bool); 13278c2ecf20Sopenharmony_civoid xgbe_get_all_hw_features(struct xgbe_prv_data *); 13288c2ecf20Sopenharmony_ciint xgbe_powerup(struct net_device *, unsigned int); 13298c2ecf20Sopenharmony_ciint xgbe_powerdown(struct net_device *, unsigned int); 13308c2ecf20Sopenharmony_civoid xgbe_init_rx_coalesce(struct xgbe_prv_data *); 13318c2ecf20Sopenharmony_civoid xgbe_init_tx_coalesce(struct xgbe_prv_data *); 13328c2ecf20Sopenharmony_civoid xgbe_restart_dev(struct xgbe_prv_data *pdata); 13338c2ecf20Sopenharmony_civoid xgbe_full_restart_dev(struct xgbe_prv_data *pdata); 13348c2ecf20Sopenharmony_ci 13358c2ecf20Sopenharmony_ci#ifdef CONFIG_DEBUG_FS 13368c2ecf20Sopenharmony_civoid xgbe_debugfs_init(struct xgbe_prv_data *); 13378c2ecf20Sopenharmony_civoid xgbe_debugfs_exit(struct xgbe_prv_data *); 13388c2ecf20Sopenharmony_civoid xgbe_debugfs_rename(struct xgbe_prv_data *pdata); 13398c2ecf20Sopenharmony_ci#else 13408c2ecf20Sopenharmony_cistatic inline void xgbe_debugfs_init(struct xgbe_prv_data *pdata) {} 13418c2ecf20Sopenharmony_cistatic inline void xgbe_debugfs_exit(struct xgbe_prv_data *pdata) {} 13428c2ecf20Sopenharmony_cistatic inline void xgbe_debugfs_rename(struct xgbe_prv_data *pdata) {} 13438c2ecf20Sopenharmony_ci#endif /* CONFIG_DEBUG_FS */ 13448c2ecf20Sopenharmony_ci 13458c2ecf20Sopenharmony_ci/* NOTE: Uncomment for function trace log messages in KERNEL LOG */ 13468c2ecf20Sopenharmony_ci#if 0 13478c2ecf20Sopenharmony_ci#define YDEBUG 13488c2ecf20Sopenharmony_ci#define YDEBUG_MDIO 13498c2ecf20Sopenharmony_ci#endif 13508c2ecf20Sopenharmony_ci 13518c2ecf20Sopenharmony_ci/* For debug prints */ 13528c2ecf20Sopenharmony_ci#ifdef YDEBUG 13538c2ecf20Sopenharmony_ci#define DBGPR(x...) pr_alert(x) 13548c2ecf20Sopenharmony_ci#else 13558c2ecf20Sopenharmony_ci#define DBGPR(x...) do { } while (0) 13568c2ecf20Sopenharmony_ci#endif 13578c2ecf20Sopenharmony_ci 13588c2ecf20Sopenharmony_ci#ifdef YDEBUG_MDIO 13598c2ecf20Sopenharmony_ci#define DBGPR_MDIO(x...) pr_alert(x) 13608c2ecf20Sopenharmony_ci#else 13618c2ecf20Sopenharmony_ci#define DBGPR_MDIO(x...) do { } while (0) 13628c2ecf20Sopenharmony_ci#endif 13638c2ecf20Sopenharmony_ci 13648c2ecf20Sopenharmony_ci#endif 1365