xgbe.h revision c5aa9e3b815645e3aad08444c91ca6b237eeea01
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> 124c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 125c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 126c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGBE_DRV_NAME "amd-xgbe" 127c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGBE_DRV_VERSION "1.0.0-a" 128c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGBE_DRV_DESC "AMD 10 Gigabit Ethernet Driver" 129c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 130c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* Descriptor related defines */ 131c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define TX_DESC_CNT 512 132c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define TX_DESC_MIN_FREE (TX_DESC_CNT >> 3) 133c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define TX_DESC_MAX_PROC (TX_DESC_CNT >> 1) 134c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define RX_DESC_CNT 512 135c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 136c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define TX_MAX_BUF_SIZE (0x3fff & ~(64 - 1)) 137c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 138c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define RX_MIN_BUF_SIZE (ETH_FRAME_LEN + ETH_FCS_LEN + VLAN_HLEN) 139c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define RX_BUF_ALIGN 64 140c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 141c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define MAX_DMA_CHANNELS 16 142c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define DMA_ARDOMAIN_SETTING 0x2 143c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define DMA_ARCACHE_SETTING 0xb 144c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define DMA_AWDOMAIN_SETTING 0x2 145c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define DMA_AWCACHE_SETTING 0x7 146c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define DMA_INTERRUPT_MASK 0x31c7 147c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 148c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_MIN_PACKET 60 149c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_STD_PACKET_MTU 1500 150c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_MAX_STD_PACKET 1518 151c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_JUMBO_PACKET_MTU 9000 152c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_MAX_JUMBO_PACKET 9018 153c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 154c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define MAX_MULTICAST_LIST 14 155c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define TX_FLAGS_IP_PKT 0x00000001 156c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define TX_FLAGS_TCP_PKT 0x00000002 157c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 158c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* MDIO bus phy name */ 159c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGBE_PHY_NAME "amd_xgbe_phy" 160c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGBE_PRTAD 0 161c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 162c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* Driver PMT macros */ 163c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_DRIVER_CONTEXT 1 164c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_IOCTL_CONTEXT 2 165c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 166c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define FIFO_SIZE_B(x) (x) 167c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define FIFO_SIZE_KB(x) (x * 1024) 168c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 169c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGBE_TC_CNT 2 170c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 171c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* Helper macro for descriptor handling 172c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * Always use GET_DESC_DATA to access the descriptor data 173c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * since the index is free-running and needs to be and-ed 174c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * with the descriptor count value of the ring to index to 175c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * the proper descriptor data. 176c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas */ 177c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define GET_DESC_DATA(_ring, _idx) \ 178c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas ((_ring)->rdata + \ 179c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas ((_idx) & ((_ring)->rdesc_count - 1))) 180c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 181c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 182c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* Default coalescing parameters */ 183c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_INIT_DMA_TX_USECS 100 184c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_INIT_DMA_TX_FRAMES 16 185c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 186c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_MAX_DMA_RIWT 0xff 187c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_INIT_DMA_RX_USECS 100 188c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_INIT_DMA_RX_FRAMES 16 189c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 190c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* Flow control queue count */ 191c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_MAX_FLOW_CONTROL_QUEUES 8 192c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 193c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 194c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct xgbe_prv_data; 195c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 196c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct xgbe_packet_data { 197c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int attributes; 198c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 199c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int errors; 200c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 201c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rdesc_count; 202c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int length; 203c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 204c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int header_len; 205c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tcp_header_len; 206c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tcp_payload_len; 207c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned short mss; 208c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 209c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned short vlan_ctag; 210c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas}; 211c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 212c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* Common Rx and Tx descriptor mapping */ 213c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct xgbe_ring_desc { 214c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int desc0; 215c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int desc1; 216c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int desc2; 217c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int desc3; 218c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas}; 219c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 220c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* Structure used to hold information related to the descriptor 221c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * and the packet associated with the descriptor (always use 222c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * use the GET_DESC_DATA macro to access this data from the ring) 223c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas */ 224c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct xgbe_ring_data { 225c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_ring_desc *rdesc; /* Virtual address of descriptor */ 226c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas dma_addr_t rdesc_dma; /* DMA address of descriptor */ 227c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 228c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct sk_buff *skb; /* Virtual address of SKB */ 229c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas dma_addr_t skb_dma; /* DMA address of SKB data */ 230c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int skb_dma_len; /* Length of SKB DMA area */ 231c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tso_header; /* TSO header indicator */ 232c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 233c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned short len; /* Length of received Rx packet */ 234c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 235c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int interrupt; /* Interrupt indicator */ 236c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 237c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int mapped_as_page; 238c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas}; 239c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 240c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct xgbe_ring { 241c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Ring lock - used just for TX rings at the moment */ 242c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas spinlock_t lock; 243c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 244c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Per packet related information */ 245c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_packet_data packet_data; 246c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 247c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Virtual/DMA addresses and count of allocated descriptor memory */ 248c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_ring_desc *rdesc; 249c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas dma_addr_t rdesc_dma; 250c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rdesc_count; 251c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 252c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Array of descriptor data corresponding the descriptor memory 253c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * (always use the GET_DESC_DATA macro to access this data) 254c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas */ 255c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_ring_data *rdata; 256c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 257c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Ring index values 258c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * cur - Tx: index of descriptor to be used for current transfer 259c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * Rx: index of descriptor to check for packet availability 260c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * dirty - Tx: index of descriptor to check for transfer complete 261c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * Rx: count of descriptors in which a packet has been received 262c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * (used with skb_realloc_index to refresh the ring) 263c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas */ 264c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int cur; 265c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int dirty; 266c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 267c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Coalesce frame count used for interrupt bit setting */ 268c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int coalesce_count; 269c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 270c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas union { 271c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct { 272c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int queue_stopped; 273c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned short cur_mss; 274c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned short cur_vlan_ctag; 275c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas } tx; 276c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 277c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct { 278c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int realloc_index; 279c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int realloc_threshold; 280c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas } rx; 281c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas }; 282c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas} ____cacheline_aligned; 283c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 284c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* Structure used to describe the descriptor rings associated with 285c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * a DMA channel. 286c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas */ 287c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct xgbe_channel { 288c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas char name[16]; 289c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 290c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Address of private data area for device */ 291c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_prv_data *pdata; 292c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 293c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Queue index and base address of queue's DMA registers */ 294c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int queue_index; 295c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void __iomem *dma_regs; 296c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 297c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int saved_ier; 298c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 299c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_timer_active; 300c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct hrtimer tx_timer; 301c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 302c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_ring *tx_ring; 303c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_ring *rx_ring; 304c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas} ____cacheline_aligned; 305c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 306c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasenum xgbe_int { 307c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_INT_DMA_ISR_DC0IS, 308c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_INT_DMA_CH_SR_TI, 309c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_INT_DMA_CH_SR_TPS, 310c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_INT_DMA_CH_SR_TBU, 311c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_INT_DMA_CH_SR_RI, 312c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_INT_DMA_CH_SR_RBU, 313c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_INT_DMA_CH_SR_RPS, 314c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_INT_DMA_CH_SR_FBE, 315c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_INT_DMA_ALL, 316c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas}; 317c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 318c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasenum xgbe_int_state { 319c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_INT_STATE_SAVE, 320c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_INT_STATE_RESTORE, 321c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas}; 322c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 323c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasenum xgbe_mtl_fifo_size { 324c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_MTL_FIFO_SIZE_256 = 0x00, 325c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_MTL_FIFO_SIZE_512 = 0x01, 326c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_MTL_FIFO_SIZE_1K = 0x03, 327c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_MTL_FIFO_SIZE_2K = 0x07, 328c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_MTL_FIFO_SIZE_4K = 0x0f, 329c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_MTL_FIFO_SIZE_8K = 0x1f, 330c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_MTL_FIFO_SIZE_16K = 0x3f, 331c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_MTL_FIFO_SIZE_32K = 0x7f, 332c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_MTL_FIFO_SIZE_64K = 0xff, 333c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_MTL_FIFO_SIZE_128K = 0x1ff, 334c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas XGMAC_MTL_FIFO_SIZE_256K = 0x3ff, 335c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas}; 336c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 337c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct xgbe_mmc_stats { 338c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Tx Stats */ 339c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txoctetcount_gb; 340c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txframecount_gb; 341c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txbroadcastframes_g; 342c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txmulticastframes_g; 343c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 tx64octets_gb; 344c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 tx65to127octets_gb; 345c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 tx128to255octets_gb; 346c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 tx256to511octets_gb; 347c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 tx512to1023octets_gb; 348c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 tx1024tomaxoctets_gb; 349c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txunicastframes_gb; 350c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txmulticastframes_gb; 351c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txbroadcastframes_gb; 352c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txunderflowerror; 353c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txoctetcount_g; 354c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txframecount_g; 355c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txpauseframes; 356c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 txvlanframes_g; 357c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 358c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Rx Stats */ 359c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxframecount_gb; 360c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxoctetcount_gb; 361c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxoctetcount_g; 362c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxbroadcastframes_g; 363c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxmulticastframes_g; 364c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxcrcerror; 365c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxrunterror; 366c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxjabbererror; 367c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxundersize_g; 368c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxoversize_g; 369c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rx64octets_gb; 370c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rx65to127octets_gb; 371c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rx128to255octets_gb; 372c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rx256to511octets_gb; 373c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rx512to1023octets_gb; 374c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rx1024tomaxoctets_gb; 375c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxunicastframes_g; 376c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxlengtherror; 377c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxoutofrangetype; 378c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxpauseframes; 379c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxfifooverflow; 380c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxvlanframes_gb; 381c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas u64 rxwatchdogerror; 382c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas}; 383c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 384c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct xgbe_hw_if { 385c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*tx_complete)(struct xgbe_ring_desc *); 386c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 387c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*set_promiscuous_mode)(struct xgbe_prv_data *, unsigned int); 388c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*set_all_multicast_mode)(struct xgbe_prv_data *, unsigned int); 389c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*set_addn_mac_addrs)(struct xgbe_prv_data *, unsigned int); 390c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*set_mac_address)(struct xgbe_prv_data *, u8 *addr); 391c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 392c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*enable_rx_csum)(struct xgbe_prv_data *); 393c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*disable_rx_csum)(struct xgbe_prv_data *); 394c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 395c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*enable_rx_vlan_stripping)(struct xgbe_prv_data *); 396c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*disable_rx_vlan_stripping)(struct xgbe_prv_data *); 397c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 398c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*read_mmd_regs)(struct xgbe_prv_data *, int, int); 399c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*write_mmd_regs)(struct xgbe_prv_data *, int, int, int); 400c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*set_gmii_speed)(struct xgbe_prv_data *); 401c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*set_gmii_2500_speed)(struct xgbe_prv_data *); 402c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*set_xgmii_speed)(struct xgbe_prv_data *); 403c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 404c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*enable_tx)(struct xgbe_prv_data *); 405c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*disable_tx)(struct xgbe_prv_data *); 406c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*enable_rx)(struct xgbe_prv_data *); 407c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*disable_rx)(struct xgbe_prv_data *); 408c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 409c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*powerup_tx)(struct xgbe_prv_data *); 410c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*powerdown_tx)(struct xgbe_prv_data *); 411c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*powerup_rx)(struct xgbe_prv_data *); 412c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*powerdown_rx)(struct xgbe_prv_data *); 413c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 414c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*init)(struct xgbe_prv_data *); 415c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*exit)(struct xgbe_prv_data *); 416c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 417c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*enable_int)(struct xgbe_channel *, enum xgbe_int); 418c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*disable_int)(struct xgbe_channel *, enum xgbe_int); 419c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*pre_xmit)(struct xgbe_channel *); 420c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*dev_read)(struct xgbe_channel *); 421c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*tx_desc_init)(struct xgbe_channel *); 422c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*rx_desc_init)(struct xgbe_channel *); 423c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*rx_desc_reset)(struct xgbe_ring_data *); 424c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*tx_desc_reset)(struct xgbe_ring_data *); 425c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*is_last_desc)(struct xgbe_ring_desc *); 426c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*is_context_desc)(struct xgbe_ring_desc *); 427c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 428c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* For FLOW ctrl */ 429c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_tx_flow_control)(struct xgbe_prv_data *); 430c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_rx_flow_control)(struct xgbe_prv_data *); 431c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 432c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* For RX coalescing */ 433c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_rx_coalesce)(struct xgbe_prv_data *); 434c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_tx_coalesce)(struct xgbe_prv_data *); 435c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int (*usec_to_riwt)(struct xgbe_prv_data *, unsigned int); 436c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int (*riwt_to_usec)(struct xgbe_prv_data *, unsigned int); 437c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 438c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* For RX and TX threshold config */ 439c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_rx_threshold)(struct xgbe_prv_data *, unsigned int); 440c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_tx_threshold)(struct xgbe_prv_data *, unsigned int); 441c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 442c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* For RX and TX Store and Forward Mode config */ 443c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_rsf_mode)(struct xgbe_prv_data *, unsigned int); 444c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_tsf_mode)(struct xgbe_prv_data *, unsigned int); 445c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 446c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* For TX DMA Operate on Second Frame config */ 447c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_osp_mode)(struct xgbe_prv_data *); 448c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 449c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* For RX and TX PBL config */ 450c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_rx_pbl_val)(struct xgbe_prv_data *); 451c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*get_rx_pbl_val)(struct xgbe_prv_data *); 452c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_tx_pbl_val)(struct xgbe_prv_data *); 453c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*get_tx_pbl_val)(struct xgbe_prv_data *); 454c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*config_pblx8)(struct xgbe_prv_data *); 455c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 456c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* For MMC statistics */ 457c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*rx_mmc_int)(struct xgbe_prv_data *); 458c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*tx_mmc_int)(struct xgbe_prv_data *); 459c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*read_mmc_stats)(struct xgbe_prv_data *); 460c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas}; 461c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 462c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct xgbe_desc_if { 463c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*alloc_ring_resources)(struct xgbe_prv_data *); 464c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*free_ring_resources)(struct xgbe_prv_data *); 465c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int (*map_tx_skb)(struct xgbe_channel *, struct sk_buff *); 466c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*realloc_skb)(struct xgbe_channel *); 467c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*unmap_skb)(struct xgbe_prv_data *, struct xgbe_ring_data *); 468c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*wrapper_tx_desc_init)(struct xgbe_prv_data *); 469c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void (*wrapper_rx_desc_init)(struct xgbe_prv_data *); 470c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas}; 471c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 472c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* This structure contains flags that indicate what hardware features 473c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas * or configurations are present in the device. 474c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas */ 475c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct xgbe_hw_features { 476c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* HW Feature Register0 */ 477c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int gmii; /* 1000 Mbps support */ 478c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int vlhash; /* VLAN Hash Filter */ 479c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int sma; /* SMA(MDIO) Interface */ 480c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rwk; /* PMT remote wake-up packet */ 481c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int mgk; /* PMT magic packet */ 482c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int mmc; /* RMON module */ 483c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int aoe; /* ARP Offload */ 484c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int ts; /* IEEE 1588-2008 Adavanced Timestamp */ 485c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int eee; /* Energy Efficient Ethernet */ 486c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_coe; /* Tx Checksum Offload */ 487c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_coe; /* Rx Checksum Offload */ 488c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int addn_mac; /* Additional MAC Addresses */ 489c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int ts_src; /* Timestamp Source */ 490c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int sa_vlan_ins; /* Source Address or VLAN Insertion */ 491c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 492c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* HW Feature Register1 */ 493c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_fifo_size; /* MTL Receive FIFO Size */ 494c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_fifo_size; /* MTL Transmit FIFO Size */ 495c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int adv_ts_hi; /* Advance Timestamping High Word */ 496c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int dcb; /* DCB Feature */ 497c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int sph; /* Split Header Feature */ 498c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tso; /* TCP Segmentation Offload */ 499c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int dma_debug; /* DMA Debug Registers */ 500c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rss; /* Receive Side Scaling */ 501c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int hash_table_size; /* Hash Table Size */ 502c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int l3l4_filter_num; /* Number of L3-L4 Filters */ 503c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 504c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* HW Feature Register2 */ 505c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_q_cnt; /* Number of MTL Receive Queues */ 506c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_q_cnt; /* Number of MTL Transmit Queues */ 507c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_ch_cnt; /* Number of DMA Receive Channels */ 508c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_ch_cnt; /* Number of DMA Transmit Channels */ 509c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int pps_out_num; /* Number of PPS outputs */ 510c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int aux_snap_num; /* Number of Aux snapshot inputs */ 511c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas}; 512c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 513c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct xgbe_prv_data { 514c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct net_device *netdev; 515c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct platform_device *pdev; 516c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct device *dev; 517c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 518c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* XGMAC/XPCS related mmio registers */ 519c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void __iomem *xgmac_regs; /* XGMAC CSRs */ 520c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas void __iomem *xpcs_regs; /* XPCS MMD registers */ 521c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 522c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Overall device lock */ 523c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas spinlock_t lock; 524c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 525c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* XPCS indirect addressing mutex */ 526c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct mutex xpcs_mutex; 527c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 528c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int irq_number; 529c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 530c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_hw_if hw_if; 531c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_desc_if desc_if; 532c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 533c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Rings for Tx/Rx on a DMA channel */ 534c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_channel *channel; 535c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int channel_count; 536c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_ring_count; 537c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_desc_count; 538c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_ring_count; 539c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_desc_count; 540c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 541c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Tx/Rx common settings */ 542c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int pblx8; 543c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 544c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Tx settings */ 545c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_sf_mode; 546c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_threshold; 547c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_pbl; 548c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_osp_mode; 549c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 550c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Rx settings */ 551c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_sf_mode; 552c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_threshold; 553c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_pbl; 554c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 555c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Tx coalescing settings */ 556c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_usecs; 557c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_frames; 558c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 559c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Rx coalescing settings */ 560c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_riwt; 561c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_frames; 562c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 563c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Current MTU */ 564c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_buf_size; 565c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 566c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Flow control settings */ 567c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int pause_autoneg; 568c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int tx_pause; 569c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int rx_pause; 570c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 571c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* MDIO settings */ 572c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct module *phy_module; 573c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas char *mii_bus_id; 574c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct mii_bus *mii; 575c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int mdio_mmd; 576c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct phy_device *phydev; 577c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int default_autoneg; 578c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int default_speed; 579c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 580c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Current PHY settings */ 581c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas phy_interface_t phy_mode; 582c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int phy_link; 583c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas int phy_speed; 584c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int phy_tx_pause; 585c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int phy_rx_pause; 586c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 587c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Netdev related settings */ 588c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas netdev_features_t netdev_features; 589c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct napi_struct napi; 590c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_mmc_stats mmc_stats; 591c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 592c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* System clock value used for Rx watchdog */ 593c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct clk *sysclock; 594c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 595c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Hardware features of the device */ 596c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct xgbe_hw_features hw_feat; 597c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 598c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Device restart work structure */ 599c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct work_struct restart_work; 600c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 601c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas /* Keeps track of power mode */ 602c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int power_down; 603c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 604c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#ifdef CONFIG_DEBUG_FS 605c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas struct dentry *xgbe_debugfs; 606c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 607c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int debugfs_xgmac_reg; 608c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 609c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int debugfs_xpcs_mmd; 610c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int debugfs_xpcs_reg; 611c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#endif 612c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas}; 613c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 614c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* Function prototypes*/ 615c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 616c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_init_function_ptrs_dev(struct xgbe_hw_if *); 617c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_init_function_ptrs_desc(struct xgbe_desc_if *); 618c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct net_device_ops *xgbe_get_netdev_ops(void); 619c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstruct ethtool_ops *xgbe_get_ethtool_ops(void); 620c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 621c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasint xgbe_mdio_register(struct xgbe_prv_data *); 622c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_mdio_unregister(struct xgbe_prv_data *); 623c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_dump_phy_registers(struct xgbe_prv_data *); 624c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_dump_tx_desc(struct xgbe_ring *, unsigned int, unsigned int, 625c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int); 626c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_dump_rx_desc(struct xgbe_ring *, struct xgbe_ring_desc *, 627c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas unsigned int); 628c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_print_pkt(struct net_device *, struct sk_buff *, bool); 629c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_get_all_hw_features(struct xgbe_prv_data *); 630c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasint xgbe_powerup(struct net_device *, unsigned int); 631c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasint xgbe_powerdown(struct net_device *, unsigned int); 632c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_init_rx_coalesce(struct xgbe_prv_data *); 633c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_init_tx_coalesce(struct xgbe_prv_data *); 634c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 635c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#ifdef CONFIG_DEBUG_FS 636c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_debugfs_init(struct xgbe_prv_data *); 637c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasvoid xgbe_debugfs_exit(struct xgbe_prv_data *); 638c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#else 639c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstatic inline void xgbe_debugfs_init(struct xgbe_prv_data *pdata) {} 640c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomasstatic inline void xgbe_debugfs_exit(struct xgbe_prv_data *pdata) {} 641c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#endif /* CONFIG_DEBUG_FS */ 642c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 643c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* NOTE: Uncomment for TX and RX DESCRIPTOR DUMP in KERNEL LOG */ 644c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#if 0 645c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_ENABLE_TX_DESC_DUMP 646c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_ENABLE_RX_DESC_DUMP 647c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#endif 648c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 649c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* NOTE: Uncomment for TX and RX PACKET DUMP in KERNEL LOG */ 650c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#if 0 651c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_ENABLE_TX_PKT_DUMP 652c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define XGMAC_ENABLE_RX_PKT_DUMP 653c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#endif 654c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 655c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* NOTE: Uncomment for function trace log messages in KERNEL LOG */ 656c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#if 0 657c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define YDEBUG 658c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define YDEBUG_MDIO 659c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#endif 660c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 661c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas/* For debug prints */ 662c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#ifdef YDEBUG 663c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define DBGPR(x...) pr_alert(x) 664c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define DBGPHY_REGS(x...) xgbe_dump_phy_registers(x) 665c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#else 666c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define DBGPR(x...) do { } while (0) 667c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define DBGPHY_REGS(x...) do { } while (0) 668c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#endif 669c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 670c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#ifdef YDEBUG_MDIO 671c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define DBGPR_MDIO(x...) pr_alert(x) 672c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#else 673c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#define DBGPR_MDIO(x...) do { } while (0) 674c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#endif 675c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas 676c5aa9e3b815645e3aad08444c91ca6b237eeea01Lendacky, Thomas#endif 677