162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * AMD 10Gb Ethernet driver 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * This file is available to you under your choice of the following two 562306a36Sopenharmony_ci * licenses: 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * License 1: GPLv2 862306a36Sopenharmony_ci * 962306a36Sopenharmony_ci * Copyright (c) 2014-2016 Advanced Micro Devices, Inc. 1062306a36Sopenharmony_ci * 1162306a36Sopenharmony_ci * This file is free software; you may copy, redistribute and/or modify 1262306a36Sopenharmony_ci * it under the terms of the GNU General Public License as published by 1362306a36Sopenharmony_ci * the Free Software Foundation, either version 2 of the License, or (at 1462306a36Sopenharmony_ci * your option) any later version. 1562306a36Sopenharmony_ci * 1662306a36Sopenharmony_ci * This file is distributed in the hope that it will be useful, but 1762306a36Sopenharmony_ci * WITHOUT ANY WARRANTY; without even the implied warranty of 1862306a36Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1962306a36Sopenharmony_ci * General Public License for more details. 2062306a36Sopenharmony_ci * 2162306a36Sopenharmony_ci * You should have received a copy of the GNU General Public License 2262306a36Sopenharmony_ci * along with this program. If not, see <http://www.gnu.org/licenses/>. 2362306a36Sopenharmony_ci * 2462306a36Sopenharmony_ci * This file incorporates work covered by the following copyright and 2562306a36Sopenharmony_ci * permission notice: 2662306a36Sopenharmony_ci * The Synopsys DWC ETHER XGMAC Software Driver and documentation 2762306a36Sopenharmony_ci * (hereinafter "Software") is an unsupported proprietary work of Synopsys, 2862306a36Sopenharmony_ci * Inc. unless otherwise expressly agreed to in writing between Synopsys 2962306a36Sopenharmony_ci * and you. 3062306a36Sopenharmony_ci * 3162306a36Sopenharmony_ci * The Software IS NOT an item of Licensed Software or Licensed Product 3262306a36Sopenharmony_ci * under any End User Software License Agreement or Agreement for Licensed 3362306a36Sopenharmony_ci * Product with Synopsys or any supplement thereto. Permission is hereby 3462306a36Sopenharmony_ci * granted, free of charge, to any person obtaining a copy of this software 3562306a36Sopenharmony_ci * annotated with this license and the Software, to deal in the Software 3662306a36Sopenharmony_ci * without restriction, including without limitation the rights to use, 3762306a36Sopenharmony_ci * copy, modify, merge, publish, distribute, sublicense, and/or sell copies 3862306a36Sopenharmony_ci * of the Software, and to permit persons to whom the Software is furnished 3962306a36Sopenharmony_ci * to do so, subject to the following conditions: 4062306a36Sopenharmony_ci * 4162306a36Sopenharmony_ci * The above copyright notice and this permission notice shall be included 4262306a36Sopenharmony_ci * in all copies or substantial portions of the Software. 4362306a36Sopenharmony_ci * 4462306a36Sopenharmony_ci * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" 4562306a36Sopenharmony_ci * BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 4662306a36Sopenharmony_ci * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 4762306a36Sopenharmony_ci * PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS 4862306a36Sopenharmony_ci * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 4962306a36Sopenharmony_ci * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 5062306a36Sopenharmony_ci * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 5162306a36Sopenharmony_ci * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 5262306a36Sopenharmony_ci * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 5362306a36Sopenharmony_ci * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 5462306a36Sopenharmony_ci * THE POSSIBILITY OF SUCH DAMAGE. 5562306a36Sopenharmony_ci * 5662306a36Sopenharmony_ci * 5762306a36Sopenharmony_ci * License 2: Modified BSD 5862306a36Sopenharmony_ci * 5962306a36Sopenharmony_ci * Copyright (c) 2014-2016 Advanced Micro Devices, Inc. 6062306a36Sopenharmony_ci * All rights reserved. 6162306a36Sopenharmony_ci * 6262306a36Sopenharmony_ci * Redistribution and use in source and binary forms, with or without 6362306a36Sopenharmony_ci * modification, are permitted provided that the following conditions are met: 6462306a36Sopenharmony_ci * * Redistributions of source code must retain the above copyright 6562306a36Sopenharmony_ci * notice, this list of conditions and the following disclaimer. 6662306a36Sopenharmony_ci * * Redistributions in binary form must reproduce the above copyright 6762306a36Sopenharmony_ci * notice, this list of conditions and the following disclaimer in the 6862306a36Sopenharmony_ci * documentation and/or other materials provided with the distribution. 6962306a36Sopenharmony_ci * * Neither the name of Advanced Micro Devices, Inc. nor the 7062306a36Sopenharmony_ci * names of its contributors may be used to endorse or promote products 7162306a36Sopenharmony_ci * derived from this software without specific prior written permission. 7262306a36Sopenharmony_ci * 7362306a36Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 7462306a36Sopenharmony_ci * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 7562306a36Sopenharmony_ci * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 7662306a36Sopenharmony_ci * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY 7762306a36Sopenharmony_ci * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 7862306a36Sopenharmony_ci * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 7962306a36Sopenharmony_ci * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 8062306a36Sopenharmony_ci * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 8162306a36Sopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 8262306a36Sopenharmony_ci * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 8362306a36Sopenharmony_ci * 8462306a36Sopenharmony_ci * This file incorporates work covered by the following copyright and 8562306a36Sopenharmony_ci * permission notice: 8662306a36Sopenharmony_ci * The Synopsys DWC ETHER XGMAC Software Driver and documentation 8762306a36Sopenharmony_ci * (hereinafter "Software") is an unsupported proprietary work of Synopsys, 8862306a36Sopenharmony_ci * Inc. unless otherwise expressly agreed to in writing between Synopsys 8962306a36Sopenharmony_ci * and you. 9062306a36Sopenharmony_ci * 9162306a36Sopenharmony_ci * The Software IS NOT an item of Licensed Software or Licensed Product 9262306a36Sopenharmony_ci * under any End User Software License Agreement or Agreement for Licensed 9362306a36Sopenharmony_ci * Product with Synopsys or any supplement thereto. Permission is hereby 9462306a36Sopenharmony_ci * granted, free of charge, to any person obtaining a copy of this software 9562306a36Sopenharmony_ci * annotated with this license and the Software, to deal in the Software 9662306a36Sopenharmony_ci * without restriction, including without limitation the rights to use, 9762306a36Sopenharmony_ci * copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9862306a36Sopenharmony_ci * of the Software, and to permit persons to whom the Software is furnished 9962306a36Sopenharmony_ci * to do so, subject to the following conditions: 10062306a36Sopenharmony_ci * 10162306a36Sopenharmony_ci * The above copyright notice and this permission notice shall be included 10262306a36Sopenharmony_ci * in all copies or substantial portions of the Software. 10362306a36Sopenharmony_ci * 10462306a36Sopenharmony_ci * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" 10562306a36Sopenharmony_ci * BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 10662306a36Sopenharmony_ci * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 10762306a36Sopenharmony_ci * PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS 10862306a36Sopenharmony_ci * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 10962306a36Sopenharmony_ci * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 11062306a36Sopenharmony_ci * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 11162306a36Sopenharmony_ci * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 11262306a36Sopenharmony_ci * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 11362306a36Sopenharmony_ci * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 11462306a36Sopenharmony_ci * THE POSSIBILITY OF SUCH DAMAGE. 11562306a36Sopenharmony_ci */ 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci#ifndef __XGBE_H__ 11862306a36Sopenharmony_ci#define __XGBE_H__ 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci#include <linux/dma-mapping.h> 12162306a36Sopenharmony_ci#include <linux/netdevice.h> 12262306a36Sopenharmony_ci#include <linux/workqueue.h> 12362306a36Sopenharmony_ci#include <linux/phy.h> 12462306a36Sopenharmony_ci#include <linux/if_vlan.h> 12562306a36Sopenharmony_ci#include <linux/bitops.h> 12662306a36Sopenharmony_ci#include <linux/ptp_clock_kernel.h> 12762306a36Sopenharmony_ci#include <linux/timecounter.h> 12862306a36Sopenharmony_ci#include <linux/net_tstamp.h> 12962306a36Sopenharmony_ci#include <net/dcbnl.h> 13062306a36Sopenharmony_ci#include <linux/completion.h> 13162306a36Sopenharmony_ci#include <linux/cpumask.h> 13262306a36Sopenharmony_ci#include <linux/interrupt.h> 13362306a36Sopenharmony_ci#include <linux/dcache.h> 13462306a36Sopenharmony_ci#include <linux/ethtool.h> 13562306a36Sopenharmony_ci#include <linux/list.h> 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci#define XGBE_DRV_NAME "amd-xgbe" 13862306a36Sopenharmony_ci#define XGBE_DRV_DESC "AMD 10 Gigabit Ethernet Driver" 13962306a36Sopenharmony_ci 14062306a36Sopenharmony_ci/* Descriptor related defines */ 14162306a36Sopenharmony_ci#define XGBE_TX_DESC_CNT 512 14262306a36Sopenharmony_ci#define XGBE_TX_DESC_MIN_FREE (XGBE_TX_DESC_CNT >> 3) 14362306a36Sopenharmony_ci#define XGBE_TX_DESC_MAX_PROC (XGBE_TX_DESC_CNT >> 1) 14462306a36Sopenharmony_ci#define XGBE_RX_DESC_CNT 512 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_ci#define XGBE_TX_DESC_CNT_MIN 64 14762306a36Sopenharmony_ci#define XGBE_TX_DESC_CNT_MAX 4096 14862306a36Sopenharmony_ci#define XGBE_RX_DESC_CNT_MIN 64 14962306a36Sopenharmony_ci#define XGBE_RX_DESC_CNT_MAX 4096 15062306a36Sopenharmony_ci 15162306a36Sopenharmony_ci#define XGBE_TX_MAX_BUF_SIZE (0x3fff & ~(64 - 1)) 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_ci/* Descriptors required for maximum contiguous TSO/GSO packet */ 15462306a36Sopenharmony_ci#define XGBE_TX_MAX_SPLIT \ 15562306a36Sopenharmony_ci ((GSO_LEGACY_MAX_SIZE / XGBE_TX_MAX_BUF_SIZE) + 1) 15662306a36Sopenharmony_ci 15762306a36Sopenharmony_ci/* Maximum possible descriptors needed for an SKB: 15862306a36Sopenharmony_ci * - Maximum number of SKB frags 15962306a36Sopenharmony_ci * - Maximum descriptors for contiguous TSO/GSO packet 16062306a36Sopenharmony_ci * - Possible context descriptor 16162306a36Sopenharmony_ci * - Possible TSO header descriptor 16262306a36Sopenharmony_ci */ 16362306a36Sopenharmony_ci#define XGBE_TX_MAX_DESCS (MAX_SKB_FRAGS + XGBE_TX_MAX_SPLIT + 2) 16462306a36Sopenharmony_ci 16562306a36Sopenharmony_ci#define XGBE_RX_MIN_BUF_SIZE (ETH_FRAME_LEN + ETH_FCS_LEN + VLAN_HLEN) 16662306a36Sopenharmony_ci#define XGBE_RX_BUF_ALIGN 64 16762306a36Sopenharmony_ci#define XGBE_SKB_ALLOC_SIZE 256 16862306a36Sopenharmony_ci#define XGBE_SPH_HDSMS_SIZE 2 /* Keep in sync with SKB_ALLOC_SIZE */ 16962306a36Sopenharmony_ci 17062306a36Sopenharmony_ci#define XGBE_MAX_DMA_CHANNELS 16 17162306a36Sopenharmony_ci#define XGBE_MAX_QUEUES 16 17262306a36Sopenharmony_ci#define XGBE_PRIORITY_QUEUES 8 17362306a36Sopenharmony_ci#define XGBE_DMA_STOP_TIMEOUT 1 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ci/* DMA cache settings - Outer sharable, write-back, write-allocate */ 17662306a36Sopenharmony_ci#define XGBE_DMA_OS_ARCR 0x002b2b2b 17762306a36Sopenharmony_ci#define XGBE_DMA_OS_AWCR 0x2f2f2f2f 17862306a36Sopenharmony_ci 17962306a36Sopenharmony_ci/* DMA cache settings - System, no caches used */ 18062306a36Sopenharmony_ci#define XGBE_DMA_SYS_ARCR 0x00303030 18162306a36Sopenharmony_ci#define XGBE_DMA_SYS_AWCR 0x30303030 18262306a36Sopenharmony_ci 18362306a36Sopenharmony_ci/* DMA cache settings - PCI device */ 18462306a36Sopenharmony_ci#define XGBE_DMA_PCI_ARCR 0x000f0f0f 18562306a36Sopenharmony_ci#define XGBE_DMA_PCI_AWCR 0x0f0f0f0f 18662306a36Sopenharmony_ci#define XGBE_DMA_PCI_AWARCR 0x00000f0f 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ci/* DMA channel interrupt modes */ 18962306a36Sopenharmony_ci#define XGBE_IRQ_MODE_EDGE 0 19062306a36Sopenharmony_ci#define XGBE_IRQ_MODE_LEVEL 1 19162306a36Sopenharmony_ci 19262306a36Sopenharmony_ci#define XGMAC_MIN_PACKET 60 19362306a36Sopenharmony_ci#define XGMAC_STD_PACKET_MTU 1500 19462306a36Sopenharmony_ci#define XGMAC_MAX_STD_PACKET 1518 19562306a36Sopenharmony_ci#define XGMAC_JUMBO_PACKET_MTU 9000 19662306a36Sopenharmony_ci#define XGMAC_MAX_JUMBO_PACKET 9018 19762306a36Sopenharmony_ci#define XGMAC_ETH_PREAMBLE (12 + 8) /* Inter-frame gap + preamble */ 19862306a36Sopenharmony_ci 19962306a36Sopenharmony_ci#define XGMAC_PFC_DATA_LEN 46 20062306a36Sopenharmony_ci#define XGMAC_PFC_DELAYS 14000 20162306a36Sopenharmony_ci 20262306a36Sopenharmony_ci#define XGMAC_PRIO_QUEUES(_cnt) \ 20362306a36Sopenharmony_ci min_t(unsigned int, IEEE_8021QAZ_MAX_TCS, (_cnt)) 20462306a36Sopenharmony_ci 20562306a36Sopenharmony_ci/* Common property names */ 20662306a36Sopenharmony_ci#define XGBE_MAC_ADDR_PROPERTY "mac-address" 20762306a36Sopenharmony_ci#define XGBE_PHY_MODE_PROPERTY "phy-mode" 20862306a36Sopenharmony_ci#define XGBE_DMA_IRQS_PROPERTY "amd,per-channel-interrupt" 20962306a36Sopenharmony_ci#define XGBE_SPEEDSET_PROPERTY "amd,speed-set" 21062306a36Sopenharmony_ci 21162306a36Sopenharmony_ci/* Device-tree clock names */ 21262306a36Sopenharmony_ci#define XGBE_DMA_CLOCK "dma_clk" 21362306a36Sopenharmony_ci#define XGBE_PTP_CLOCK "ptp_clk" 21462306a36Sopenharmony_ci 21562306a36Sopenharmony_ci/* ACPI property names */ 21662306a36Sopenharmony_ci#define XGBE_ACPI_DMA_FREQ "amd,dma-freq" 21762306a36Sopenharmony_ci#define XGBE_ACPI_PTP_FREQ "amd,ptp-freq" 21862306a36Sopenharmony_ci 21962306a36Sopenharmony_ci/* PCI BAR mapping */ 22062306a36Sopenharmony_ci#define XGBE_XGMAC_BAR 0 22162306a36Sopenharmony_ci#define XGBE_XPCS_BAR 1 22262306a36Sopenharmony_ci#define XGBE_MAC_PROP_OFFSET 0x1d000 22362306a36Sopenharmony_ci#define XGBE_I2C_CTRL_OFFSET 0x1e000 22462306a36Sopenharmony_ci 22562306a36Sopenharmony_ci/* PCI MSI/MSIx support */ 22662306a36Sopenharmony_ci#define XGBE_MSI_BASE_COUNT 4 22762306a36Sopenharmony_ci#define XGBE_MSI_MIN_COUNT (XGBE_MSI_BASE_COUNT + 1) 22862306a36Sopenharmony_ci 22962306a36Sopenharmony_ci/* PCI clock frequencies */ 23062306a36Sopenharmony_ci#define XGBE_V2_DMA_CLOCK_FREQ 500000000 /* 500 MHz */ 23162306a36Sopenharmony_ci#define XGBE_V2_PTP_CLOCK_FREQ 125000000 /* 125 MHz */ 23262306a36Sopenharmony_ci 23362306a36Sopenharmony_ci/* Timestamp support - values based on 50MHz PTP clock 23462306a36Sopenharmony_ci * 50MHz => 20 nsec 23562306a36Sopenharmony_ci */ 23662306a36Sopenharmony_ci#define XGBE_TSTAMP_SSINC 20 23762306a36Sopenharmony_ci#define XGBE_TSTAMP_SNSINC 0 23862306a36Sopenharmony_ci 23962306a36Sopenharmony_ci/* Driver PMT macros */ 24062306a36Sopenharmony_ci#define XGMAC_DRIVER_CONTEXT 1 24162306a36Sopenharmony_ci#define XGMAC_IOCTL_CONTEXT 2 24262306a36Sopenharmony_ci 24362306a36Sopenharmony_ci#define XGMAC_FIFO_MIN_ALLOC 2048 24462306a36Sopenharmony_ci#define XGMAC_FIFO_UNIT 256 24562306a36Sopenharmony_ci#define XGMAC_FIFO_ALIGN(_x) \ 24662306a36Sopenharmony_ci (((_x) + XGMAC_FIFO_UNIT - 1) & ~(XGMAC_FIFO_UNIT - 1)) 24762306a36Sopenharmony_ci#define XGMAC_FIFO_FC_OFF 2048 24862306a36Sopenharmony_ci#define XGMAC_FIFO_FC_MIN 4096 24962306a36Sopenharmony_ci 25062306a36Sopenharmony_ci#define XGBE_TC_MIN_QUANTUM 10 25162306a36Sopenharmony_ci 25262306a36Sopenharmony_ci/* Helper macro for descriptor handling 25362306a36Sopenharmony_ci * Always use XGBE_GET_DESC_DATA to access the descriptor data 25462306a36Sopenharmony_ci * since the index is free-running and needs to be and-ed 25562306a36Sopenharmony_ci * with the descriptor count value of the ring to index to 25662306a36Sopenharmony_ci * the proper descriptor data. 25762306a36Sopenharmony_ci */ 25862306a36Sopenharmony_ci#define XGBE_GET_DESC_DATA(_ring, _idx) \ 25962306a36Sopenharmony_ci ((_ring)->rdata + \ 26062306a36Sopenharmony_ci ((_idx) & ((_ring)->rdesc_count - 1))) 26162306a36Sopenharmony_ci 26262306a36Sopenharmony_ci/* Default coalescing parameters */ 26362306a36Sopenharmony_ci#define XGMAC_INIT_DMA_TX_USECS 1000 26462306a36Sopenharmony_ci#define XGMAC_INIT_DMA_TX_FRAMES 25 26562306a36Sopenharmony_ci 26662306a36Sopenharmony_ci#define XGMAC_MAX_DMA_RIWT 0xff 26762306a36Sopenharmony_ci#define XGMAC_INIT_DMA_RX_USECS 30 26862306a36Sopenharmony_ci#define XGMAC_INIT_DMA_RX_FRAMES 25 26962306a36Sopenharmony_ci 27062306a36Sopenharmony_ci/* Flow control queue count */ 27162306a36Sopenharmony_ci#define XGMAC_MAX_FLOW_CONTROL_QUEUES 8 27262306a36Sopenharmony_ci 27362306a36Sopenharmony_ci/* Flow control threshold units */ 27462306a36Sopenharmony_ci#define XGMAC_FLOW_CONTROL_UNIT 512 27562306a36Sopenharmony_ci#define XGMAC_FLOW_CONTROL_ALIGN(_x) \ 27662306a36Sopenharmony_ci (((_x) + XGMAC_FLOW_CONTROL_UNIT - 1) & ~(XGMAC_FLOW_CONTROL_UNIT - 1)) 27762306a36Sopenharmony_ci#define XGMAC_FLOW_CONTROL_VALUE(_x) \ 27862306a36Sopenharmony_ci (((_x) < 1024) ? 0 : ((_x) / XGMAC_FLOW_CONTROL_UNIT) - 2) 27962306a36Sopenharmony_ci#define XGMAC_FLOW_CONTROL_MAX 33280 28062306a36Sopenharmony_ci 28162306a36Sopenharmony_ci/* Maximum MAC address hash table size (256 bits = 8 bytes) */ 28262306a36Sopenharmony_ci#define XGBE_MAC_HASH_TABLE_SIZE 8 28362306a36Sopenharmony_ci 28462306a36Sopenharmony_ci/* Receive Side Scaling */ 28562306a36Sopenharmony_ci#define XGBE_RSS_HASH_KEY_SIZE 40 28662306a36Sopenharmony_ci#define XGBE_RSS_MAX_TABLE_SIZE 256 28762306a36Sopenharmony_ci#define XGBE_RSS_LOOKUP_TABLE_TYPE 0 28862306a36Sopenharmony_ci#define XGBE_RSS_HASH_KEY_TYPE 1 28962306a36Sopenharmony_ci 29062306a36Sopenharmony_ci/* Auto-negotiation */ 29162306a36Sopenharmony_ci#define XGBE_AN_MS_TIMEOUT 500 29262306a36Sopenharmony_ci#define XGBE_LINK_TIMEOUT 5 29362306a36Sopenharmony_ci#define XGBE_KR_TRAINING_WAIT_ITER 50 29462306a36Sopenharmony_ci 29562306a36Sopenharmony_ci#define XGBE_SGMII_AN_LINK_STATUS BIT(1) 29662306a36Sopenharmony_ci#define XGBE_SGMII_AN_LINK_SPEED (BIT(2) | BIT(3)) 29762306a36Sopenharmony_ci#define XGBE_SGMII_AN_LINK_SPEED_10 0x00 29862306a36Sopenharmony_ci#define XGBE_SGMII_AN_LINK_SPEED_100 0x04 29962306a36Sopenharmony_ci#define XGBE_SGMII_AN_LINK_SPEED_1000 0x08 30062306a36Sopenharmony_ci#define XGBE_SGMII_AN_LINK_DUPLEX BIT(4) 30162306a36Sopenharmony_ci 30262306a36Sopenharmony_ci/* ECC correctable error notification window (seconds) */ 30362306a36Sopenharmony_ci#define XGBE_ECC_LIMIT 60 30462306a36Sopenharmony_ci 30562306a36Sopenharmony_ci/* MDIO port types */ 30662306a36Sopenharmony_ci#define XGMAC_MAX_C22_PORT 3 30762306a36Sopenharmony_ci 30862306a36Sopenharmony_ci/* Link mode bit operations */ 30962306a36Sopenharmony_ci#define XGBE_ZERO_SUP(_ls) \ 31062306a36Sopenharmony_ci ethtool_link_ksettings_zero_link_mode((_ls), supported) 31162306a36Sopenharmony_ci 31262306a36Sopenharmony_ci#define XGBE_SET_SUP(_ls, _mode) \ 31362306a36Sopenharmony_ci ethtool_link_ksettings_add_link_mode((_ls), supported, _mode) 31462306a36Sopenharmony_ci 31562306a36Sopenharmony_ci#define XGBE_CLR_SUP(_ls, _mode) \ 31662306a36Sopenharmony_ci ethtool_link_ksettings_del_link_mode((_ls), supported, _mode) 31762306a36Sopenharmony_ci 31862306a36Sopenharmony_ci#define XGBE_IS_SUP(_ls, _mode) \ 31962306a36Sopenharmony_ci ethtool_link_ksettings_test_link_mode((_ls), supported, _mode) 32062306a36Sopenharmony_ci 32162306a36Sopenharmony_ci#define XGBE_ZERO_ADV(_ls) \ 32262306a36Sopenharmony_ci ethtool_link_ksettings_zero_link_mode((_ls), advertising) 32362306a36Sopenharmony_ci 32462306a36Sopenharmony_ci#define XGBE_SET_ADV(_ls, _mode) \ 32562306a36Sopenharmony_ci ethtool_link_ksettings_add_link_mode((_ls), advertising, _mode) 32662306a36Sopenharmony_ci 32762306a36Sopenharmony_ci#define XGBE_CLR_ADV(_ls, _mode) \ 32862306a36Sopenharmony_ci ethtool_link_ksettings_del_link_mode((_ls), advertising, _mode) 32962306a36Sopenharmony_ci 33062306a36Sopenharmony_ci#define XGBE_ADV(_ls, _mode) \ 33162306a36Sopenharmony_ci ethtool_link_ksettings_test_link_mode((_ls), advertising, _mode) 33262306a36Sopenharmony_ci 33362306a36Sopenharmony_ci#define XGBE_ZERO_LP_ADV(_ls) \ 33462306a36Sopenharmony_ci ethtool_link_ksettings_zero_link_mode((_ls), lp_advertising) 33562306a36Sopenharmony_ci 33662306a36Sopenharmony_ci#define XGBE_SET_LP_ADV(_ls, _mode) \ 33762306a36Sopenharmony_ci ethtool_link_ksettings_add_link_mode((_ls), lp_advertising, _mode) 33862306a36Sopenharmony_ci 33962306a36Sopenharmony_ci#define XGBE_CLR_LP_ADV(_ls, _mode) \ 34062306a36Sopenharmony_ci ethtool_link_ksettings_del_link_mode((_ls), lp_advertising, _mode) 34162306a36Sopenharmony_ci 34262306a36Sopenharmony_ci#define XGBE_LP_ADV(_ls, _mode) \ 34362306a36Sopenharmony_ci ethtool_link_ksettings_test_link_mode((_ls), lp_advertising, _mode) 34462306a36Sopenharmony_ci 34562306a36Sopenharmony_ci#define XGBE_LM_COPY(_dst, _dname, _src, _sname) \ 34662306a36Sopenharmony_ci bitmap_copy((_dst)->link_modes._dname, \ 34762306a36Sopenharmony_ci (_src)->link_modes._sname, \ 34862306a36Sopenharmony_ci __ETHTOOL_LINK_MODE_MASK_NBITS) 34962306a36Sopenharmony_ci 35062306a36Sopenharmony_cistruct xgbe_prv_data; 35162306a36Sopenharmony_ci 35262306a36Sopenharmony_cistruct xgbe_packet_data { 35362306a36Sopenharmony_ci struct sk_buff *skb; 35462306a36Sopenharmony_ci 35562306a36Sopenharmony_ci unsigned int attributes; 35662306a36Sopenharmony_ci 35762306a36Sopenharmony_ci unsigned int errors; 35862306a36Sopenharmony_ci 35962306a36Sopenharmony_ci unsigned int rdesc_count; 36062306a36Sopenharmony_ci unsigned int length; 36162306a36Sopenharmony_ci 36262306a36Sopenharmony_ci unsigned int header_len; 36362306a36Sopenharmony_ci unsigned int tcp_header_len; 36462306a36Sopenharmony_ci unsigned int tcp_payload_len; 36562306a36Sopenharmony_ci unsigned short mss; 36662306a36Sopenharmony_ci 36762306a36Sopenharmony_ci unsigned short vlan_ctag; 36862306a36Sopenharmony_ci 36962306a36Sopenharmony_ci u64 rx_tstamp; 37062306a36Sopenharmony_ci 37162306a36Sopenharmony_ci u32 rss_hash; 37262306a36Sopenharmony_ci enum pkt_hash_types rss_hash_type; 37362306a36Sopenharmony_ci 37462306a36Sopenharmony_ci unsigned int tx_packets; 37562306a36Sopenharmony_ci unsigned int tx_bytes; 37662306a36Sopenharmony_ci}; 37762306a36Sopenharmony_ci 37862306a36Sopenharmony_ci/* Common Rx and Tx descriptor mapping */ 37962306a36Sopenharmony_cistruct xgbe_ring_desc { 38062306a36Sopenharmony_ci __le32 desc0; 38162306a36Sopenharmony_ci __le32 desc1; 38262306a36Sopenharmony_ci __le32 desc2; 38362306a36Sopenharmony_ci __le32 desc3; 38462306a36Sopenharmony_ci}; 38562306a36Sopenharmony_ci 38662306a36Sopenharmony_ci/* Page allocation related values */ 38762306a36Sopenharmony_cistruct xgbe_page_alloc { 38862306a36Sopenharmony_ci struct page *pages; 38962306a36Sopenharmony_ci unsigned int pages_len; 39062306a36Sopenharmony_ci unsigned int pages_offset; 39162306a36Sopenharmony_ci 39262306a36Sopenharmony_ci dma_addr_t pages_dma; 39362306a36Sopenharmony_ci}; 39462306a36Sopenharmony_ci 39562306a36Sopenharmony_ci/* Ring entry buffer data */ 39662306a36Sopenharmony_cistruct xgbe_buffer_data { 39762306a36Sopenharmony_ci struct xgbe_page_alloc pa; 39862306a36Sopenharmony_ci struct xgbe_page_alloc pa_unmap; 39962306a36Sopenharmony_ci 40062306a36Sopenharmony_ci dma_addr_t dma_base; 40162306a36Sopenharmony_ci unsigned long dma_off; 40262306a36Sopenharmony_ci unsigned int dma_len; 40362306a36Sopenharmony_ci}; 40462306a36Sopenharmony_ci 40562306a36Sopenharmony_ci/* Tx-related ring data */ 40662306a36Sopenharmony_cistruct xgbe_tx_ring_data { 40762306a36Sopenharmony_ci unsigned int packets; /* BQL packet count */ 40862306a36Sopenharmony_ci unsigned int bytes; /* BQL byte count */ 40962306a36Sopenharmony_ci}; 41062306a36Sopenharmony_ci 41162306a36Sopenharmony_ci/* Rx-related ring data */ 41262306a36Sopenharmony_cistruct xgbe_rx_ring_data { 41362306a36Sopenharmony_ci struct xgbe_buffer_data hdr; /* Header locations */ 41462306a36Sopenharmony_ci struct xgbe_buffer_data buf; /* Payload locations */ 41562306a36Sopenharmony_ci 41662306a36Sopenharmony_ci unsigned short hdr_len; /* Length of received header */ 41762306a36Sopenharmony_ci unsigned short len; /* Length of received packet */ 41862306a36Sopenharmony_ci}; 41962306a36Sopenharmony_ci 42062306a36Sopenharmony_ci/* Structure used to hold information related to the descriptor 42162306a36Sopenharmony_ci * and the packet associated with the descriptor (always use 42262306a36Sopenharmony_ci * the XGBE_GET_DESC_DATA macro to access this data from the ring) 42362306a36Sopenharmony_ci */ 42462306a36Sopenharmony_cistruct xgbe_ring_data { 42562306a36Sopenharmony_ci struct xgbe_ring_desc *rdesc; /* Virtual address of descriptor */ 42662306a36Sopenharmony_ci dma_addr_t rdesc_dma; /* DMA address of descriptor */ 42762306a36Sopenharmony_ci 42862306a36Sopenharmony_ci struct sk_buff *skb; /* Virtual address of SKB */ 42962306a36Sopenharmony_ci dma_addr_t skb_dma; /* DMA address of SKB data */ 43062306a36Sopenharmony_ci unsigned int skb_dma_len; /* Length of SKB DMA area */ 43162306a36Sopenharmony_ci 43262306a36Sopenharmony_ci struct xgbe_tx_ring_data tx; /* Tx-related data */ 43362306a36Sopenharmony_ci struct xgbe_rx_ring_data rx; /* Rx-related data */ 43462306a36Sopenharmony_ci 43562306a36Sopenharmony_ci unsigned int mapped_as_page; 43662306a36Sopenharmony_ci 43762306a36Sopenharmony_ci /* Incomplete receive save location. If the budget is exhausted 43862306a36Sopenharmony_ci * or the last descriptor (last normal descriptor or a following 43962306a36Sopenharmony_ci * context descriptor) has not been DMA'd yet the current state 44062306a36Sopenharmony_ci * of the receive processing needs to be saved. 44162306a36Sopenharmony_ci */ 44262306a36Sopenharmony_ci unsigned int state_saved; 44362306a36Sopenharmony_ci struct { 44462306a36Sopenharmony_ci struct sk_buff *skb; 44562306a36Sopenharmony_ci unsigned int len; 44662306a36Sopenharmony_ci unsigned int error; 44762306a36Sopenharmony_ci } state; 44862306a36Sopenharmony_ci}; 44962306a36Sopenharmony_ci 45062306a36Sopenharmony_cistruct xgbe_ring { 45162306a36Sopenharmony_ci /* Ring lock - used just for TX rings at the moment */ 45262306a36Sopenharmony_ci spinlock_t lock; 45362306a36Sopenharmony_ci 45462306a36Sopenharmony_ci /* Per packet related information */ 45562306a36Sopenharmony_ci struct xgbe_packet_data packet_data; 45662306a36Sopenharmony_ci 45762306a36Sopenharmony_ci /* Virtual/DMA addresses and count of allocated descriptor memory */ 45862306a36Sopenharmony_ci struct xgbe_ring_desc *rdesc; 45962306a36Sopenharmony_ci dma_addr_t rdesc_dma; 46062306a36Sopenharmony_ci unsigned int rdesc_count; 46162306a36Sopenharmony_ci 46262306a36Sopenharmony_ci /* Array of descriptor data corresponding the descriptor memory 46362306a36Sopenharmony_ci * (always use the XGBE_GET_DESC_DATA macro to access this data) 46462306a36Sopenharmony_ci */ 46562306a36Sopenharmony_ci struct xgbe_ring_data *rdata; 46662306a36Sopenharmony_ci 46762306a36Sopenharmony_ci /* Page allocation for RX buffers */ 46862306a36Sopenharmony_ci struct xgbe_page_alloc rx_hdr_pa; 46962306a36Sopenharmony_ci struct xgbe_page_alloc rx_buf_pa; 47062306a36Sopenharmony_ci int node; 47162306a36Sopenharmony_ci 47262306a36Sopenharmony_ci /* Ring index values 47362306a36Sopenharmony_ci * cur - Tx: index of descriptor to be used for current transfer 47462306a36Sopenharmony_ci * Rx: index of descriptor to check for packet availability 47562306a36Sopenharmony_ci * dirty - Tx: index of descriptor to check for transfer complete 47662306a36Sopenharmony_ci * Rx: index of descriptor to check for buffer reallocation 47762306a36Sopenharmony_ci */ 47862306a36Sopenharmony_ci unsigned int cur; 47962306a36Sopenharmony_ci unsigned int dirty; 48062306a36Sopenharmony_ci 48162306a36Sopenharmony_ci /* Coalesce frame count used for interrupt bit setting */ 48262306a36Sopenharmony_ci unsigned int coalesce_count; 48362306a36Sopenharmony_ci 48462306a36Sopenharmony_ci union { 48562306a36Sopenharmony_ci struct { 48662306a36Sopenharmony_ci unsigned int queue_stopped; 48762306a36Sopenharmony_ci unsigned int xmit_more; 48862306a36Sopenharmony_ci unsigned short cur_mss; 48962306a36Sopenharmony_ci unsigned short cur_vlan_ctag; 49062306a36Sopenharmony_ci } tx; 49162306a36Sopenharmony_ci }; 49262306a36Sopenharmony_ci} ____cacheline_aligned; 49362306a36Sopenharmony_ci 49462306a36Sopenharmony_ci/* Structure used to describe the descriptor rings associated with 49562306a36Sopenharmony_ci * a DMA channel. 49662306a36Sopenharmony_ci */ 49762306a36Sopenharmony_cistruct xgbe_channel { 49862306a36Sopenharmony_ci char name[16]; 49962306a36Sopenharmony_ci 50062306a36Sopenharmony_ci /* Address of private data area for device */ 50162306a36Sopenharmony_ci struct xgbe_prv_data *pdata; 50262306a36Sopenharmony_ci 50362306a36Sopenharmony_ci /* Queue index and base address of queue's DMA registers */ 50462306a36Sopenharmony_ci unsigned int queue_index; 50562306a36Sopenharmony_ci void __iomem *dma_regs; 50662306a36Sopenharmony_ci 50762306a36Sopenharmony_ci /* Per channel interrupt irq number */ 50862306a36Sopenharmony_ci int dma_irq; 50962306a36Sopenharmony_ci char dma_irq_name[IFNAMSIZ + 32]; 51062306a36Sopenharmony_ci 51162306a36Sopenharmony_ci /* Netdev related settings */ 51262306a36Sopenharmony_ci struct napi_struct napi; 51362306a36Sopenharmony_ci 51462306a36Sopenharmony_ci /* Per channel interrupt enablement tracker */ 51562306a36Sopenharmony_ci unsigned int curr_ier; 51662306a36Sopenharmony_ci unsigned int saved_ier; 51762306a36Sopenharmony_ci 51862306a36Sopenharmony_ci unsigned int tx_timer_active; 51962306a36Sopenharmony_ci struct timer_list tx_timer; 52062306a36Sopenharmony_ci 52162306a36Sopenharmony_ci struct xgbe_ring *tx_ring; 52262306a36Sopenharmony_ci struct xgbe_ring *rx_ring; 52362306a36Sopenharmony_ci 52462306a36Sopenharmony_ci int node; 52562306a36Sopenharmony_ci cpumask_t affinity_mask; 52662306a36Sopenharmony_ci} ____cacheline_aligned; 52762306a36Sopenharmony_ci 52862306a36Sopenharmony_cienum xgbe_state { 52962306a36Sopenharmony_ci XGBE_DOWN, 53062306a36Sopenharmony_ci XGBE_LINK_INIT, 53162306a36Sopenharmony_ci XGBE_LINK_ERR, 53262306a36Sopenharmony_ci XGBE_STOPPED, 53362306a36Sopenharmony_ci}; 53462306a36Sopenharmony_ci 53562306a36Sopenharmony_cienum xgbe_int { 53662306a36Sopenharmony_ci XGMAC_INT_DMA_CH_SR_TI, 53762306a36Sopenharmony_ci XGMAC_INT_DMA_CH_SR_TPS, 53862306a36Sopenharmony_ci XGMAC_INT_DMA_CH_SR_TBU, 53962306a36Sopenharmony_ci XGMAC_INT_DMA_CH_SR_RI, 54062306a36Sopenharmony_ci XGMAC_INT_DMA_CH_SR_RBU, 54162306a36Sopenharmony_ci XGMAC_INT_DMA_CH_SR_RPS, 54262306a36Sopenharmony_ci XGMAC_INT_DMA_CH_SR_TI_RI, 54362306a36Sopenharmony_ci XGMAC_INT_DMA_CH_SR_FBE, 54462306a36Sopenharmony_ci XGMAC_INT_DMA_ALL, 54562306a36Sopenharmony_ci}; 54662306a36Sopenharmony_ci 54762306a36Sopenharmony_cienum xgbe_int_state { 54862306a36Sopenharmony_ci XGMAC_INT_STATE_SAVE, 54962306a36Sopenharmony_ci XGMAC_INT_STATE_RESTORE, 55062306a36Sopenharmony_ci}; 55162306a36Sopenharmony_ci 55262306a36Sopenharmony_cienum xgbe_ecc_sec { 55362306a36Sopenharmony_ci XGBE_ECC_SEC_TX, 55462306a36Sopenharmony_ci XGBE_ECC_SEC_RX, 55562306a36Sopenharmony_ci XGBE_ECC_SEC_DESC, 55662306a36Sopenharmony_ci}; 55762306a36Sopenharmony_ci 55862306a36Sopenharmony_cienum xgbe_speed { 55962306a36Sopenharmony_ci XGBE_SPEED_1000 = 0, 56062306a36Sopenharmony_ci XGBE_SPEED_2500, 56162306a36Sopenharmony_ci XGBE_SPEED_10000, 56262306a36Sopenharmony_ci XGBE_SPEEDS, 56362306a36Sopenharmony_ci}; 56462306a36Sopenharmony_ci 56562306a36Sopenharmony_cienum xgbe_xpcs_access { 56662306a36Sopenharmony_ci XGBE_XPCS_ACCESS_V1 = 0, 56762306a36Sopenharmony_ci XGBE_XPCS_ACCESS_V2, 56862306a36Sopenharmony_ci}; 56962306a36Sopenharmony_ci 57062306a36Sopenharmony_cienum xgbe_an_mode { 57162306a36Sopenharmony_ci XGBE_AN_MODE_CL73 = 0, 57262306a36Sopenharmony_ci XGBE_AN_MODE_CL73_REDRV, 57362306a36Sopenharmony_ci XGBE_AN_MODE_CL37, 57462306a36Sopenharmony_ci XGBE_AN_MODE_CL37_SGMII, 57562306a36Sopenharmony_ci XGBE_AN_MODE_NONE, 57662306a36Sopenharmony_ci}; 57762306a36Sopenharmony_ci 57862306a36Sopenharmony_cienum xgbe_an { 57962306a36Sopenharmony_ci XGBE_AN_READY = 0, 58062306a36Sopenharmony_ci XGBE_AN_PAGE_RECEIVED, 58162306a36Sopenharmony_ci XGBE_AN_INCOMPAT_LINK, 58262306a36Sopenharmony_ci XGBE_AN_COMPLETE, 58362306a36Sopenharmony_ci XGBE_AN_NO_LINK, 58462306a36Sopenharmony_ci XGBE_AN_ERROR, 58562306a36Sopenharmony_ci}; 58662306a36Sopenharmony_ci 58762306a36Sopenharmony_cienum xgbe_rx { 58862306a36Sopenharmony_ci XGBE_RX_BPA = 0, 58962306a36Sopenharmony_ci XGBE_RX_XNP, 59062306a36Sopenharmony_ci XGBE_RX_COMPLETE, 59162306a36Sopenharmony_ci XGBE_RX_ERROR, 59262306a36Sopenharmony_ci}; 59362306a36Sopenharmony_ci 59462306a36Sopenharmony_cienum xgbe_mode { 59562306a36Sopenharmony_ci XGBE_MODE_KX_1000 = 0, 59662306a36Sopenharmony_ci XGBE_MODE_KX_2500, 59762306a36Sopenharmony_ci XGBE_MODE_KR, 59862306a36Sopenharmony_ci XGBE_MODE_X, 59962306a36Sopenharmony_ci XGBE_MODE_SGMII_10, 60062306a36Sopenharmony_ci XGBE_MODE_SGMII_100, 60162306a36Sopenharmony_ci XGBE_MODE_SGMII_1000, 60262306a36Sopenharmony_ci XGBE_MODE_SFI, 60362306a36Sopenharmony_ci XGBE_MODE_UNKNOWN, 60462306a36Sopenharmony_ci}; 60562306a36Sopenharmony_ci 60662306a36Sopenharmony_cienum xgbe_speedset { 60762306a36Sopenharmony_ci XGBE_SPEEDSET_1000_10000 = 0, 60862306a36Sopenharmony_ci XGBE_SPEEDSET_2500_10000, 60962306a36Sopenharmony_ci}; 61062306a36Sopenharmony_ci 61162306a36Sopenharmony_cienum xgbe_mdio_mode { 61262306a36Sopenharmony_ci XGBE_MDIO_MODE_NONE = 0, 61362306a36Sopenharmony_ci XGBE_MDIO_MODE_CL22, 61462306a36Sopenharmony_ci XGBE_MDIO_MODE_CL45, 61562306a36Sopenharmony_ci}; 61662306a36Sopenharmony_ci 61762306a36Sopenharmony_cienum xgbe_mb_cmd { 61862306a36Sopenharmony_ci XGBE_MB_CMD_POWER_OFF = 0, 61962306a36Sopenharmony_ci XGBE_MB_CMD_SET_1G, 62062306a36Sopenharmony_ci XGBE_MB_CMD_SET_2_5G, 62162306a36Sopenharmony_ci XGBE_MB_CMD_SET_10G_SFI, 62262306a36Sopenharmony_ci XGBE_MB_CMD_SET_10G_KR, 62362306a36Sopenharmony_ci XGBE_MB_CMD_RRC 62462306a36Sopenharmony_ci}; 62562306a36Sopenharmony_ci 62662306a36Sopenharmony_cienum xgbe_mb_subcmd { 62762306a36Sopenharmony_ci XGBE_MB_SUBCMD_NONE = 0, 62862306a36Sopenharmony_ci XGBE_MB_SUBCMD_RX_ADAP, 62962306a36Sopenharmony_ci 63062306a36Sopenharmony_ci /* 10GbE SFP subcommands */ 63162306a36Sopenharmony_ci XGBE_MB_SUBCMD_ACTIVE = 0, 63262306a36Sopenharmony_ci XGBE_MB_SUBCMD_PASSIVE_1M, 63362306a36Sopenharmony_ci XGBE_MB_SUBCMD_PASSIVE_3M, 63462306a36Sopenharmony_ci XGBE_MB_SUBCMD_PASSIVE_OTHER, 63562306a36Sopenharmony_ci 63662306a36Sopenharmony_ci /* 1GbE Mode subcommands */ 63762306a36Sopenharmony_ci XGBE_MB_SUBCMD_10MBITS = 0, 63862306a36Sopenharmony_ci XGBE_MB_SUBCMD_100MBITS, 63962306a36Sopenharmony_ci XGBE_MB_SUBCMD_1G_SGMII, 64062306a36Sopenharmony_ci XGBE_MB_SUBCMD_1G_KX 64162306a36Sopenharmony_ci}; 64262306a36Sopenharmony_ci 64362306a36Sopenharmony_cistruct xgbe_phy { 64462306a36Sopenharmony_ci struct ethtool_link_ksettings lks; 64562306a36Sopenharmony_ci 64662306a36Sopenharmony_ci int address; 64762306a36Sopenharmony_ci 64862306a36Sopenharmony_ci int autoneg; 64962306a36Sopenharmony_ci int speed; 65062306a36Sopenharmony_ci int duplex; 65162306a36Sopenharmony_ci 65262306a36Sopenharmony_ci int link; 65362306a36Sopenharmony_ci 65462306a36Sopenharmony_ci int pause_autoneg; 65562306a36Sopenharmony_ci int tx_pause; 65662306a36Sopenharmony_ci int rx_pause; 65762306a36Sopenharmony_ci}; 65862306a36Sopenharmony_ci 65962306a36Sopenharmony_cienum xgbe_i2c_cmd { 66062306a36Sopenharmony_ci XGBE_I2C_CMD_READ = 0, 66162306a36Sopenharmony_ci XGBE_I2C_CMD_WRITE, 66262306a36Sopenharmony_ci}; 66362306a36Sopenharmony_ci 66462306a36Sopenharmony_cistruct xgbe_i2c_op { 66562306a36Sopenharmony_ci enum xgbe_i2c_cmd cmd; 66662306a36Sopenharmony_ci 66762306a36Sopenharmony_ci unsigned int target; 66862306a36Sopenharmony_ci 66962306a36Sopenharmony_ci void *buf; 67062306a36Sopenharmony_ci unsigned int len; 67162306a36Sopenharmony_ci}; 67262306a36Sopenharmony_ci 67362306a36Sopenharmony_cistruct xgbe_i2c_op_state { 67462306a36Sopenharmony_ci struct xgbe_i2c_op *op; 67562306a36Sopenharmony_ci 67662306a36Sopenharmony_ci unsigned int tx_len; 67762306a36Sopenharmony_ci unsigned char *tx_buf; 67862306a36Sopenharmony_ci 67962306a36Sopenharmony_ci unsigned int rx_len; 68062306a36Sopenharmony_ci unsigned char *rx_buf; 68162306a36Sopenharmony_ci 68262306a36Sopenharmony_ci unsigned int tx_abort_source; 68362306a36Sopenharmony_ci 68462306a36Sopenharmony_ci int ret; 68562306a36Sopenharmony_ci}; 68662306a36Sopenharmony_ci 68762306a36Sopenharmony_cistruct xgbe_i2c { 68862306a36Sopenharmony_ci unsigned int started; 68962306a36Sopenharmony_ci unsigned int max_speed_mode; 69062306a36Sopenharmony_ci unsigned int rx_fifo_size; 69162306a36Sopenharmony_ci unsigned int tx_fifo_size; 69262306a36Sopenharmony_ci 69362306a36Sopenharmony_ci struct xgbe_i2c_op_state op_state; 69462306a36Sopenharmony_ci}; 69562306a36Sopenharmony_ci 69662306a36Sopenharmony_cistruct xgbe_mmc_stats { 69762306a36Sopenharmony_ci /* Tx Stats */ 69862306a36Sopenharmony_ci u64 txoctetcount_gb; 69962306a36Sopenharmony_ci u64 txframecount_gb; 70062306a36Sopenharmony_ci u64 txbroadcastframes_g; 70162306a36Sopenharmony_ci u64 txmulticastframes_g; 70262306a36Sopenharmony_ci u64 tx64octets_gb; 70362306a36Sopenharmony_ci u64 tx65to127octets_gb; 70462306a36Sopenharmony_ci u64 tx128to255octets_gb; 70562306a36Sopenharmony_ci u64 tx256to511octets_gb; 70662306a36Sopenharmony_ci u64 tx512to1023octets_gb; 70762306a36Sopenharmony_ci u64 tx1024tomaxoctets_gb; 70862306a36Sopenharmony_ci u64 txunicastframes_gb; 70962306a36Sopenharmony_ci u64 txmulticastframes_gb; 71062306a36Sopenharmony_ci u64 txbroadcastframes_gb; 71162306a36Sopenharmony_ci u64 txunderflowerror; 71262306a36Sopenharmony_ci u64 txoctetcount_g; 71362306a36Sopenharmony_ci u64 txframecount_g; 71462306a36Sopenharmony_ci u64 txpauseframes; 71562306a36Sopenharmony_ci u64 txvlanframes_g; 71662306a36Sopenharmony_ci 71762306a36Sopenharmony_ci /* Rx Stats */ 71862306a36Sopenharmony_ci u64 rxframecount_gb; 71962306a36Sopenharmony_ci u64 rxoctetcount_gb; 72062306a36Sopenharmony_ci u64 rxoctetcount_g; 72162306a36Sopenharmony_ci u64 rxbroadcastframes_g; 72262306a36Sopenharmony_ci u64 rxmulticastframes_g; 72362306a36Sopenharmony_ci u64 rxcrcerror; 72462306a36Sopenharmony_ci u64 rxrunterror; 72562306a36Sopenharmony_ci u64 rxjabbererror; 72662306a36Sopenharmony_ci u64 rxundersize_g; 72762306a36Sopenharmony_ci u64 rxoversize_g; 72862306a36Sopenharmony_ci u64 rx64octets_gb; 72962306a36Sopenharmony_ci u64 rx65to127octets_gb; 73062306a36Sopenharmony_ci u64 rx128to255octets_gb; 73162306a36Sopenharmony_ci u64 rx256to511octets_gb; 73262306a36Sopenharmony_ci u64 rx512to1023octets_gb; 73362306a36Sopenharmony_ci u64 rx1024tomaxoctets_gb; 73462306a36Sopenharmony_ci u64 rxunicastframes_g; 73562306a36Sopenharmony_ci u64 rxlengtherror; 73662306a36Sopenharmony_ci u64 rxoutofrangetype; 73762306a36Sopenharmony_ci u64 rxpauseframes; 73862306a36Sopenharmony_ci u64 rxfifooverflow; 73962306a36Sopenharmony_ci u64 rxvlanframes_gb; 74062306a36Sopenharmony_ci u64 rxwatchdogerror; 74162306a36Sopenharmony_ci}; 74262306a36Sopenharmony_ci 74362306a36Sopenharmony_cistruct xgbe_ext_stats { 74462306a36Sopenharmony_ci u64 tx_tso_packets; 74562306a36Sopenharmony_ci u64 rx_split_header_packets; 74662306a36Sopenharmony_ci u64 rx_buffer_unavailable; 74762306a36Sopenharmony_ci 74862306a36Sopenharmony_ci u64 txq_packets[XGBE_MAX_DMA_CHANNELS]; 74962306a36Sopenharmony_ci u64 txq_bytes[XGBE_MAX_DMA_CHANNELS]; 75062306a36Sopenharmony_ci u64 rxq_packets[XGBE_MAX_DMA_CHANNELS]; 75162306a36Sopenharmony_ci u64 rxq_bytes[XGBE_MAX_DMA_CHANNELS]; 75262306a36Sopenharmony_ci 75362306a36Sopenharmony_ci u64 tx_vxlan_packets; 75462306a36Sopenharmony_ci u64 rx_vxlan_packets; 75562306a36Sopenharmony_ci u64 rx_csum_errors; 75662306a36Sopenharmony_ci u64 rx_vxlan_csum_errors; 75762306a36Sopenharmony_ci}; 75862306a36Sopenharmony_ci 75962306a36Sopenharmony_cistruct xgbe_hw_if { 76062306a36Sopenharmony_ci int (*tx_complete)(struct xgbe_ring_desc *); 76162306a36Sopenharmony_ci 76262306a36Sopenharmony_ci int (*set_mac_address)(struct xgbe_prv_data *, const u8 *addr); 76362306a36Sopenharmony_ci int (*config_rx_mode)(struct xgbe_prv_data *); 76462306a36Sopenharmony_ci 76562306a36Sopenharmony_ci int (*enable_rx_csum)(struct xgbe_prv_data *); 76662306a36Sopenharmony_ci int (*disable_rx_csum)(struct xgbe_prv_data *); 76762306a36Sopenharmony_ci 76862306a36Sopenharmony_ci int (*enable_rx_vlan_stripping)(struct xgbe_prv_data *); 76962306a36Sopenharmony_ci int (*disable_rx_vlan_stripping)(struct xgbe_prv_data *); 77062306a36Sopenharmony_ci int (*enable_rx_vlan_filtering)(struct xgbe_prv_data *); 77162306a36Sopenharmony_ci int (*disable_rx_vlan_filtering)(struct xgbe_prv_data *); 77262306a36Sopenharmony_ci int (*update_vlan_hash_table)(struct xgbe_prv_data *); 77362306a36Sopenharmony_ci 77462306a36Sopenharmony_ci int (*read_mmd_regs)(struct xgbe_prv_data *, int, int); 77562306a36Sopenharmony_ci void (*write_mmd_regs)(struct xgbe_prv_data *, int, int, int); 77662306a36Sopenharmony_ci int (*set_speed)(struct xgbe_prv_data *, int); 77762306a36Sopenharmony_ci 77862306a36Sopenharmony_ci int (*set_ext_mii_mode)(struct xgbe_prv_data *, unsigned int, 77962306a36Sopenharmony_ci enum xgbe_mdio_mode); 78062306a36Sopenharmony_ci int (*read_ext_mii_regs_c22)(struct xgbe_prv_data *, int, int); 78162306a36Sopenharmony_ci int (*write_ext_mii_regs_c22)(struct xgbe_prv_data *, int, int, u16); 78262306a36Sopenharmony_ci int (*read_ext_mii_regs_c45)(struct xgbe_prv_data *, int, int, int); 78362306a36Sopenharmony_ci int (*write_ext_mii_regs_c45)(struct xgbe_prv_data *, int, int, int, 78462306a36Sopenharmony_ci u16); 78562306a36Sopenharmony_ci 78662306a36Sopenharmony_ci int (*set_gpio)(struct xgbe_prv_data *, unsigned int); 78762306a36Sopenharmony_ci int (*clr_gpio)(struct xgbe_prv_data *, unsigned int); 78862306a36Sopenharmony_ci 78962306a36Sopenharmony_ci void (*enable_tx)(struct xgbe_prv_data *); 79062306a36Sopenharmony_ci void (*disable_tx)(struct xgbe_prv_data *); 79162306a36Sopenharmony_ci void (*enable_rx)(struct xgbe_prv_data *); 79262306a36Sopenharmony_ci void (*disable_rx)(struct xgbe_prv_data *); 79362306a36Sopenharmony_ci 79462306a36Sopenharmony_ci void (*powerup_tx)(struct xgbe_prv_data *); 79562306a36Sopenharmony_ci void (*powerdown_tx)(struct xgbe_prv_data *); 79662306a36Sopenharmony_ci void (*powerup_rx)(struct xgbe_prv_data *); 79762306a36Sopenharmony_ci void (*powerdown_rx)(struct xgbe_prv_data *); 79862306a36Sopenharmony_ci 79962306a36Sopenharmony_ci int (*init)(struct xgbe_prv_data *); 80062306a36Sopenharmony_ci int (*exit)(struct xgbe_prv_data *); 80162306a36Sopenharmony_ci 80262306a36Sopenharmony_ci int (*enable_int)(struct xgbe_channel *, enum xgbe_int); 80362306a36Sopenharmony_ci int (*disable_int)(struct xgbe_channel *, enum xgbe_int); 80462306a36Sopenharmony_ci void (*dev_xmit)(struct xgbe_channel *); 80562306a36Sopenharmony_ci int (*dev_read)(struct xgbe_channel *); 80662306a36Sopenharmony_ci void (*tx_desc_init)(struct xgbe_channel *); 80762306a36Sopenharmony_ci void (*rx_desc_init)(struct xgbe_channel *); 80862306a36Sopenharmony_ci void (*tx_desc_reset)(struct xgbe_ring_data *); 80962306a36Sopenharmony_ci void (*rx_desc_reset)(struct xgbe_prv_data *, struct xgbe_ring_data *, 81062306a36Sopenharmony_ci unsigned int); 81162306a36Sopenharmony_ci int (*is_last_desc)(struct xgbe_ring_desc *); 81262306a36Sopenharmony_ci int (*is_context_desc)(struct xgbe_ring_desc *); 81362306a36Sopenharmony_ci void (*tx_start_xmit)(struct xgbe_channel *, struct xgbe_ring *); 81462306a36Sopenharmony_ci 81562306a36Sopenharmony_ci /* For FLOW ctrl */ 81662306a36Sopenharmony_ci int (*config_tx_flow_control)(struct xgbe_prv_data *); 81762306a36Sopenharmony_ci int (*config_rx_flow_control)(struct xgbe_prv_data *); 81862306a36Sopenharmony_ci 81962306a36Sopenharmony_ci /* For RX coalescing */ 82062306a36Sopenharmony_ci int (*config_rx_coalesce)(struct xgbe_prv_data *); 82162306a36Sopenharmony_ci int (*config_tx_coalesce)(struct xgbe_prv_data *); 82262306a36Sopenharmony_ci unsigned int (*usec_to_riwt)(struct xgbe_prv_data *, unsigned int); 82362306a36Sopenharmony_ci unsigned int (*riwt_to_usec)(struct xgbe_prv_data *, unsigned int); 82462306a36Sopenharmony_ci 82562306a36Sopenharmony_ci /* For RX and TX threshold config */ 82662306a36Sopenharmony_ci int (*config_rx_threshold)(struct xgbe_prv_data *, unsigned int); 82762306a36Sopenharmony_ci int (*config_tx_threshold)(struct xgbe_prv_data *, unsigned int); 82862306a36Sopenharmony_ci 82962306a36Sopenharmony_ci /* For RX and TX Store and Forward Mode config */ 83062306a36Sopenharmony_ci int (*config_rsf_mode)(struct xgbe_prv_data *, unsigned int); 83162306a36Sopenharmony_ci int (*config_tsf_mode)(struct xgbe_prv_data *, unsigned int); 83262306a36Sopenharmony_ci 83362306a36Sopenharmony_ci /* For TX DMA Operate on Second Frame config */ 83462306a36Sopenharmony_ci int (*config_osp_mode)(struct xgbe_prv_data *); 83562306a36Sopenharmony_ci 83662306a36Sopenharmony_ci /* For MMC statistics */ 83762306a36Sopenharmony_ci void (*rx_mmc_int)(struct xgbe_prv_data *); 83862306a36Sopenharmony_ci void (*tx_mmc_int)(struct xgbe_prv_data *); 83962306a36Sopenharmony_ci void (*read_mmc_stats)(struct xgbe_prv_data *); 84062306a36Sopenharmony_ci 84162306a36Sopenharmony_ci /* For Timestamp config */ 84262306a36Sopenharmony_ci int (*config_tstamp)(struct xgbe_prv_data *, unsigned int); 84362306a36Sopenharmony_ci void (*update_tstamp_addend)(struct xgbe_prv_data *, unsigned int); 84462306a36Sopenharmony_ci void (*set_tstamp_time)(struct xgbe_prv_data *, unsigned int sec, 84562306a36Sopenharmony_ci unsigned int nsec); 84662306a36Sopenharmony_ci u64 (*get_tstamp_time)(struct xgbe_prv_data *); 84762306a36Sopenharmony_ci u64 (*get_tx_tstamp)(struct xgbe_prv_data *); 84862306a36Sopenharmony_ci 84962306a36Sopenharmony_ci /* For Data Center Bridging config */ 85062306a36Sopenharmony_ci void (*config_tc)(struct xgbe_prv_data *); 85162306a36Sopenharmony_ci void (*config_dcb_tc)(struct xgbe_prv_data *); 85262306a36Sopenharmony_ci void (*config_dcb_pfc)(struct xgbe_prv_data *); 85362306a36Sopenharmony_ci 85462306a36Sopenharmony_ci /* For Receive Side Scaling */ 85562306a36Sopenharmony_ci int (*enable_rss)(struct xgbe_prv_data *); 85662306a36Sopenharmony_ci int (*disable_rss)(struct xgbe_prv_data *); 85762306a36Sopenharmony_ci int (*set_rss_hash_key)(struct xgbe_prv_data *, const u8 *); 85862306a36Sopenharmony_ci int (*set_rss_lookup_table)(struct xgbe_prv_data *, const u32 *); 85962306a36Sopenharmony_ci 86062306a36Sopenharmony_ci /* For ECC */ 86162306a36Sopenharmony_ci void (*disable_ecc_ded)(struct xgbe_prv_data *); 86262306a36Sopenharmony_ci void (*disable_ecc_sec)(struct xgbe_prv_data *, enum xgbe_ecc_sec); 86362306a36Sopenharmony_ci 86462306a36Sopenharmony_ci /* For VXLAN */ 86562306a36Sopenharmony_ci void (*enable_vxlan)(struct xgbe_prv_data *); 86662306a36Sopenharmony_ci void (*disable_vxlan)(struct xgbe_prv_data *); 86762306a36Sopenharmony_ci void (*set_vxlan_id)(struct xgbe_prv_data *); 86862306a36Sopenharmony_ci}; 86962306a36Sopenharmony_ci 87062306a36Sopenharmony_ci/* This structure represents implementation specific routines for an 87162306a36Sopenharmony_ci * implementation of a PHY. All routines are required unless noted below. 87262306a36Sopenharmony_ci * Optional routines: 87362306a36Sopenharmony_ci * an_pre, an_post 87462306a36Sopenharmony_ci * kr_training_pre, kr_training_post 87562306a36Sopenharmony_ci * module_info, module_eeprom 87662306a36Sopenharmony_ci */ 87762306a36Sopenharmony_cistruct xgbe_phy_impl_if { 87862306a36Sopenharmony_ci /* Perform Setup/teardown actions */ 87962306a36Sopenharmony_ci int (*init)(struct xgbe_prv_data *); 88062306a36Sopenharmony_ci void (*exit)(struct xgbe_prv_data *); 88162306a36Sopenharmony_ci 88262306a36Sopenharmony_ci /* Perform start/stop specific actions */ 88362306a36Sopenharmony_ci int (*reset)(struct xgbe_prv_data *); 88462306a36Sopenharmony_ci int (*start)(struct xgbe_prv_data *); 88562306a36Sopenharmony_ci void (*stop)(struct xgbe_prv_data *); 88662306a36Sopenharmony_ci 88762306a36Sopenharmony_ci /* Return the link status */ 88862306a36Sopenharmony_ci int (*link_status)(struct xgbe_prv_data *, int *); 88962306a36Sopenharmony_ci 89062306a36Sopenharmony_ci /* Indicate if a particular speed is valid */ 89162306a36Sopenharmony_ci bool (*valid_speed)(struct xgbe_prv_data *, int); 89262306a36Sopenharmony_ci 89362306a36Sopenharmony_ci /* Check if the specified mode can/should be used */ 89462306a36Sopenharmony_ci bool (*use_mode)(struct xgbe_prv_data *, enum xgbe_mode); 89562306a36Sopenharmony_ci /* Switch the PHY into various modes */ 89662306a36Sopenharmony_ci void (*set_mode)(struct xgbe_prv_data *, enum xgbe_mode); 89762306a36Sopenharmony_ci /* Retrieve mode needed for a specific speed */ 89862306a36Sopenharmony_ci enum xgbe_mode (*get_mode)(struct xgbe_prv_data *, int); 89962306a36Sopenharmony_ci /* Retrieve new/next mode when trying to auto-negotiate */ 90062306a36Sopenharmony_ci enum xgbe_mode (*switch_mode)(struct xgbe_prv_data *); 90162306a36Sopenharmony_ci /* Retrieve current mode */ 90262306a36Sopenharmony_ci enum xgbe_mode (*cur_mode)(struct xgbe_prv_data *); 90362306a36Sopenharmony_ci 90462306a36Sopenharmony_ci /* Retrieve current auto-negotiation mode */ 90562306a36Sopenharmony_ci enum xgbe_an_mode (*an_mode)(struct xgbe_prv_data *); 90662306a36Sopenharmony_ci 90762306a36Sopenharmony_ci /* Configure auto-negotiation settings */ 90862306a36Sopenharmony_ci int (*an_config)(struct xgbe_prv_data *); 90962306a36Sopenharmony_ci 91062306a36Sopenharmony_ci /* Set/override auto-negotiation advertisement settings */ 91162306a36Sopenharmony_ci void (*an_advertising)(struct xgbe_prv_data *, 91262306a36Sopenharmony_ci struct ethtool_link_ksettings *); 91362306a36Sopenharmony_ci 91462306a36Sopenharmony_ci /* Process results of auto-negotiation */ 91562306a36Sopenharmony_ci enum xgbe_mode (*an_outcome)(struct xgbe_prv_data *); 91662306a36Sopenharmony_ci 91762306a36Sopenharmony_ci /* Pre/Post auto-negotiation support */ 91862306a36Sopenharmony_ci void (*an_pre)(struct xgbe_prv_data *); 91962306a36Sopenharmony_ci void (*an_post)(struct xgbe_prv_data *); 92062306a36Sopenharmony_ci 92162306a36Sopenharmony_ci /* Pre/Post KR training enablement support */ 92262306a36Sopenharmony_ci void (*kr_training_pre)(struct xgbe_prv_data *); 92362306a36Sopenharmony_ci void (*kr_training_post)(struct xgbe_prv_data *); 92462306a36Sopenharmony_ci 92562306a36Sopenharmony_ci /* SFP module related info */ 92662306a36Sopenharmony_ci int (*module_info)(struct xgbe_prv_data *pdata, 92762306a36Sopenharmony_ci struct ethtool_modinfo *modinfo); 92862306a36Sopenharmony_ci int (*module_eeprom)(struct xgbe_prv_data *pdata, 92962306a36Sopenharmony_ci struct ethtool_eeprom *eeprom, u8 *data); 93062306a36Sopenharmony_ci}; 93162306a36Sopenharmony_ci 93262306a36Sopenharmony_cistruct xgbe_phy_if { 93362306a36Sopenharmony_ci /* For PHY setup/teardown */ 93462306a36Sopenharmony_ci int (*phy_init)(struct xgbe_prv_data *); 93562306a36Sopenharmony_ci void (*phy_exit)(struct xgbe_prv_data *); 93662306a36Sopenharmony_ci 93762306a36Sopenharmony_ci /* For PHY support when setting device up/down */ 93862306a36Sopenharmony_ci int (*phy_reset)(struct xgbe_prv_data *); 93962306a36Sopenharmony_ci int (*phy_start)(struct xgbe_prv_data *); 94062306a36Sopenharmony_ci void (*phy_stop)(struct xgbe_prv_data *); 94162306a36Sopenharmony_ci 94262306a36Sopenharmony_ci /* For PHY support while device is up */ 94362306a36Sopenharmony_ci void (*phy_status)(struct xgbe_prv_data *); 94462306a36Sopenharmony_ci int (*phy_config_aneg)(struct xgbe_prv_data *); 94562306a36Sopenharmony_ci 94662306a36Sopenharmony_ci /* For PHY settings validation */ 94762306a36Sopenharmony_ci bool (*phy_valid_speed)(struct xgbe_prv_data *, int); 94862306a36Sopenharmony_ci 94962306a36Sopenharmony_ci /* For single interrupt support */ 95062306a36Sopenharmony_ci irqreturn_t (*an_isr)(struct xgbe_prv_data *); 95162306a36Sopenharmony_ci 95262306a36Sopenharmony_ci /* For ethtool PHY support */ 95362306a36Sopenharmony_ci int (*module_info)(struct xgbe_prv_data *pdata, 95462306a36Sopenharmony_ci struct ethtool_modinfo *modinfo); 95562306a36Sopenharmony_ci int (*module_eeprom)(struct xgbe_prv_data *pdata, 95662306a36Sopenharmony_ci struct ethtool_eeprom *eeprom, u8 *data); 95762306a36Sopenharmony_ci 95862306a36Sopenharmony_ci /* PHY implementation specific services */ 95962306a36Sopenharmony_ci struct xgbe_phy_impl_if phy_impl; 96062306a36Sopenharmony_ci}; 96162306a36Sopenharmony_ci 96262306a36Sopenharmony_cistruct xgbe_i2c_if { 96362306a36Sopenharmony_ci /* For initial I2C setup */ 96462306a36Sopenharmony_ci int (*i2c_init)(struct xgbe_prv_data *); 96562306a36Sopenharmony_ci 96662306a36Sopenharmony_ci /* For I2C support when setting device up/down */ 96762306a36Sopenharmony_ci int (*i2c_start)(struct xgbe_prv_data *); 96862306a36Sopenharmony_ci void (*i2c_stop)(struct xgbe_prv_data *); 96962306a36Sopenharmony_ci 97062306a36Sopenharmony_ci /* For performing I2C operations */ 97162306a36Sopenharmony_ci int (*i2c_xfer)(struct xgbe_prv_data *, struct xgbe_i2c_op *); 97262306a36Sopenharmony_ci 97362306a36Sopenharmony_ci /* For single interrupt support */ 97462306a36Sopenharmony_ci irqreturn_t (*i2c_isr)(struct xgbe_prv_data *); 97562306a36Sopenharmony_ci}; 97662306a36Sopenharmony_ci 97762306a36Sopenharmony_cistruct xgbe_desc_if { 97862306a36Sopenharmony_ci int (*alloc_ring_resources)(struct xgbe_prv_data *); 97962306a36Sopenharmony_ci void (*free_ring_resources)(struct xgbe_prv_data *); 98062306a36Sopenharmony_ci int (*map_tx_skb)(struct xgbe_channel *, struct sk_buff *); 98162306a36Sopenharmony_ci int (*map_rx_buffer)(struct xgbe_prv_data *, struct xgbe_ring *, 98262306a36Sopenharmony_ci struct xgbe_ring_data *); 98362306a36Sopenharmony_ci void (*unmap_rdata)(struct xgbe_prv_data *, struct xgbe_ring_data *); 98462306a36Sopenharmony_ci void (*wrapper_tx_desc_init)(struct xgbe_prv_data *); 98562306a36Sopenharmony_ci void (*wrapper_rx_desc_init)(struct xgbe_prv_data *); 98662306a36Sopenharmony_ci}; 98762306a36Sopenharmony_ci 98862306a36Sopenharmony_ci/* This structure contains flags that indicate what hardware features 98962306a36Sopenharmony_ci * or configurations are present in the device. 99062306a36Sopenharmony_ci */ 99162306a36Sopenharmony_cistruct xgbe_hw_features { 99262306a36Sopenharmony_ci /* HW Version */ 99362306a36Sopenharmony_ci unsigned int version; 99462306a36Sopenharmony_ci 99562306a36Sopenharmony_ci /* HW Feature Register0 */ 99662306a36Sopenharmony_ci unsigned int gmii; /* 1000 Mbps support */ 99762306a36Sopenharmony_ci unsigned int vlhash; /* VLAN Hash Filter */ 99862306a36Sopenharmony_ci unsigned int sma; /* SMA(MDIO) Interface */ 99962306a36Sopenharmony_ci unsigned int rwk; /* PMT remote wake-up packet */ 100062306a36Sopenharmony_ci unsigned int mgk; /* PMT magic packet */ 100162306a36Sopenharmony_ci unsigned int mmc; /* RMON module */ 100262306a36Sopenharmony_ci unsigned int aoe; /* ARP Offload */ 100362306a36Sopenharmony_ci unsigned int ts; /* IEEE 1588-2008 Advanced Timestamp */ 100462306a36Sopenharmony_ci unsigned int eee; /* Energy Efficient Ethernet */ 100562306a36Sopenharmony_ci unsigned int tx_coe; /* Tx Checksum Offload */ 100662306a36Sopenharmony_ci unsigned int rx_coe; /* Rx Checksum Offload */ 100762306a36Sopenharmony_ci unsigned int addn_mac; /* Additional MAC Addresses */ 100862306a36Sopenharmony_ci unsigned int ts_src; /* Timestamp Source */ 100962306a36Sopenharmony_ci unsigned int sa_vlan_ins; /* Source Address or VLAN Insertion */ 101062306a36Sopenharmony_ci unsigned int vxn; /* VXLAN/NVGRE */ 101162306a36Sopenharmony_ci 101262306a36Sopenharmony_ci /* HW Feature Register1 */ 101362306a36Sopenharmony_ci unsigned int rx_fifo_size; /* MTL Receive FIFO Size */ 101462306a36Sopenharmony_ci unsigned int tx_fifo_size; /* MTL Transmit FIFO Size */ 101562306a36Sopenharmony_ci unsigned int adv_ts_hi; /* Advance Timestamping High Word */ 101662306a36Sopenharmony_ci unsigned int dma_width; /* DMA width */ 101762306a36Sopenharmony_ci unsigned int dcb; /* DCB Feature */ 101862306a36Sopenharmony_ci unsigned int sph; /* Split Header Feature */ 101962306a36Sopenharmony_ci unsigned int tso; /* TCP Segmentation Offload */ 102062306a36Sopenharmony_ci unsigned int dma_debug; /* DMA Debug Registers */ 102162306a36Sopenharmony_ci unsigned int rss; /* Receive Side Scaling */ 102262306a36Sopenharmony_ci unsigned int tc_cnt; /* Number of Traffic Classes */ 102362306a36Sopenharmony_ci unsigned int hash_table_size; /* Hash Table Size */ 102462306a36Sopenharmony_ci unsigned int l3l4_filter_num; /* Number of L3-L4 Filters */ 102562306a36Sopenharmony_ci 102662306a36Sopenharmony_ci /* HW Feature Register2 */ 102762306a36Sopenharmony_ci unsigned int rx_q_cnt; /* Number of MTL Receive Queues */ 102862306a36Sopenharmony_ci unsigned int tx_q_cnt; /* Number of MTL Transmit Queues */ 102962306a36Sopenharmony_ci unsigned int rx_ch_cnt; /* Number of DMA Receive Channels */ 103062306a36Sopenharmony_ci unsigned int tx_ch_cnt; /* Number of DMA Transmit Channels */ 103162306a36Sopenharmony_ci unsigned int pps_out_num; /* Number of PPS outputs */ 103262306a36Sopenharmony_ci unsigned int aux_snap_num; /* Number of Aux snapshot inputs */ 103362306a36Sopenharmony_ci}; 103462306a36Sopenharmony_ci 103562306a36Sopenharmony_cistruct xgbe_version_data { 103662306a36Sopenharmony_ci void (*init_function_ptrs_phy_impl)(struct xgbe_phy_if *); 103762306a36Sopenharmony_ci enum xgbe_xpcs_access xpcs_access; 103862306a36Sopenharmony_ci unsigned int mmc_64bit; 103962306a36Sopenharmony_ci unsigned int tx_max_fifo_size; 104062306a36Sopenharmony_ci unsigned int rx_max_fifo_size; 104162306a36Sopenharmony_ci unsigned int tx_tstamp_workaround; 104262306a36Sopenharmony_ci unsigned int ecc_support; 104362306a36Sopenharmony_ci unsigned int i2c_support; 104462306a36Sopenharmony_ci unsigned int irq_reissue_support; 104562306a36Sopenharmony_ci unsigned int tx_desc_prefetch; 104662306a36Sopenharmony_ci unsigned int rx_desc_prefetch; 104762306a36Sopenharmony_ci unsigned int an_cdr_workaround; 104862306a36Sopenharmony_ci unsigned int enable_rrc; 104962306a36Sopenharmony_ci}; 105062306a36Sopenharmony_ci 105162306a36Sopenharmony_cistruct xgbe_prv_data { 105262306a36Sopenharmony_ci struct net_device *netdev; 105362306a36Sopenharmony_ci struct pci_dev *pcidev; 105462306a36Sopenharmony_ci struct platform_device *platdev; 105562306a36Sopenharmony_ci struct acpi_device *adev; 105662306a36Sopenharmony_ci struct device *dev; 105762306a36Sopenharmony_ci struct platform_device *phy_platdev; 105862306a36Sopenharmony_ci struct device *phy_dev; 105962306a36Sopenharmony_ci 106062306a36Sopenharmony_ci /* Version related data */ 106162306a36Sopenharmony_ci struct xgbe_version_data *vdata; 106262306a36Sopenharmony_ci 106362306a36Sopenharmony_ci /* ACPI or DT flag */ 106462306a36Sopenharmony_ci unsigned int use_acpi; 106562306a36Sopenharmony_ci 106662306a36Sopenharmony_ci /* XGMAC/XPCS related mmio registers */ 106762306a36Sopenharmony_ci void __iomem *xgmac_regs; /* XGMAC CSRs */ 106862306a36Sopenharmony_ci void __iomem *xpcs_regs; /* XPCS MMD registers */ 106962306a36Sopenharmony_ci void __iomem *rxtx_regs; /* SerDes Rx/Tx CSRs */ 107062306a36Sopenharmony_ci void __iomem *sir0_regs; /* SerDes integration registers (1/2) */ 107162306a36Sopenharmony_ci void __iomem *sir1_regs; /* SerDes integration registers (2/2) */ 107262306a36Sopenharmony_ci void __iomem *xprop_regs; /* XGBE property registers */ 107362306a36Sopenharmony_ci void __iomem *xi2c_regs; /* XGBE I2C CSRs */ 107462306a36Sopenharmony_ci 107562306a36Sopenharmony_ci /* Port property registers */ 107662306a36Sopenharmony_ci unsigned int pp0; 107762306a36Sopenharmony_ci unsigned int pp1; 107862306a36Sopenharmony_ci unsigned int pp2; 107962306a36Sopenharmony_ci unsigned int pp3; 108062306a36Sopenharmony_ci unsigned int pp4; 108162306a36Sopenharmony_ci 108262306a36Sopenharmony_ci /* Overall device lock */ 108362306a36Sopenharmony_ci spinlock_t lock; 108462306a36Sopenharmony_ci 108562306a36Sopenharmony_ci /* XPCS indirect addressing lock */ 108662306a36Sopenharmony_ci spinlock_t xpcs_lock; 108762306a36Sopenharmony_ci unsigned int xpcs_window_def_reg; 108862306a36Sopenharmony_ci unsigned int xpcs_window_sel_reg; 108962306a36Sopenharmony_ci unsigned int xpcs_window; 109062306a36Sopenharmony_ci unsigned int xpcs_window_size; 109162306a36Sopenharmony_ci unsigned int xpcs_window_mask; 109262306a36Sopenharmony_ci 109362306a36Sopenharmony_ci /* RSS addressing mutex */ 109462306a36Sopenharmony_ci struct mutex rss_mutex; 109562306a36Sopenharmony_ci 109662306a36Sopenharmony_ci /* Flags representing xgbe_state */ 109762306a36Sopenharmony_ci unsigned long dev_state; 109862306a36Sopenharmony_ci 109962306a36Sopenharmony_ci /* ECC support */ 110062306a36Sopenharmony_ci unsigned long tx_sec_period; 110162306a36Sopenharmony_ci unsigned long tx_ded_period; 110262306a36Sopenharmony_ci unsigned long rx_sec_period; 110362306a36Sopenharmony_ci unsigned long rx_ded_period; 110462306a36Sopenharmony_ci unsigned long desc_sec_period; 110562306a36Sopenharmony_ci unsigned long desc_ded_period; 110662306a36Sopenharmony_ci 110762306a36Sopenharmony_ci unsigned int tx_sec_count; 110862306a36Sopenharmony_ci unsigned int tx_ded_count; 110962306a36Sopenharmony_ci unsigned int rx_sec_count; 111062306a36Sopenharmony_ci unsigned int rx_ded_count; 111162306a36Sopenharmony_ci unsigned int desc_ded_count; 111262306a36Sopenharmony_ci unsigned int desc_sec_count; 111362306a36Sopenharmony_ci 111462306a36Sopenharmony_ci int dev_irq; 111562306a36Sopenharmony_ci int ecc_irq; 111662306a36Sopenharmony_ci int i2c_irq; 111762306a36Sopenharmony_ci int channel_irq[XGBE_MAX_DMA_CHANNELS]; 111862306a36Sopenharmony_ci 111962306a36Sopenharmony_ci unsigned int per_channel_irq; 112062306a36Sopenharmony_ci unsigned int irq_count; 112162306a36Sopenharmony_ci unsigned int channel_irq_count; 112262306a36Sopenharmony_ci unsigned int channel_irq_mode; 112362306a36Sopenharmony_ci 112462306a36Sopenharmony_ci char ecc_name[IFNAMSIZ + 32]; 112562306a36Sopenharmony_ci 112662306a36Sopenharmony_ci struct xgbe_hw_if hw_if; 112762306a36Sopenharmony_ci struct xgbe_phy_if phy_if; 112862306a36Sopenharmony_ci struct xgbe_desc_if desc_if; 112962306a36Sopenharmony_ci struct xgbe_i2c_if i2c_if; 113062306a36Sopenharmony_ci 113162306a36Sopenharmony_ci /* AXI DMA settings */ 113262306a36Sopenharmony_ci unsigned int coherent; 113362306a36Sopenharmony_ci unsigned int arcr; 113462306a36Sopenharmony_ci unsigned int awcr; 113562306a36Sopenharmony_ci unsigned int awarcr; 113662306a36Sopenharmony_ci 113762306a36Sopenharmony_ci /* Service routine support */ 113862306a36Sopenharmony_ci struct workqueue_struct *dev_workqueue; 113962306a36Sopenharmony_ci struct work_struct service_work; 114062306a36Sopenharmony_ci struct timer_list service_timer; 114162306a36Sopenharmony_ci 114262306a36Sopenharmony_ci /* Rings for Tx/Rx on a DMA channel */ 114362306a36Sopenharmony_ci struct xgbe_channel *channel[XGBE_MAX_DMA_CHANNELS]; 114462306a36Sopenharmony_ci unsigned int tx_max_channel_count; 114562306a36Sopenharmony_ci unsigned int rx_max_channel_count; 114662306a36Sopenharmony_ci unsigned int channel_count; 114762306a36Sopenharmony_ci unsigned int tx_ring_count; 114862306a36Sopenharmony_ci unsigned int tx_desc_count; 114962306a36Sopenharmony_ci unsigned int rx_ring_count; 115062306a36Sopenharmony_ci unsigned int rx_desc_count; 115162306a36Sopenharmony_ci 115262306a36Sopenharmony_ci unsigned int new_tx_ring_count; 115362306a36Sopenharmony_ci unsigned int new_rx_ring_count; 115462306a36Sopenharmony_ci 115562306a36Sopenharmony_ci unsigned int tx_max_q_count; 115662306a36Sopenharmony_ci unsigned int rx_max_q_count; 115762306a36Sopenharmony_ci unsigned int tx_q_count; 115862306a36Sopenharmony_ci unsigned int rx_q_count; 115962306a36Sopenharmony_ci 116062306a36Sopenharmony_ci /* Tx/Rx common settings */ 116162306a36Sopenharmony_ci unsigned int blen; 116262306a36Sopenharmony_ci unsigned int pbl; 116362306a36Sopenharmony_ci unsigned int aal; 116462306a36Sopenharmony_ci unsigned int rd_osr_limit; 116562306a36Sopenharmony_ci unsigned int wr_osr_limit; 116662306a36Sopenharmony_ci 116762306a36Sopenharmony_ci /* Tx settings */ 116862306a36Sopenharmony_ci unsigned int tx_sf_mode; 116962306a36Sopenharmony_ci unsigned int tx_threshold; 117062306a36Sopenharmony_ci unsigned int tx_osp_mode; 117162306a36Sopenharmony_ci unsigned int tx_max_fifo_size; 117262306a36Sopenharmony_ci 117362306a36Sopenharmony_ci /* Rx settings */ 117462306a36Sopenharmony_ci unsigned int rx_sf_mode; 117562306a36Sopenharmony_ci unsigned int rx_threshold; 117662306a36Sopenharmony_ci unsigned int rx_max_fifo_size; 117762306a36Sopenharmony_ci 117862306a36Sopenharmony_ci /* Tx coalescing settings */ 117962306a36Sopenharmony_ci unsigned int tx_usecs; 118062306a36Sopenharmony_ci unsigned int tx_frames; 118162306a36Sopenharmony_ci 118262306a36Sopenharmony_ci /* Rx coalescing settings */ 118362306a36Sopenharmony_ci unsigned int rx_riwt; 118462306a36Sopenharmony_ci unsigned int rx_usecs; 118562306a36Sopenharmony_ci unsigned int rx_frames; 118662306a36Sopenharmony_ci 118762306a36Sopenharmony_ci /* Current Rx buffer size */ 118862306a36Sopenharmony_ci unsigned int rx_buf_size; 118962306a36Sopenharmony_ci 119062306a36Sopenharmony_ci /* Flow control settings */ 119162306a36Sopenharmony_ci unsigned int pause_autoneg; 119262306a36Sopenharmony_ci unsigned int tx_pause; 119362306a36Sopenharmony_ci unsigned int rx_pause; 119462306a36Sopenharmony_ci unsigned int rx_rfa[XGBE_MAX_QUEUES]; 119562306a36Sopenharmony_ci unsigned int rx_rfd[XGBE_MAX_QUEUES]; 119662306a36Sopenharmony_ci 119762306a36Sopenharmony_ci /* Receive Side Scaling settings */ 119862306a36Sopenharmony_ci u8 rss_key[XGBE_RSS_HASH_KEY_SIZE]; 119962306a36Sopenharmony_ci u32 rss_table[XGBE_RSS_MAX_TABLE_SIZE]; 120062306a36Sopenharmony_ci u32 rss_options; 120162306a36Sopenharmony_ci 120262306a36Sopenharmony_ci /* VXLAN settings */ 120362306a36Sopenharmony_ci u16 vxlan_port; 120462306a36Sopenharmony_ci 120562306a36Sopenharmony_ci /* Netdev related settings */ 120662306a36Sopenharmony_ci unsigned char mac_addr[ETH_ALEN]; 120762306a36Sopenharmony_ci netdev_features_t netdev_features; 120862306a36Sopenharmony_ci struct napi_struct napi; 120962306a36Sopenharmony_ci struct xgbe_mmc_stats mmc_stats; 121062306a36Sopenharmony_ci struct xgbe_ext_stats ext_stats; 121162306a36Sopenharmony_ci 121262306a36Sopenharmony_ci /* Filtering support */ 121362306a36Sopenharmony_ci unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; 121462306a36Sopenharmony_ci 121562306a36Sopenharmony_ci /* Device clocks */ 121662306a36Sopenharmony_ci struct clk *sysclk; 121762306a36Sopenharmony_ci unsigned long sysclk_rate; 121862306a36Sopenharmony_ci struct clk *ptpclk; 121962306a36Sopenharmony_ci unsigned long ptpclk_rate; 122062306a36Sopenharmony_ci 122162306a36Sopenharmony_ci /* Timestamp support */ 122262306a36Sopenharmony_ci spinlock_t tstamp_lock; 122362306a36Sopenharmony_ci struct ptp_clock_info ptp_clock_info; 122462306a36Sopenharmony_ci struct ptp_clock *ptp_clock; 122562306a36Sopenharmony_ci struct hwtstamp_config tstamp_config; 122662306a36Sopenharmony_ci struct cyclecounter tstamp_cc; 122762306a36Sopenharmony_ci struct timecounter tstamp_tc; 122862306a36Sopenharmony_ci unsigned int tstamp_addend; 122962306a36Sopenharmony_ci struct work_struct tx_tstamp_work; 123062306a36Sopenharmony_ci struct sk_buff *tx_tstamp_skb; 123162306a36Sopenharmony_ci u64 tx_tstamp; 123262306a36Sopenharmony_ci 123362306a36Sopenharmony_ci /* DCB support */ 123462306a36Sopenharmony_ci struct ieee_ets *ets; 123562306a36Sopenharmony_ci struct ieee_pfc *pfc; 123662306a36Sopenharmony_ci unsigned int q2tc_map[XGBE_MAX_QUEUES]; 123762306a36Sopenharmony_ci unsigned int prio2q_map[IEEE_8021QAZ_MAX_TCS]; 123862306a36Sopenharmony_ci unsigned int pfcq[XGBE_MAX_QUEUES]; 123962306a36Sopenharmony_ci unsigned int pfc_rfa; 124062306a36Sopenharmony_ci u8 num_tcs; 124162306a36Sopenharmony_ci 124262306a36Sopenharmony_ci /* Hardware features of the device */ 124362306a36Sopenharmony_ci struct xgbe_hw_features hw_feat; 124462306a36Sopenharmony_ci 124562306a36Sopenharmony_ci /* Device work structures */ 124662306a36Sopenharmony_ci struct work_struct restart_work; 124762306a36Sopenharmony_ci struct work_struct stopdev_work; 124862306a36Sopenharmony_ci 124962306a36Sopenharmony_ci /* Keeps track of power mode */ 125062306a36Sopenharmony_ci unsigned int power_down; 125162306a36Sopenharmony_ci 125262306a36Sopenharmony_ci /* Network interface message level setting */ 125362306a36Sopenharmony_ci u32 msg_enable; 125462306a36Sopenharmony_ci 125562306a36Sopenharmony_ci /* Current PHY settings */ 125662306a36Sopenharmony_ci phy_interface_t phy_mode; 125762306a36Sopenharmony_ci int phy_link; 125862306a36Sopenharmony_ci int phy_speed; 125962306a36Sopenharmony_ci 126062306a36Sopenharmony_ci /* MDIO/PHY related settings */ 126162306a36Sopenharmony_ci unsigned int phy_started; 126262306a36Sopenharmony_ci void *phy_data; 126362306a36Sopenharmony_ci struct xgbe_phy phy; 126462306a36Sopenharmony_ci int mdio_mmd; 126562306a36Sopenharmony_ci unsigned long link_check; 126662306a36Sopenharmony_ci struct completion mdio_complete; 126762306a36Sopenharmony_ci 126862306a36Sopenharmony_ci unsigned int kr_redrv; 126962306a36Sopenharmony_ci 127062306a36Sopenharmony_ci char an_name[IFNAMSIZ + 32]; 127162306a36Sopenharmony_ci struct workqueue_struct *an_workqueue; 127262306a36Sopenharmony_ci 127362306a36Sopenharmony_ci int an_irq; 127462306a36Sopenharmony_ci struct work_struct an_irq_work; 127562306a36Sopenharmony_ci 127662306a36Sopenharmony_ci /* Auto-negotiation state machine support */ 127762306a36Sopenharmony_ci unsigned int an_int; 127862306a36Sopenharmony_ci unsigned int an_status; 127962306a36Sopenharmony_ci struct mutex an_mutex; 128062306a36Sopenharmony_ci enum xgbe_an an_result; 128162306a36Sopenharmony_ci enum xgbe_an an_state; 128262306a36Sopenharmony_ci enum xgbe_rx kr_state; 128362306a36Sopenharmony_ci enum xgbe_rx kx_state; 128462306a36Sopenharmony_ci struct work_struct an_work; 128562306a36Sopenharmony_ci unsigned int an_again; 128662306a36Sopenharmony_ci unsigned int an_supported; 128762306a36Sopenharmony_ci unsigned int parallel_detect; 128862306a36Sopenharmony_ci unsigned int fec_ability; 128962306a36Sopenharmony_ci unsigned long an_start; 129062306a36Sopenharmony_ci unsigned long kr_start_time; 129162306a36Sopenharmony_ci enum xgbe_an_mode an_mode; 129262306a36Sopenharmony_ci 129362306a36Sopenharmony_ci /* I2C support */ 129462306a36Sopenharmony_ci struct xgbe_i2c i2c; 129562306a36Sopenharmony_ci struct mutex i2c_mutex; 129662306a36Sopenharmony_ci struct completion i2c_complete; 129762306a36Sopenharmony_ci char i2c_name[IFNAMSIZ + 32]; 129862306a36Sopenharmony_ci 129962306a36Sopenharmony_ci unsigned int lpm_ctrl; /* CTRL1 for resume */ 130062306a36Sopenharmony_ci 130162306a36Sopenharmony_ci unsigned int isr_as_tasklet; 130262306a36Sopenharmony_ci struct tasklet_struct tasklet_dev; 130362306a36Sopenharmony_ci struct tasklet_struct tasklet_ecc; 130462306a36Sopenharmony_ci struct tasklet_struct tasklet_i2c; 130562306a36Sopenharmony_ci struct tasklet_struct tasklet_an; 130662306a36Sopenharmony_ci 130762306a36Sopenharmony_ci struct dentry *xgbe_debugfs; 130862306a36Sopenharmony_ci 130962306a36Sopenharmony_ci unsigned int debugfs_xgmac_reg; 131062306a36Sopenharmony_ci 131162306a36Sopenharmony_ci unsigned int debugfs_xpcs_mmd; 131262306a36Sopenharmony_ci unsigned int debugfs_xpcs_reg; 131362306a36Sopenharmony_ci 131462306a36Sopenharmony_ci unsigned int debugfs_xprop_reg; 131562306a36Sopenharmony_ci 131662306a36Sopenharmony_ci unsigned int debugfs_xi2c_reg; 131762306a36Sopenharmony_ci 131862306a36Sopenharmony_ci bool debugfs_an_cdr_workaround; 131962306a36Sopenharmony_ci bool debugfs_an_cdr_track_early; 132062306a36Sopenharmony_ci bool en_rx_adap; 132162306a36Sopenharmony_ci int rx_adapt_retries; 132262306a36Sopenharmony_ci bool rx_adapt_done; 132362306a36Sopenharmony_ci bool mode_set; 132462306a36Sopenharmony_ci}; 132562306a36Sopenharmony_ci 132662306a36Sopenharmony_ci/* Function prototypes*/ 132762306a36Sopenharmony_cistruct xgbe_prv_data *xgbe_alloc_pdata(struct device *); 132862306a36Sopenharmony_civoid xgbe_free_pdata(struct xgbe_prv_data *); 132962306a36Sopenharmony_civoid xgbe_set_counts(struct xgbe_prv_data *); 133062306a36Sopenharmony_ciint xgbe_config_netdev(struct xgbe_prv_data *); 133162306a36Sopenharmony_civoid xgbe_deconfig_netdev(struct xgbe_prv_data *); 133262306a36Sopenharmony_ci 133362306a36Sopenharmony_ciint xgbe_platform_init(void); 133462306a36Sopenharmony_civoid xgbe_platform_exit(void); 133562306a36Sopenharmony_ci#ifdef CONFIG_PCI 133662306a36Sopenharmony_ciint xgbe_pci_init(void); 133762306a36Sopenharmony_civoid xgbe_pci_exit(void); 133862306a36Sopenharmony_ci#else 133962306a36Sopenharmony_cistatic inline int xgbe_pci_init(void) { return 0; } 134062306a36Sopenharmony_cistatic inline void xgbe_pci_exit(void) { } 134162306a36Sopenharmony_ci#endif 134262306a36Sopenharmony_ci 134362306a36Sopenharmony_civoid xgbe_init_function_ptrs_dev(struct xgbe_hw_if *); 134462306a36Sopenharmony_civoid xgbe_init_function_ptrs_phy(struct xgbe_phy_if *); 134562306a36Sopenharmony_civoid xgbe_init_function_ptrs_phy_v1(struct xgbe_phy_if *); 134662306a36Sopenharmony_civoid xgbe_init_function_ptrs_phy_v2(struct xgbe_phy_if *); 134762306a36Sopenharmony_civoid xgbe_init_function_ptrs_desc(struct xgbe_desc_if *); 134862306a36Sopenharmony_civoid xgbe_init_function_ptrs_i2c(struct xgbe_i2c_if *); 134962306a36Sopenharmony_ciconst struct net_device_ops *xgbe_get_netdev_ops(void); 135062306a36Sopenharmony_ciconst struct ethtool_ops *xgbe_get_ethtool_ops(void); 135162306a36Sopenharmony_ciconst struct udp_tunnel_nic_info *xgbe_get_udp_tunnel_info(void); 135262306a36Sopenharmony_ci 135362306a36Sopenharmony_ci#ifdef CONFIG_AMD_XGBE_DCB 135462306a36Sopenharmony_ciconst struct dcbnl_rtnl_ops *xgbe_get_dcbnl_ops(void); 135562306a36Sopenharmony_ci#endif 135662306a36Sopenharmony_ci 135762306a36Sopenharmony_civoid xgbe_ptp_register(struct xgbe_prv_data *); 135862306a36Sopenharmony_civoid xgbe_ptp_unregister(struct xgbe_prv_data *); 135962306a36Sopenharmony_civoid xgbe_dump_tx_desc(struct xgbe_prv_data *, struct xgbe_ring *, 136062306a36Sopenharmony_ci unsigned int, unsigned int, unsigned int); 136162306a36Sopenharmony_civoid xgbe_dump_rx_desc(struct xgbe_prv_data *, struct xgbe_ring *, 136262306a36Sopenharmony_ci unsigned int); 136362306a36Sopenharmony_civoid xgbe_print_pkt(struct net_device *, struct sk_buff *, bool); 136462306a36Sopenharmony_civoid xgbe_get_all_hw_features(struct xgbe_prv_data *); 136562306a36Sopenharmony_ciint xgbe_powerup(struct net_device *, unsigned int); 136662306a36Sopenharmony_ciint xgbe_powerdown(struct net_device *, unsigned int); 136762306a36Sopenharmony_civoid xgbe_init_rx_coalesce(struct xgbe_prv_data *); 136862306a36Sopenharmony_civoid xgbe_init_tx_coalesce(struct xgbe_prv_data *); 136962306a36Sopenharmony_civoid xgbe_restart_dev(struct xgbe_prv_data *pdata); 137062306a36Sopenharmony_civoid xgbe_full_restart_dev(struct xgbe_prv_data *pdata); 137162306a36Sopenharmony_ci 137262306a36Sopenharmony_ci#ifdef CONFIG_DEBUG_FS 137362306a36Sopenharmony_civoid xgbe_debugfs_init(struct xgbe_prv_data *); 137462306a36Sopenharmony_civoid xgbe_debugfs_exit(struct xgbe_prv_data *); 137562306a36Sopenharmony_civoid xgbe_debugfs_rename(struct xgbe_prv_data *pdata); 137662306a36Sopenharmony_ci#else 137762306a36Sopenharmony_cistatic inline void xgbe_debugfs_init(struct xgbe_prv_data *pdata) {} 137862306a36Sopenharmony_cistatic inline void xgbe_debugfs_exit(struct xgbe_prv_data *pdata) {} 137962306a36Sopenharmony_cistatic inline void xgbe_debugfs_rename(struct xgbe_prv_data *pdata) {} 138062306a36Sopenharmony_ci#endif /* CONFIG_DEBUG_FS */ 138162306a36Sopenharmony_ci 138262306a36Sopenharmony_ci/* NOTE: Uncomment for function trace log messages in KERNEL LOG */ 138362306a36Sopenharmony_ci#if 0 138462306a36Sopenharmony_ci#define YDEBUG 138562306a36Sopenharmony_ci#define YDEBUG_MDIO 138662306a36Sopenharmony_ci#endif 138762306a36Sopenharmony_ci 138862306a36Sopenharmony_ci/* For debug prints */ 138962306a36Sopenharmony_ci#ifdef YDEBUG 139062306a36Sopenharmony_ci#define DBGPR(x...) pr_alert(x) 139162306a36Sopenharmony_ci#else 139262306a36Sopenharmony_ci#define DBGPR(x...) do { } while (0) 139362306a36Sopenharmony_ci#endif 139462306a36Sopenharmony_ci 139562306a36Sopenharmony_ci#ifdef YDEBUG_MDIO 139662306a36Sopenharmony_ci#define DBGPR_MDIO(x...) pr_alert(x) 139762306a36Sopenharmony_ci#else 139862306a36Sopenharmony_ci#define DBGPR_MDIO(x...) do { } while (0) 139962306a36Sopenharmony_ci#endif 140062306a36Sopenharmony_ci 140162306a36Sopenharmony_ci#endif 1402