xgbe.h revision b85e4d8960f10e4b28613a3e7b76f8889a2089e3
1c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* 2c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * AMD 10Gb Ethernet driver 3c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * 4c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * This file is available to you under your choice of the following two 5c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * licenses: 6c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * 7c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * License 1: GPLv2 8c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * 9c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * Copyright (c) 2014 Advanced Micro Devices, Inc. 10c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * 11c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * This file is free software; you may copy, redistribute and/or modify 12c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * it under the terms of the GNU General Public License as published by 13c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * the Free Software Foundation, either version 2 of the License, or (at 14c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * your option) any later version. 15c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * 16c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * This file is distributed in the hope that it will be useful, but 17c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * WITHOUT ANY WARRANTY; without even the implied warranty of 18c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * General Public License for more details. 20c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * 21c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * You should have received a copy of the GNU General Public License 22c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * along with this program. If not, see <http://www.gnu.org/licenses/>. 23c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * 24c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * This file incorporates work covered by the following copyright and 25c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * permission notice: 26c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * The Synopsys DWC ETHER XGMAC Software Driver and documentation 27c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * (hereinafter "Software") is an unsupported proprietary work of Synopsys, 28c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * Inc. unless otherwise expressly agreed to in writing between Synopsys 29c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * and you. 30c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * 31c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * The Software IS NOT an item of Licensed Software or Licensed Product 32c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * under any End User Software License Agreement or Agreement for Licensed 33c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * Product with Synopsys or any supplement thereto. Permission is hereby 34c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * granted, free of charge, to any person obtaining a copy of this software 35c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * annotated with this license and the Software, to deal in the Software 36c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * without restriction, including without limitation the rights to use, 37c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * copy, modify, merge, publish, distribute, sublicense, and/or sell copies 38c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * of the Software, and to permit persons to whom the Software is furnished 39c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * to do so, subject to the following conditions: 40c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * 41c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * The above copyright notice and this permission notice shall be included 42c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * in all copies or substantial portions of the Software. 43c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * 44c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" 45c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 46c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 47c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS 48c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 49c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 50c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 51c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 52c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 53c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 54c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * THE POSSIBILITY OF SUCH DAMAGE. 55c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * 56c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * 57c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * License 2: Modified BSD 58c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * 59c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * Copyright (c) 2014 Advanced Micro Devices, Inc. 60c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * All rights reserved. 61c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * 62c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * Redistribution and use in source and binary forms, with or without 63c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * modification, are permitted provided that the following conditions are met: 64c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * * Redistributions of source code must retain the above copyright 65c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * notice, this list of conditions and the following disclaimer. 66c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * * Redistributions in binary form must reproduce the above copyright 67c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * notice, this list of conditions and the following disclaimer in the 68c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * documentation and/or other materials provided with the distribution. 69c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * * Neither the name of Advanced Micro Devices, Inc. nor the 70c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * names of its contributors may be used to endorse or promote products 71c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * derived from this software without specific prior written permission. 72c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * 73c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 74c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 75c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 76c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY 77c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 78c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 79c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 80c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 81c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 82c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 83c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * 84c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * This file incorporates work covered by the following copyright and 85c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * permission notice: 86c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * The Synopsys DWC ETHER XGMAC Software Driver and documentation 87c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * (hereinafter "Software") is an unsupported proprietary work of Synopsys, 88c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * Inc. unless otherwise expressly agreed to in writing between Synopsys 89c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * and you. 90c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * 91c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * The Software IS NOT an item of Licensed Software or Licensed Product 92c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * under any End User Software License Agreement or Agreement for Licensed 93c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * Product with Synopsys or any supplement thereto. Permission is hereby 94c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * granted, free of charge, to any person obtaining a copy of this software 95c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * annotated with this license and the Software, to deal in the Software 96c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * without restriction, including without limitation the rights to use, 97c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * copy, modify, merge, publish, distribute, sublicense, and/or sell copies 98c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * of the Software, and to permit persons to whom the Software is furnished 99c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * to do so, subject to the following conditions: 100c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * 101c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * The above copyright notice and this permission notice shall be included 102c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * in all copies or substantial portions of the Software. 103c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * 104c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" 105c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 106c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 107c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS 108c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 109c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 110c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 111c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 112c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 113c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 114c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * THE POSSIBILITY OF SUCH DAMAGE. 115c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas */ 116c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 117c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#ifndef __XGBE_H__ 118c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define __XGBE_H__ 119c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 120c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#include <linux/dma-mapping.h> 121c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#include <linux/netdevice.h> 122c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#include <linux/workqueue.h> 123c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#include <linux/phy.h> 124801c62d945c6121c0262924732e430f0553bfb37Lendacky, Thomas#include <linux/if_vlan.h> 125801c62d945c6121c0262924732e430f0553bfb37Lendacky, Thomas#include <linux/bitops.h> 126c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 127c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 128c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGBE_DRV_NAME "amd-xgbe" 129c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGBE_DRV_VERSION "1.0.0-a" 130c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGBE_DRV_DESC "AMD 10 Gigabit Ethernet Driver" 131c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 132c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* Descriptor related defines */ 133d0a8ba6cba0a05ce79df100a3d99502b94117d88Lendacky, Thomas#define XGBE_TX_DESC_CNT 512 134d0a8ba6cba0a05ce79df100a3d99502b94117d88Lendacky, Thomas#define XGBE_TX_DESC_MIN_FREE (XGBE_TX_DESC_CNT >> 3) 135d0a8ba6cba0a05ce79df100a3d99502b94117d88Lendacky, Thomas#define XGBE_TX_DESC_MAX_PROC (XGBE_TX_DESC_CNT >> 1) 136d0a8ba6cba0a05ce79df100a3d99502b94117d88Lendacky, Thomas#define XGBE_RX_DESC_CNT 512 137c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 138d0a8ba6cba0a05ce79df100a3d99502b94117d88Lendacky, Thomas#define XGBE_TX_MAX_BUF_SIZE (0x3fff & ~(64 - 1)) 139c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 140d0a8ba6cba0a05ce79df100a3d99502b94117d88Lendacky, Thomas#define XGBE_RX_MIN_BUF_SIZE (ETH_FRAME_LEN + ETH_FCS_LEN + VLAN_HLEN) 141d0a8ba6cba0a05ce79df100a3d99502b94117d88Lendacky, Thomas#define XGBE_RX_BUF_ALIGN 64 142c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 143d5c4858237fe43c30714f4447ccec87d5fb3fcdeLendacky, Thomas#define XGBE_MAX_DMA_CHANNELS 16 144d0a8ba6cba0a05ce79df100a3d99502b94117d88Lendacky, Thomas 145d0a8ba6cba0a05ce79df100a3d99502b94117d88Lendacky, Thomas/* DMA cache settings - Outer sharable, write-back, write-allocate */ 146d0a8ba6cba0a05ce79df100a3d99502b94117d88Lendacky, Thomas#define XGBE_DMA_ARDOMAIN 0x2 147d0a8ba6cba0a05ce79df100a3d99502b94117d88Lendacky, Thomas#define XGBE_DMA_ARCACHE 0xb 148d0a8ba6cba0a05ce79df100a3d99502b94117d88Lendacky, Thomas#define XGBE_DMA_AWDOMAIN 0x2 149d0a8ba6cba0a05ce79df100a3d99502b94117d88Lendacky, Thomas#define XGBE_DMA_AWCACHE 0x7 150d0a8ba6cba0a05ce79df100a3d99502b94117d88Lendacky, Thomas 151d0a8ba6cba0a05ce79df100a3d99502b94117d88Lendacky, Thomas#define XGBE_DMA_INTERRUPT_MASK 0x31c7 152c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 153c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_MIN_PACKET 60 154c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_STD_PACKET_MTU 1500 155c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_MAX_STD_PACKET 1518 156c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_JUMBO_PACKET_MTU 9000 157c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_MAX_JUMBO_PACKET 9018 158c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 159c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* MDIO bus phy name */ 160c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGBE_PHY_NAME "amd_xgbe_phy" 161c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGBE_PRTAD 0 162c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 163c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* Driver PMT macros */ 164c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_DRIVER_CONTEXT 1 165c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_IOCTL_CONTEXT 2 166c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 167d0a8ba6cba0a05ce79df100a3d99502b94117d88Lendacky, Thomas#define XGBE_FIFO_SIZE_B(x) (x) 168d0a8ba6cba0a05ce79df100a3d99502b94117d88Lendacky, Thomas#define XGBE_FIFO_SIZE_KB(x) (x * 1024) 169c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 170c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGBE_TC_CNT 2 171c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 172c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* Helper macro for descriptor handling 173d0a8ba6cba0a05ce79df100a3d99502b94117d88Lendacky, Thomas * Always use XGBE_GET_DESC_DATA to access the descriptor data 174c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * since the index is free-running and needs to be and-ed 175c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * with the descriptor count value of the ring to index to 176c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * the proper descriptor data. 177c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas */ 178d0a8ba6cba0a05ce79df100a3d99502b94117d88Lendacky, Thomas#define XGBE_GET_DESC_DATA(_ring, _idx) \ 179c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas ((_ring)->rdata + \ 180c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas ((_idx) & ((_ring)->rdesc_count - 1))) 181c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 182c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 183c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* Default coalescing parameters */ 184c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_INIT_DMA_TX_USECS 100 185c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_INIT_DMA_TX_FRAMES 16 186c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 187c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_MAX_DMA_RIWT 0xff 188c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_INIT_DMA_RX_USECS 100 189c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_INIT_DMA_RX_FRAMES 16 190c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 191c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* Flow control queue count */ 192c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_MAX_FLOW_CONTROL_QUEUES 8 193c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 194b85e4d8960f10e4b28613a3e7b76f8889a2089e3Lendacky, Thomas/* Maximum MAC address hash table size (256 bits = 8 bytes) */ 195b85e4d8960f10e4b28613a3e7b76f8889a2089e3Lendacky, Thomas#define XGBE_MAC_HASH_TABLE_SIZE 8 196c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 197c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct xgbe_prv_data; 198c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 199c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct xgbe_packet_data { 200c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int attributes; 201c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 202c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int errors; 203c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 204c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rdesc_count; 205c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int length; 206c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 207c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int header_len; 208c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tcp_header_len; 209c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tcp_payload_len; 210c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned short mss; 211c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 212c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned short vlan_ctag; 213c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas}; 214c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 215c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* Common Rx and Tx descriptor mapping */ 216c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct xgbe_ring_desc { 217c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int desc0; 218c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int desc1; 219c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int desc2; 220c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int desc3; 221c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas}; 222c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 223c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* Structure used to hold information related to the descriptor 224c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * and the packet associated with the descriptor (always use 225d0a8ba6cba0a05ce79df100a3d99502b94117d88Lendacky, Thomas * use the XGBE_GET_DESC_DATA macro to access this data from the ring) 226c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas */ 227c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct xgbe_ring_data { 228c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_ring_desc *rdesc; /* Virtual address of descriptor */ 229c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas dma_addr_t rdesc_dma; /* DMA address of descriptor */ 230c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 231c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct sk_buff *skb; /* Virtual address of SKB */ 232c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas dma_addr_t skb_dma; /* DMA address of SKB data */ 233c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int skb_dma_len; /* Length of SKB DMA area */ 234c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tso_header; /* TSO header indicator */ 235c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 236c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned short len; /* Length of received Rx packet */ 237c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 238c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int interrupt; /* Interrupt indicator */ 239c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 240c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int mapped_as_page; 241c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas}; 242c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 243c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct xgbe_ring { 244c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Ring lock - used just for TX rings at the moment */ 245c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas spinlock_t lock; 246c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 247c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Per packet related information */ 248c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_packet_data packet_data; 249c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 250c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Virtual/DMA addresses and count of allocated descriptor memory */ 251c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_ring_desc *rdesc; 252c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas dma_addr_t rdesc_dma; 253c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rdesc_count; 254c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 255c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Array of descriptor data corresponding the descriptor memory 256d0a8ba6cba0a05ce79df100a3d99502b94117d88Lendacky, Thomas * (always use the XGBE_GET_DESC_DATA macro to access this data) 257c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas */ 258c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_ring_data *rdata; 259c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 260c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Ring index values 261c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * cur - Tx: index of descriptor to be used for current transfer 262c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * Rx: index of descriptor to check for packet availability 263c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * dirty - Tx: index of descriptor to check for transfer complete 264c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * Rx: count of descriptors in which a packet has been received 265c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * (used with skb_realloc_index to refresh the ring) 266c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas */ 267c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int cur; 268c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int dirty; 269c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 270c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Coalesce frame count used for interrupt bit setting */ 271c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int coalesce_count; 272c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 273c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas union { 274c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct { 275c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int queue_stopped; 276c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned short cur_mss; 277c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned short cur_vlan_ctag; 278c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas } tx; 279c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 280c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct { 281c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int realloc_index; 282c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int realloc_threshold; 283c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas } rx; 284c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas }; 285c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas} ____cacheline_aligned; 286c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 287c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* Structure used to describe the descriptor rings associated with 288c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * a DMA channel. 289c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas */ 290c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct xgbe_channel { 291c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas char name[16]; 292c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 293c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Address of private data area for device */ 294c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_prv_data *pdata; 295c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 296c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Queue index and base address of queue's DMA registers */ 297c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int queue_index; 298c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void __iomem *dma_regs; 299c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 300c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int saved_ier; 301c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 302c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_timer_active; 303c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct hrtimer tx_timer; 304c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 305c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_ring *tx_ring; 306c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_ring *rx_ring; 307c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas} ____cacheline_aligned; 308c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 309c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasenum xgbe_int { 310c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_INT_DMA_ISR_DC0IS, 311c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_INT_DMA_CH_SR_TI, 312c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_INT_DMA_CH_SR_TPS, 313c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_INT_DMA_CH_SR_TBU, 314c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_INT_DMA_CH_SR_RI, 315c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_INT_DMA_CH_SR_RBU, 316c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_INT_DMA_CH_SR_RPS, 317c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_INT_DMA_CH_SR_FBE, 318c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_INT_DMA_ALL, 319c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas}; 320c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 321c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasenum xgbe_int_state { 322c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_INT_STATE_SAVE, 323c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_INT_STATE_RESTORE, 324c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas}; 325c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 326c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasenum xgbe_mtl_fifo_size { 327c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_MTL_FIFO_SIZE_256 = 0x00, 328c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_MTL_FIFO_SIZE_512 = 0x01, 329c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_MTL_FIFO_SIZE_1K = 0x03, 330c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_MTL_FIFO_SIZE_2K = 0x07, 331c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_MTL_FIFO_SIZE_4K = 0x0f, 332c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_MTL_FIFO_SIZE_8K = 0x1f, 333c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_MTL_FIFO_SIZE_16K = 0x3f, 334c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_MTL_FIFO_SIZE_32K = 0x7f, 335c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_MTL_FIFO_SIZE_64K = 0xff, 336c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_MTL_FIFO_SIZE_128K = 0x1ff, 337c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_MTL_FIFO_SIZE_256K = 0x3ff, 338c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas}; 339c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 340c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct xgbe_mmc_stats { 341c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Tx Stats */ 342c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txoctetcount_gb; 343c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txframecount_gb; 344c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txbroadcastframes_g; 345c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txmulticastframes_g; 346c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 tx64octets_gb; 347c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 tx65to127octets_gb; 348c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 tx128to255octets_gb; 349c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 tx256to511octets_gb; 350c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 tx512to1023octets_gb; 351c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 tx1024tomaxoctets_gb; 352c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txunicastframes_gb; 353c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txmulticastframes_gb; 354c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txbroadcastframes_gb; 355c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txunderflowerror; 356c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txoctetcount_g; 357c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txframecount_g; 358c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txpauseframes; 359c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txvlanframes_g; 360c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 361c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Rx Stats */ 362c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxframecount_gb; 363c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxoctetcount_gb; 364c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxoctetcount_g; 365c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxbroadcastframes_g; 366c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxmulticastframes_g; 367c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxcrcerror; 368c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxrunterror; 369c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxjabbererror; 370c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxundersize_g; 371c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxoversize_g; 372c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rx64octets_gb; 373c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rx65to127octets_gb; 374c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rx128to255octets_gb; 375c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rx256to511octets_gb; 376c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rx512to1023octets_gb; 377c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rx1024tomaxoctets_gb; 378c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxunicastframes_g; 379c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxlengtherror; 380c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxoutofrangetype; 381c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxpauseframes; 382c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxfifooverflow; 383c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxvlanframes_gb; 384c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxwatchdogerror; 385c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas}; 386c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 387c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct xgbe_hw_if { 388c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*tx_complete)(struct xgbe_ring_desc *); 389c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 390c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*set_promiscuous_mode)(struct xgbe_prv_data *, unsigned int); 391c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*set_all_multicast_mode)(struct xgbe_prv_data *, unsigned int); 392b85e4d8960f10e4b28613a3e7b76f8889a2089e3Lendacky, Thomas int (*add_mac_addresses)(struct xgbe_prv_data *); 393c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*set_mac_address)(struct xgbe_prv_data *, u8 *addr); 394c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 395c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*enable_rx_csum)(struct xgbe_prv_data *); 396c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*disable_rx_csum)(struct xgbe_prv_data *); 397c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 398c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*enable_rx_vlan_stripping)(struct xgbe_prv_data *); 399c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*disable_rx_vlan_stripping)(struct xgbe_prv_data *); 400801c62d945c6121c0262924732e430f0553bfb37Lendacky, Thomas int (*enable_rx_vlan_filtering)(struct xgbe_prv_data *); 401801c62d945c6121c0262924732e430f0553bfb37Lendacky, Thomas int (*disable_rx_vlan_filtering)(struct xgbe_prv_data *); 402801c62d945c6121c0262924732e430f0553bfb37Lendacky, Thomas int (*update_vlan_hash_table)(struct xgbe_prv_data *); 403c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 404c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*read_mmd_regs)(struct xgbe_prv_data *, int, int); 405c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*write_mmd_regs)(struct xgbe_prv_data *, int, int, int); 406c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*set_gmii_speed)(struct xgbe_prv_data *); 407c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*set_gmii_2500_speed)(struct xgbe_prv_data *); 408c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*set_xgmii_speed)(struct xgbe_prv_data *); 409c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 410c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*enable_tx)(struct xgbe_prv_data *); 411c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*disable_tx)(struct xgbe_prv_data *); 412c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*enable_rx)(struct xgbe_prv_data *); 413c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*disable_rx)(struct xgbe_prv_data *); 414c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 415c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*powerup_tx)(struct xgbe_prv_data *); 416c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*powerdown_tx)(struct xgbe_prv_data *); 417c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*powerup_rx)(struct xgbe_prv_data *); 418c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*powerdown_rx)(struct xgbe_prv_data *); 419c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 420c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*init)(struct xgbe_prv_data *); 421c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*exit)(struct xgbe_prv_data *); 422c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 423c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*enable_int)(struct xgbe_channel *, enum xgbe_int); 424c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*disable_int)(struct xgbe_channel *, enum xgbe_int); 425c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*pre_xmit)(struct xgbe_channel *); 426c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*dev_read)(struct xgbe_channel *); 427c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*tx_desc_init)(struct xgbe_channel *); 428c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*rx_desc_init)(struct xgbe_channel *); 429c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*rx_desc_reset)(struct xgbe_ring_data *); 430c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*tx_desc_reset)(struct xgbe_ring_data *); 431c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*is_last_desc)(struct xgbe_ring_desc *); 432c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*is_context_desc)(struct xgbe_ring_desc *); 433c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 434c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* For FLOW ctrl */ 435c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_tx_flow_control)(struct xgbe_prv_data *); 436c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_rx_flow_control)(struct xgbe_prv_data *); 437c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 438c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* For RX coalescing */ 439c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_rx_coalesce)(struct xgbe_prv_data *); 440c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_tx_coalesce)(struct xgbe_prv_data *); 441c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int (*usec_to_riwt)(struct xgbe_prv_data *, unsigned int); 442c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int (*riwt_to_usec)(struct xgbe_prv_data *, unsigned int); 443c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 444c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* For RX and TX threshold config */ 445c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_rx_threshold)(struct xgbe_prv_data *, unsigned int); 446c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_tx_threshold)(struct xgbe_prv_data *, unsigned int); 447c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 448c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* For RX and TX Store and Forward Mode config */ 449c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_rsf_mode)(struct xgbe_prv_data *, unsigned int); 450c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_tsf_mode)(struct xgbe_prv_data *, unsigned int); 451c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 452c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* For TX DMA Operate on Second Frame config */ 453c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_osp_mode)(struct xgbe_prv_data *); 454c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 455c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* For RX and TX PBL config */ 456c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_rx_pbl_val)(struct xgbe_prv_data *); 457c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*get_rx_pbl_val)(struct xgbe_prv_data *); 458c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_tx_pbl_val)(struct xgbe_prv_data *); 459c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*get_tx_pbl_val)(struct xgbe_prv_data *); 460c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_pblx8)(struct xgbe_prv_data *); 461c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 462c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* For MMC statistics */ 463c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*rx_mmc_int)(struct xgbe_prv_data *); 464c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*tx_mmc_int)(struct xgbe_prv_data *); 465c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*read_mmc_stats)(struct xgbe_prv_data *); 466c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas}; 467c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 468c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct xgbe_desc_if { 469c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*alloc_ring_resources)(struct xgbe_prv_data *); 470c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*free_ring_resources)(struct xgbe_prv_data *); 471c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*map_tx_skb)(struct xgbe_channel *, struct sk_buff *); 472c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*realloc_skb)(struct xgbe_channel *); 473c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*unmap_skb)(struct xgbe_prv_data *, struct xgbe_ring_data *); 474c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*wrapper_tx_desc_init)(struct xgbe_prv_data *); 475c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*wrapper_rx_desc_init)(struct xgbe_prv_data *); 476c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas}; 477c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 478c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* This structure contains flags that indicate what hardware features 479c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * or configurations are present in the device. 480c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas */ 481c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct xgbe_hw_features { 482c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* HW Feature Register0 */ 483c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int gmii; /* 1000 Mbps support */ 484c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int vlhash; /* VLAN Hash Filter */ 485c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int sma; /* SMA(MDIO) Interface */ 486c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rwk; /* PMT remote wake-up packet */ 487c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int mgk; /* PMT magic packet */ 488c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int mmc; /* RMON module */ 489c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int aoe; /* ARP Offload */ 490c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int ts; /* IEEE 1588-2008 Adavanced Timestamp */ 491c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int eee; /* Energy Efficient Ethernet */ 492c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_coe; /* Tx Checksum Offload */ 493c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_coe; /* Rx Checksum Offload */ 494c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int addn_mac; /* Additional MAC Addresses */ 495c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int ts_src; /* Timestamp Source */ 496c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int sa_vlan_ins; /* Source Address or VLAN Insertion */ 497c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 498c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* HW Feature Register1 */ 499c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_fifo_size; /* MTL Receive FIFO Size */ 500c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_fifo_size; /* MTL Transmit FIFO Size */ 501c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int adv_ts_hi; /* Advance Timestamping High Word */ 502c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int dcb; /* DCB Feature */ 503c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int sph; /* Split Header Feature */ 504c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tso; /* TCP Segmentation Offload */ 505c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int dma_debug; /* DMA Debug Registers */ 506c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rss; /* Receive Side Scaling */ 507c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int hash_table_size; /* Hash Table Size */ 508c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int l3l4_filter_num; /* Number of L3-L4 Filters */ 509c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 510c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* HW Feature Register2 */ 511c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_q_cnt; /* Number of MTL Receive Queues */ 512c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_q_cnt; /* Number of MTL Transmit Queues */ 513c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_ch_cnt; /* Number of DMA Receive Channels */ 514c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_ch_cnt; /* Number of DMA Transmit Channels */ 515c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int pps_out_num; /* Number of PPS outputs */ 516c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int aux_snap_num; /* Number of Aux snapshot inputs */ 517c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas}; 518c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 519c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct xgbe_prv_data { 520c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct net_device *netdev; 521c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct platform_device *pdev; 522c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct device *dev; 523c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 524c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* XGMAC/XPCS related mmio registers */ 525c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void __iomem *xgmac_regs; /* XGMAC CSRs */ 526c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void __iomem *xpcs_regs; /* XPCS MMD registers */ 527c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 528c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Overall device lock */ 529c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas spinlock_t lock; 530c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 531c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* XPCS indirect addressing mutex */ 532c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct mutex xpcs_mutex; 533c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 534c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int irq_number; 535c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 536c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_hw_if hw_if; 537c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_desc_if desc_if; 538c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 539c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Rings for Tx/Rx on a DMA channel */ 540c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_channel *channel; 541c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int channel_count; 542c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_ring_count; 543c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_desc_count; 544c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_ring_count; 545c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_desc_count; 546c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 547c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Tx/Rx common settings */ 548c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int pblx8; 549c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 550c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Tx settings */ 551c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_sf_mode; 552c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_threshold; 553c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_pbl; 554c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_osp_mode; 555c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 556c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Rx settings */ 557c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_sf_mode; 558c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_threshold; 559c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_pbl; 560c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 561c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Tx coalescing settings */ 562c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_usecs; 563c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_frames; 564c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 565c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Rx coalescing settings */ 566c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_riwt; 567c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_frames; 568c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 569c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Current MTU */ 570c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_buf_size; 571c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 572c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Flow control settings */ 573c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int pause_autoneg; 574c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_pause; 575c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_pause; 576c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 577c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* MDIO settings */ 578c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct module *phy_module; 579c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas char *mii_bus_id; 580c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct mii_bus *mii; 581c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int mdio_mmd; 582c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct phy_device *phydev; 583c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int default_autoneg; 584c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int default_speed; 585c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 586c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Current PHY settings */ 587c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas phy_interface_t phy_mode; 588c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int phy_link; 589c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int phy_speed; 590c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int phy_tx_pause; 591c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int phy_rx_pause; 592c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 593c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Netdev related settings */ 594c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas netdev_features_t netdev_features; 595c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct napi_struct napi; 596c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_mmc_stats mmc_stats; 597c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 598801c62d945c6121c0262924732e430f0553bfb37Lendacky, Thomas /* Filtering support */ 599801c62d945c6121c0262924732e430f0553bfb37Lendacky, Thomas unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; 600801c62d945c6121c0262924732e430f0553bfb37Lendacky, Thomas 601c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* System clock value used for Rx watchdog */ 602c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct clk *sysclock; 603c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 604c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Hardware features of the device */ 605c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_hw_features hw_feat; 606c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 607c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Device restart work structure */ 608c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct work_struct restart_work; 609c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 610c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Keeps track of power mode */ 611c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int power_down; 612c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 613c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#ifdef CONFIG_DEBUG_FS 614c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct dentry *xgbe_debugfs; 615c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 616c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int debugfs_xgmac_reg; 617c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 618c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int debugfs_xpcs_mmd; 619c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int debugfs_xpcs_reg; 620c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#endif 621c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas}; 622c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 623c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* Function prototypes*/ 624c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 625c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_init_function_ptrs_dev(struct xgbe_hw_if *); 626c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_init_function_ptrs_desc(struct xgbe_desc_if *); 627c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct net_device_ops *xgbe_get_netdev_ops(void); 628c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct ethtool_ops *xgbe_get_ethtool_ops(void); 629c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 630c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasint xgbe_mdio_register(struct xgbe_prv_data *); 631c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_mdio_unregister(struct xgbe_prv_data *); 632c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_dump_phy_registers(struct xgbe_prv_data *); 633c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_dump_tx_desc(struct xgbe_ring *, unsigned int, unsigned int, 634c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int); 635c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_dump_rx_desc(struct xgbe_ring *, struct xgbe_ring_desc *, 636c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int); 637c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_print_pkt(struct net_device *, struct sk_buff *, bool); 638c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_get_all_hw_features(struct xgbe_prv_data *); 639c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasint xgbe_powerup(struct net_device *, unsigned int); 640c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasint xgbe_powerdown(struct net_device *, unsigned int); 641c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_init_rx_coalesce(struct xgbe_prv_data *); 642c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_init_tx_coalesce(struct xgbe_prv_data *); 643c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 644c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#ifdef CONFIG_DEBUG_FS 645c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_debugfs_init(struct xgbe_prv_data *); 646c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_debugfs_exit(struct xgbe_prv_data *); 647c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#else 648c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstatic inline void xgbe_debugfs_init(struct xgbe_prv_data *pdata) {} 649c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstatic inline void xgbe_debugfs_exit(struct xgbe_prv_data *pdata) {} 650c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#endif /* CONFIG_DEBUG_FS */ 651c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 652c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* NOTE: Uncomment for TX and RX DESCRIPTOR DUMP in KERNEL LOG */ 653c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#if 0 654c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_ENABLE_TX_DESC_DUMP 655c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_ENABLE_RX_DESC_DUMP 656c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#endif 657c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 658c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* NOTE: Uncomment for TX and RX PACKET DUMP in KERNEL LOG */ 659c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#if 0 660c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_ENABLE_TX_PKT_DUMP 661c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_ENABLE_RX_PKT_DUMP 662c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#endif 663c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 664c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* NOTE: Uncomment for function trace log messages in KERNEL LOG */ 665c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#if 0 666c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define YDEBUG 667c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define YDEBUG_MDIO 668c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#endif 669c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 670c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* For debug prints */ 671c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#ifdef YDEBUG 672c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define DBGPR(x...) pr_alert(x) 673c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define DBGPHY_REGS(x...) xgbe_dump_phy_registers(x) 674c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#else 675c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define DBGPR(x...) do { } while (0) 676c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define DBGPHY_REGS(x...) do { } while (0) 677c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#endif 678c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 679c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#ifdef YDEBUG_MDIO 680c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define DBGPR_MDIO(x...) pr_alert(x) 681c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#else 682c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define DBGPR_MDIO(x...) do { } while (0) 683c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#endif 684c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 685c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#endif 686