18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* D-Link DL2000-based Gigabit Ethernet Adapter Linux driver */ 38c2ecf20Sopenharmony_ci/* 48c2ecf20Sopenharmony_ci Copyright (c) 2001, 2002 by D-Link Corporation 58c2ecf20Sopenharmony_ci Written by Edward Peng.<edward_peng@dlink.com.tw> 68c2ecf20Sopenharmony_ci Created 03-May-2001, base on Linux' sundance.c. 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci*/ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef __DL2K_H__ 118c2ecf20Sopenharmony_ci#define __DL2K_H__ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <linux/module.h> 148c2ecf20Sopenharmony_ci#include <linux/kernel.h> 158c2ecf20Sopenharmony_ci#include <linux/string.h> 168c2ecf20Sopenharmony_ci#include <linux/timer.h> 178c2ecf20Sopenharmony_ci#include <linux/errno.h> 188c2ecf20Sopenharmony_ci#include <linux/ioport.h> 198c2ecf20Sopenharmony_ci#include <linux/slab.h> 208c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 218c2ecf20Sopenharmony_ci#include <linux/pci.h> 228c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 238c2ecf20Sopenharmony_ci#include <linux/etherdevice.h> 248c2ecf20Sopenharmony_ci#include <linux/skbuff.h> 258c2ecf20Sopenharmony_ci#include <linux/crc32.h> 268c2ecf20Sopenharmony_ci#include <linux/ethtool.h> 278c2ecf20Sopenharmony_ci#include <linux/mii.h> 288c2ecf20Sopenharmony_ci#include <linux/bitops.h> 298c2ecf20Sopenharmony_ci#include <asm/processor.h> /* Processor type for cache alignment. */ 308c2ecf20Sopenharmony_ci#include <asm/io.h> 318c2ecf20Sopenharmony_ci#include <linux/uaccess.h> 328c2ecf20Sopenharmony_ci#include <linux/delay.h> 338c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 348c2ecf20Sopenharmony_ci#include <linux/time.h> 358c2ecf20Sopenharmony_ci#define TX_RING_SIZE 256 368c2ecf20Sopenharmony_ci#define TX_QUEUE_LEN (TX_RING_SIZE - 1) /* Limit ring entries actually used.*/ 378c2ecf20Sopenharmony_ci#define RX_RING_SIZE 256 388c2ecf20Sopenharmony_ci#define TX_TOTAL_SIZE TX_RING_SIZE*sizeof(struct netdev_desc) 398c2ecf20Sopenharmony_ci#define RX_TOTAL_SIZE RX_RING_SIZE*sizeof(struct netdev_desc) 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci/* Offsets to the device registers. 428c2ecf20Sopenharmony_ci Unlike software-only systems, device drivers interact with complex hardware. 438c2ecf20Sopenharmony_ci It's not useful to define symbolic names for every register bit in the 448c2ecf20Sopenharmony_ci device. The name can only partially document the semantics and make 458c2ecf20Sopenharmony_ci the driver longer and more difficult to read. 468c2ecf20Sopenharmony_ci In general, only the important configuration values or bits changed 478c2ecf20Sopenharmony_ci multiple times should be defined symbolically. 488c2ecf20Sopenharmony_ci*/ 498c2ecf20Sopenharmony_cienum dl2x_offsets { 508c2ecf20Sopenharmony_ci /* I/O register offsets */ 518c2ecf20Sopenharmony_ci DMACtrl = 0x00, 528c2ecf20Sopenharmony_ci RxDMAStatus = 0x08, 538c2ecf20Sopenharmony_ci TFDListPtr0 = 0x10, 548c2ecf20Sopenharmony_ci TFDListPtr1 = 0x14, 558c2ecf20Sopenharmony_ci TxDMABurstThresh = 0x18, 568c2ecf20Sopenharmony_ci TxDMAUrgentThresh = 0x19, 578c2ecf20Sopenharmony_ci TxDMAPollPeriod = 0x1a, 588c2ecf20Sopenharmony_ci RFDListPtr0 = 0x1c, 598c2ecf20Sopenharmony_ci RFDListPtr1 = 0x20, 608c2ecf20Sopenharmony_ci RxDMABurstThresh = 0x24, 618c2ecf20Sopenharmony_ci RxDMAUrgentThresh = 0x25, 628c2ecf20Sopenharmony_ci RxDMAPollPeriod = 0x26, 638c2ecf20Sopenharmony_ci RxDMAIntCtrl = 0x28, 648c2ecf20Sopenharmony_ci DebugCtrl = 0x2c, 658c2ecf20Sopenharmony_ci ASICCtrl = 0x30, 668c2ecf20Sopenharmony_ci FifoCtrl = 0x38, 678c2ecf20Sopenharmony_ci RxEarlyThresh = 0x3a, 688c2ecf20Sopenharmony_ci FlowOffThresh = 0x3c, 698c2ecf20Sopenharmony_ci FlowOnThresh = 0x3e, 708c2ecf20Sopenharmony_ci TxStartThresh = 0x44, 718c2ecf20Sopenharmony_ci EepromData = 0x48, 728c2ecf20Sopenharmony_ci EepromCtrl = 0x4a, 738c2ecf20Sopenharmony_ci ExpromAddr = 0x4c, 748c2ecf20Sopenharmony_ci Exprodata = 0x50, 758c2ecf20Sopenharmony_ci WakeEvent = 0x51, 768c2ecf20Sopenharmony_ci CountDown = 0x54, 778c2ecf20Sopenharmony_ci IntStatusAck = 0x5a, 788c2ecf20Sopenharmony_ci IntEnable = 0x5c, 798c2ecf20Sopenharmony_ci IntStatus = 0x5e, 808c2ecf20Sopenharmony_ci TxStatus = 0x60, 818c2ecf20Sopenharmony_ci MACCtrl = 0x6c, 828c2ecf20Sopenharmony_ci VLANTag = 0x70, 838c2ecf20Sopenharmony_ci PhyCtrl = 0x76, 848c2ecf20Sopenharmony_ci StationAddr0 = 0x78, 858c2ecf20Sopenharmony_ci StationAddr1 = 0x7a, 868c2ecf20Sopenharmony_ci StationAddr2 = 0x7c, 878c2ecf20Sopenharmony_ci VLANId = 0x80, 888c2ecf20Sopenharmony_ci MaxFrameSize = 0x86, 898c2ecf20Sopenharmony_ci ReceiveMode = 0x88, 908c2ecf20Sopenharmony_ci HashTable0 = 0x8c, 918c2ecf20Sopenharmony_ci HashTable1 = 0x90, 928c2ecf20Sopenharmony_ci RmonStatMask = 0x98, 938c2ecf20Sopenharmony_ci StatMask = 0x9c, 948c2ecf20Sopenharmony_ci RxJumboFrames = 0xbc, 958c2ecf20Sopenharmony_ci TCPCheckSumErrors = 0xc0, 968c2ecf20Sopenharmony_ci IPCheckSumErrors = 0xc2, 978c2ecf20Sopenharmony_ci UDPCheckSumErrors = 0xc4, 988c2ecf20Sopenharmony_ci TxJumboFrames = 0xf4, 998c2ecf20Sopenharmony_ci /* Ethernet MIB statistic register offsets */ 1008c2ecf20Sopenharmony_ci OctetRcvOk = 0xa8, 1018c2ecf20Sopenharmony_ci McstOctetRcvOk = 0xac, 1028c2ecf20Sopenharmony_ci BcstOctetRcvOk = 0xb0, 1038c2ecf20Sopenharmony_ci FramesRcvOk = 0xb4, 1048c2ecf20Sopenharmony_ci McstFramesRcvdOk = 0xb8, 1058c2ecf20Sopenharmony_ci BcstFramesRcvdOk = 0xbe, 1068c2ecf20Sopenharmony_ci MacControlFramesRcvd = 0xc6, 1078c2ecf20Sopenharmony_ci FrameTooLongErrors = 0xc8, 1088c2ecf20Sopenharmony_ci InRangeLengthErrors = 0xca, 1098c2ecf20Sopenharmony_ci FramesCheckSeqErrors = 0xcc, 1108c2ecf20Sopenharmony_ci FramesLostRxErrors = 0xce, 1118c2ecf20Sopenharmony_ci OctetXmtOk = 0xd0, 1128c2ecf20Sopenharmony_ci McstOctetXmtOk = 0xd4, 1138c2ecf20Sopenharmony_ci BcstOctetXmtOk = 0xd8, 1148c2ecf20Sopenharmony_ci FramesXmtOk = 0xdc, 1158c2ecf20Sopenharmony_ci McstFramesXmtdOk = 0xe0, 1168c2ecf20Sopenharmony_ci FramesWDeferredXmt = 0xe4, 1178c2ecf20Sopenharmony_ci LateCollisions = 0xe8, 1188c2ecf20Sopenharmony_ci MultiColFrames = 0xec, 1198c2ecf20Sopenharmony_ci SingleColFrames = 0xf0, 1208c2ecf20Sopenharmony_ci BcstFramesXmtdOk = 0xf6, 1218c2ecf20Sopenharmony_ci CarrierSenseErrors = 0xf8, 1228c2ecf20Sopenharmony_ci MacControlFramesXmtd = 0xfa, 1238c2ecf20Sopenharmony_ci FramesAbortXSColls = 0xfc, 1248c2ecf20Sopenharmony_ci FramesWEXDeferal = 0xfe, 1258c2ecf20Sopenharmony_ci /* RMON statistic register offsets */ 1268c2ecf20Sopenharmony_ci EtherStatsCollisions = 0x100, 1278c2ecf20Sopenharmony_ci EtherStatsOctetsTransmit = 0x104, 1288c2ecf20Sopenharmony_ci EtherStatsPktsTransmit = 0x108, 1298c2ecf20Sopenharmony_ci EtherStatsPkts64OctetTransmit = 0x10c, 1308c2ecf20Sopenharmony_ci EtherStats65to127OctetsTransmit = 0x110, 1318c2ecf20Sopenharmony_ci EtherStatsPkts128to255OctetsTransmit = 0x114, 1328c2ecf20Sopenharmony_ci EtherStatsPkts256to511OctetsTransmit = 0x118, 1338c2ecf20Sopenharmony_ci EtherStatsPkts512to1023OctetsTransmit = 0x11c, 1348c2ecf20Sopenharmony_ci EtherStatsPkts1024to1518OctetsTransmit = 0x120, 1358c2ecf20Sopenharmony_ci EtherStatsCRCAlignErrors = 0x124, 1368c2ecf20Sopenharmony_ci EtherStatsUndersizePkts = 0x128, 1378c2ecf20Sopenharmony_ci EtherStatsFragments = 0x12c, 1388c2ecf20Sopenharmony_ci EtherStatsJabbers = 0x130, 1398c2ecf20Sopenharmony_ci EtherStatsOctets = 0x134, 1408c2ecf20Sopenharmony_ci EtherStatsPkts = 0x138, 1418c2ecf20Sopenharmony_ci EtherStats64Octets = 0x13c, 1428c2ecf20Sopenharmony_ci EtherStatsPkts65to127Octets = 0x140, 1438c2ecf20Sopenharmony_ci EtherStatsPkts128to255Octets = 0x144, 1448c2ecf20Sopenharmony_ci EtherStatsPkts256to511Octets = 0x148, 1458c2ecf20Sopenharmony_ci EtherStatsPkts512to1023Octets = 0x14c, 1468c2ecf20Sopenharmony_ci EtherStatsPkts1024to1518Octets = 0x150, 1478c2ecf20Sopenharmony_ci}; 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci/* Bits in the interrupt status/mask registers. */ 1508c2ecf20Sopenharmony_cienum IntStatus_bits { 1518c2ecf20Sopenharmony_ci InterruptStatus = 0x0001, 1528c2ecf20Sopenharmony_ci HostError = 0x0002, 1538c2ecf20Sopenharmony_ci MACCtrlFrame = 0x0008, 1548c2ecf20Sopenharmony_ci TxComplete = 0x0004, 1558c2ecf20Sopenharmony_ci RxComplete = 0x0010, 1568c2ecf20Sopenharmony_ci RxEarly = 0x0020, 1578c2ecf20Sopenharmony_ci IntRequested = 0x0040, 1588c2ecf20Sopenharmony_ci UpdateStats = 0x0080, 1598c2ecf20Sopenharmony_ci LinkEvent = 0x0100, 1608c2ecf20Sopenharmony_ci TxDMAComplete = 0x0200, 1618c2ecf20Sopenharmony_ci RxDMAComplete = 0x0400, 1628c2ecf20Sopenharmony_ci RFDListEnd = 0x0800, 1638c2ecf20Sopenharmony_ci RxDMAPriority = 0x1000, 1648c2ecf20Sopenharmony_ci}; 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ci/* Bits in the ReceiveMode register. */ 1678c2ecf20Sopenharmony_cienum ReceiveMode_bits { 1688c2ecf20Sopenharmony_ci ReceiveUnicast = 0x0001, 1698c2ecf20Sopenharmony_ci ReceiveMulticast = 0x0002, 1708c2ecf20Sopenharmony_ci ReceiveBroadcast = 0x0004, 1718c2ecf20Sopenharmony_ci ReceiveAllFrames = 0x0008, 1728c2ecf20Sopenharmony_ci ReceiveMulticastHash = 0x0010, 1738c2ecf20Sopenharmony_ci ReceiveIPMulticast = 0x0020, 1748c2ecf20Sopenharmony_ci ReceiveVLANMatch = 0x0100, 1758c2ecf20Sopenharmony_ci ReceiveVLANHash = 0x0200, 1768c2ecf20Sopenharmony_ci}; 1778c2ecf20Sopenharmony_ci/* Bits in MACCtrl. */ 1788c2ecf20Sopenharmony_cienum MACCtrl_bits { 1798c2ecf20Sopenharmony_ci DuplexSelect = 0x20, 1808c2ecf20Sopenharmony_ci TxFlowControlEnable = 0x80, 1818c2ecf20Sopenharmony_ci RxFlowControlEnable = 0x0100, 1828c2ecf20Sopenharmony_ci RcvFCS = 0x200, 1838c2ecf20Sopenharmony_ci AutoVLANtagging = 0x1000, 1848c2ecf20Sopenharmony_ci AutoVLANuntagging = 0x2000, 1858c2ecf20Sopenharmony_ci StatsEnable = 0x00200000, 1868c2ecf20Sopenharmony_ci StatsDisable = 0x00400000, 1878c2ecf20Sopenharmony_ci StatsEnabled = 0x00800000, 1888c2ecf20Sopenharmony_ci TxEnable = 0x01000000, 1898c2ecf20Sopenharmony_ci TxDisable = 0x02000000, 1908c2ecf20Sopenharmony_ci TxEnabled = 0x04000000, 1918c2ecf20Sopenharmony_ci RxEnable = 0x08000000, 1928c2ecf20Sopenharmony_ci RxDisable = 0x10000000, 1938c2ecf20Sopenharmony_ci RxEnabled = 0x20000000, 1948c2ecf20Sopenharmony_ci}; 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_cienum ASICCtrl_LoWord_bits { 1978c2ecf20Sopenharmony_ci PhyMedia = 0x0080, 1988c2ecf20Sopenharmony_ci}; 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_cienum ASICCtrl_HiWord_bits { 2018c2ecf20Sopenharmony_ci GlobalReset = 0x0001, 2028c2ecf20Sopenharmony_ci RxReset = 0x0002, 2038c2ecf20Sopenharmony_ci TxReset = 0x0004, 2048c2ecf20Sopenharmony_ci DMAReset = 0x0008, 2058c2ecf20Sopenharmony_ci FIFOReset = 0x0010, 2068c2ecf20Sopenharmony_ci NetworkReset = 0x0020, 2078c2ecf20Sopenharmony_ci HostReset = 0x0040, 2088c2ecf20Sopenharmony_ci ResetBusy = 0x0400, 2098c2ecf20Sopenharmony_ci}; 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci#define IPG_AC_LED_MODE BIT(14) 2128c2ecf20Sopenharmony_ci#define IPG_AC_LED_SPEED BIT(27) 2138c2ecf20Sopenharmony_ci#define IPG_AC_LED_MODE_BIT_1 BIT(29) 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci/* Transmit Frame Control bits */ 2168c2ecf20Sopenharmony_cienum TFC_bits { 2178c2ecf20Sopenharmony_ci DwordAlign = 0x00000000, 2188c2ecf20Sopenharmony_ci WordAlignDisable = 0x00030000, 2198c2ecf20Sopenharmony_ci WordAlign = 0x00020000, 2208c2ecf20Sopenharmony_ci TCPChecksumEnable = 0x00040000, 2218c2ecf20Sopenharmony_ci UDPChecksumEnable = 0x00080000, 2228c2ecf20Sopenharmony_ci IPChecksumEnable = 0x00100000, 2238c2ecf20Sopenharmony_ci FCSAppendDisable = 0x00200000, 2248c2ecf20Sopenharmony_ci TxIndicate = 0x00400000, 2258c2ecf20Sopenharmony_ci TxDMAIndicate = 0x00800000, 2268c2ecf20Sopenharmony_ci FragCountShift = 24, 2278c2ecf20Sopenharmony_ci VLANTagInsert = 0x0000000010000000, 2288c2ecf20Sopenharmony_ci TFDDone = 0x80000000, 2298c2ecf20Sopenharmony_ci VIDShift = 32, 2308c2ecf20Sopenharmony_ci UsePriorityShift = 48, 2318c2ecf20Sopenharmony_ci}; 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_ci/* Receive Frames Status bits */ 2348c2ecf20Sopenharmony_cienum RFS_bits { 2358c2ecf20Sopenharmony_ci RxFIFOOverrun = 0x00010000, 2368c2ecf20Sopenharmony_ci RxRuntFrame = 0x00020000, 2378c2ecf20Sopenharmony_ci RxAlignmentError = 0x00040000, 2388c2ecf20Sopenharmony_ci RxFCSError = 0x00080000, 2398c2ecf20Sopenharmony_ci RxOverSizedFrame = 0x00100000, 2408c2ecf20Sopenharmony_ci RxLengthError = 0x00200000, 2418c2ecf20Sopenharmony_ci VLANDetected = 0x00400000, 2428c2ecf20Sopenharmony_ci TCPDetected = 0x00800000, 2438c2ecf20Sopenharmony_ci TCPError = 0x01000000, 2448c2ecf20Sopenharmony_ci UDPDetected = 0x02000000, 2458c2ecf20Sopenharmony_ci UDPError = 0x04000000, 2468c2ecf20Sopenharmony_ci IPDetected = 0x08000000, 2478c2ecf20Sopenharmony_ci IPError = 0x10000000, 2488c2ecf20Sopenharmony_ci FrameStart = 0x20000000, 2498c2ecf20Sopenharmony_ci FrameEnd = 0x40000000, 2508c2ecf20Sopenharmony_ci RFDDone = 0x80000000, 2518c2ecf20Sopenharmony_ci TCIShift = 32, 2528c2ecf20Sopenharmony_ci RFS_Errors = 0x003f0000, 2538c2ecf20Sopenharmony_ci}; 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci#define MII_RESET_TIME_OUT 10000 2568c2ecf20Sopenharmony_ci/* MII register */ 2578c2ecf20Sopenharmony_cienum _mii_reg { 2588c2ecf20Sopenharmony_ci MII_PHY_SCR = 16, 2598c2ecf20Sopenharmony_ci}; 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci/* PCS register */ 2628c2ecf20Sopenharmony_cienum _pcs_reg { 2638c2ecf20Sopenharmony_ci PCS_BMCR = 0, 2648c2ecf20Sopenharmony_ci PCS_BMSR = 1, 2658c2ecf20Sopenharmony_ci PCS_ANAR = 4, 2668c2ecf20Sopenharmony_ci PCS_ANLPAR = 5, 2678c2ecf20Sopenharmony_ci PCS_ANER = 6, 2688c2ecf20Sopenharmony_ci PCS_ANNPT = 7, 2698c2ecf20Sopenharmony_ci PCS_ANLPRNP = 8, 2708c2ecf20Sopenharmony_ci PCS_ESR = 15, 2718c2ecf20Sopenharmony_ci}; 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci/* IEEE Extened Status Register */ 2748c2ecf20Sopenharmony_cienum _mii_esr { 2758c2ecf20Sopenharmony_ci MII_ESR_1000BX_FD = 0x8000, 2768c2ecf20Sopenharmony_ci MII_ESR_1000BX_HD = 0x4000, 2778c2ecf20Sopenharmony_ci MII_ESR_1000BT_FD = 0x2000, 2788c2ecf20Sopenharmony_ci MII_ESR_1000BT_HD = 0x1000, 2798c2ecf20Sopenharmony_ci}; 2808c2ecf20Sopenharmony_ci/* PHY Specific Control Register */ 2818c2ecf20Sopenharmony_ci#if 0 2828c2ecf20Sopenharmony_citypedef union t_MII_PHY_SCR { 2838c2ecf20Sopenharmony_ci u16 image; 2848c2ecf20Sopenharmony_ci struct { 2858c2ecf20Sopenharmony_ci u16 disable_jabber:1; // bit 0 2868c2ecf20Sopenharmony_ci u16 polarity_reversal:1; // bit 1 2878c2ecf20Sopenharmony_ci u16 SEQ_test:1; // bit 2 2888c2ecf20Sopenharmony_ci u16 _bit_3:1; // bit 3 2898c2ecf20Sopenharmony_ci u16 disable_CLK125:1; // bit 4 2908c2ecf20Sopenharmony_ci u16 mdi_crossover_mode:2; // bit 6:5 2918c2ecf20Sopenharmony_ci u16 enable_ext_dist:1; // bit 7 2928c2ecf20Sopenharmony_ci u16 _bit_8_9:2; // bit 9:8 2938c2ecf20Sopenharmony_ci u16 force_link:1; // bit 10 2948c2ecf20Sopenharmony_ci u16 assert_CRS:1; // bit 11 2958c2ecf20Sopenharmony_ci u16 rcv_fifo_depth:2; // bit 13:12 2968c2ecf20Sopenharmony_ci u16 xmit_fifo_depth:2; // bit 15:14 2978c2ecf20Sopenharmony_ci } bits; 2988c2ecf20Sopenharmony_ci} PHY_SCR_t, *PPHY_SCR_t; 2998c2ecf20Sopenharmony_ci#endif 3008c2ecf20Sopenharmony_ci 3018c2ecf20Sopenharmony_citypedef enum t_MII_ADMIN_STATUS { 3028c2ecf20Sopenharmony_ci adm_reset, 3038c2ecf20Sopenharmony_ci adm_operational, 3048c2ecf20Sopenharmony_ci adm_loopback, 3058c2ecf20Sopenharmony_ci adm_power_down, 3068c2ecf20Sopenharmony_ci adm_isolate 3078c2ecf20Sopenharmony_ci} MII_ADMIN_t, *PMII_ADMIN_t; 3088c2ecf20Sopenharmony_ci 3098c2ecf20Sopenharmony_ci/* Physical Coding Sublayer Management (PCS) */ 3108c2ecf20Sopenharmony_ci/* PCS control and status registers bitmap as the same as MII */ 3118c2ecf20Sopenharmony_ci/* PCS Extended Status register bitmap as the same as MII */ 3128c2ecf20Sopenharmony_ci/* PCS ANAR */ 3138c2ecf20Sopenharmony_cienum _pcs_anar { 3148c2ecf20Sopenharmony_ci PCS_ANAR_NEXT_PAGE = 0x8000, 3158c2ecf20Sopenharmony_ci PCS_ANAR_REMOTE_FAULT = 0x3000, 3168c2ecf20Sopenharmony_ci PCS_ANAR_ASYMMETRIC = 0x0100, 3178c2ecf20Sopenharmony_ci PCS_ANAR_PAUSE = 0x0080, 3188c2ecf20Sopenharmony_ci PCS_ANAR_HALF_DUPLEX = 0x0040, 3198c2ecf20Sopenharmony_ci PCS_ANAR_FULL_DUPLEX = 0x0020, 3208c2ecf20Sopenharmony_ci}; 3218c2ecf20Sopenharmony_ci/* PCS ANLPAR */ 3228c2ecf20Sopenharmony_cienum _pcs_anlpar { 3238c2ecf20Sopenharmony_ci PCS_ANLPAR_NEXT_PAGE = PCS_ANAR_NEXT_PAGE, 3248c2ecf20Sopenharmony_ci PCS_ANLPAR_REMOTE_FAULT = PCS_ANAR_REMOTE_FAULT, 3258c2ecf20Sopenharmony_ci PCS_ANLPAR_ASYMMETRIC = PCS_ANAR_ASYMMETRIC, 3268c2ecf20Sopenharmony_ci PCS_ANLPAR_PAUSE = PCS_ANAR_PAUSE, 3278c2ecf20Sopenharmony_ci PCS_ANLPAR_HALF_DUPLEX = PCS_ANAR_HALF_DUPLEX, 3288c2ecf20Sopenharmony_ci PCS_ANLPAR_FULL_DUPLEX = PCS_ANAR_FULL_DUPLEX, 3298c2ecf20Sopenharmony_ci}; 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_citypedef struct t_SROM { 3328c2ecf20Sopenharmony_ci u16 config_param; /* 0x00 */ 3338c2ecf20Sopenharmony_ci u16 asic_ctrl; /* 0x02 */ 3348c2ecf20Sopenharmony_ci u16 sub_vendor_id; /* 0x04 */ 3358c2ecf20Sopenharmony_ci u16 sub_system_id; /* 0x06 */ 3368c2ecf20Sopenharmony_ci u16 pci_base_1; /* 0x08 (IP1000A only) */ 3378c2ecf20Sopenharmony_ci u16 pci_base_2; /* 0x0a (IP1000A only) */ 3388c2ecf20Sopenharmony_ci u16 led_mode; /* 0x0c (IP1000A only) */ 3398c2ecf20Sopenharmony_ci u16 reserved1[9]; /* 0x0e-0x1f */ 3408c2ecf20Sopenharmony_ci u8 mac_addr[6]; /* 0x20-0x25 */ 3418c2ecf20Sopenharmony_ci u8 reserved2[10]; /* 0x26-0x2f */ 3428c2ecf20Sopenharmony_ci u8 sib[204]; /* 0x30-0xfb */ 3438c2ecf20Sopenharmony_ci u32 crc; /* 0xfc-0xff */ 3448c2ecf20Sopenharmony_ci} SROM_t, *PSROM_t; 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_ci/* Ioctl custom data */ 3478c2ecf20Sopenharmony_cistruct ioctl_data { 3488c2ecf20Sopenharmony_ci char signature[10]; 3498c2ecf20Sopenharmony_ci int cmd; 3508c2ecf20Sopenharmony_ci int len; 3518c2ecf20Sopenharmony_ci char *data; 3528c2ecf20Sopenharmony_ci}; 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_ci/* The Rx and Tx buffer descriptors. */ 3558c2ecf20Sopenharmony_cistruct netdev_desc { 3568c2ecf20Sopenharmony_ci __le64 next_desc; 3578c2ecf20Sopenharmony_ci __le64 status; 3588c2ecf20Sopenharmony_ci __le64 fraginfo; 3598c2ecf20Sopenharmony_ci}; 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_ci#define PRIV_ALIGN 15 /* Required alignment mask */ 3628c2ecf20Sopenharmony_ci/* Use __attribute__((aligned (L1_CACHE_BYTES))) to maintain alignment 3638c2ecf20Sopenharmony_ci within the structure. */ 3648c2ecf20Sopenharmony_cistruct netdev_private { 3658c2ecf20Sopenharmony_ci /* Descriptor rings first for alignment. */ 3668c2ecf20Sopenharmony_ci struct netdev_desc *rx_ring; 3678c2ecf20Sopenharmony_ci struct netdev_desc *tx_ring; 3688c2ecf20Sopenharmony_ci struct sk_buff *rx_skbuff[RX_RING_SIZE]; 3698c2ecf20Sopenharmony_ci struct sk_buff *tx_skbuff[TX_RING_SIZE]; 3708c2ecf20Sopenharmony_ci dma_addr_t tx_ring_dma; 3718c2ecf20Sopenharmony_ci dma_addr_t rx_ring_dma; 3728c2ecf20Sopenharmony_ci struct pci_dev *pdev; 3738c2ecf20Sopenharmony_ci void __iomem *ioaddr; 3748c2ecf20Sopenharmony_ci void __iomem *eeprom_addr; 3758c2ecf20Sopenharmony_ci spinlock_t tx_lock; 3768c2ecf20Sopenharmony_ci spinlock_t rx_lock; 3778c2ecf20Sopenharmony_ci unsigned int rx_buf_sz; /* Based on MTU+slack. */ 3788c2ecf20Sopenharmony_ci unsigned int speed; /* Operating speed */ 3798c2ecf20Sopenharmony_ci unsigned int vlan; /* VLAN Id */ 3808c2ecf20Sopenharmony_ci unsigned int chip_id; /* PCI table chip id */ 3818c2ecf20Sopenharmony_ci unsigned int rx_coalesce; /* Maximum frames each RxDMAComplete intr */ 3828c2ecf20Sopenharmony_ci unsigned int rx_timeout; /* Wait time between RxDMAComplete intr */ 3838c2ecf20Sopenharmony_ci unsigned int tx_coalesce; /* Maximum frames each tx interrupt */ 3848c2ecf20Sopenharmony_ci unsigned int full_duplex:1; /* Full-duplex operation requested. */ 3858c2ecf20Sopenharmony_ci unsigned int an_enable:2; /* Auto-Negotiated Enable */ 3868c2ecf20Sopenharmony_ci unsigned int jumbo:1; /* Jumbo frame enable */ 3878c2ecf20Sopenharmony_ci unsigned int coalesce:1; /* Rx coalescing enable */ 3888c2ecf20Sopenharmony_ci unsigned int tx_flow:1; /* Tx flow control enable */ 3898c2ecf20Sopenharmony_ci unsigned int rx_flow:1; /* Rx flow control enable */ 3908c2ecf20Sopenharmony_ci unsigned int phy_media:1; /* 1: fiber, 0: copper */ 3918c2ecf20Sopenharmony_ci unsigned int link_status:1; /* Current link status */ 3928c2ecf20Sopenharmony_ci struct netdev_desc *last_tx; /* Last Tx descriptor used. */ 3938c2ecf20Sopenharmony_ci unsigned long cur_rx, old_rx; /* Producer/consumer ring indices */ 3948c2ecf20Sopenharmony_ci unsigned long cur_tx, old_tx; 3958c2ecf20Sopenharmony_ci struct timer_list timer; 3968c2ecf20Sopenharmony_ci int wake_polarity; 3978c2ecf20Sopenharmony_ci char name[256]; /* net device description */ 3988c2ecf20Sopenharmony_ci u8 duplex_polarity; 3998c2ecf20Sopenharmony_ci u16 mcast_filter[4]; 4008c2ecf20Sopenharmony_ci u16 advertising; /* NWay media advertisement */ 4018c2ecf20Sopenharmony_ci u16 negotiate; /* Negotiated media */ 4028c2ecf20Sopenharmony_ci int phy_addr; /* PHY addresses. */ 4038c2ecf20Sopenharmony_ci u16 led_mode; /* LED mode read from EEPROM (IP1000A only) */ 4048c2ecf20Sopenharmony_ci}; 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_ci/* The station address location in the EEPROM. */ 4078c2ecf20Sopenharmony_ci/* The struct pci_device_id consist of: 4088c2ecf20Sopenharmony_ci vendor, device Vendor and device ID to match (or PCI_ANY_ID) 4098c2ecf20Sopenharmony_ci subvendor, subdevice Subsystem vendor and device ID to match (or PCI_ANY_ID) 4108c2ecf20Sopenharmony_ci class Device class to match. The class_mask tells which bits 4118c2ecf20Sopenharmony_ci class_mask of the class are honored during the comparison. 4128c2ecf20Sopenharmony_ci driver_data Data private to the driver. 4138c2ecf20Sopenharmony_ci*/ 4148c2ecf20Sopenharmony_ci#define CHIP_IP1000A 1 4158c2ecf20Sopenharmony_ci 4168c2ecf20Sopenharmony_cistatic const struct pci_device_id rio_pci_tbl[] = { 4178c2ecf20Sopenharmony_ci {0x1186, 0x4000, PCI_ANY_ID, PCI_ANY_ID, }, 4188c2ecf20Sopenharmony_ci {0x13f0, 0x1021, PCI_ANY_ID, PCI_ANY_ID, }, 4198c2ecf20Sopenharmony_ci { PCI_VDEVICE(SUNDANCE, 0x1023), CHIP_IP1000A }, 4208c2ecf20Sopenharmony_ci { PCI_VDEVICE(SUNDANCE, 0x2021), CHIP_IP1000A }, 4218c2ecf20Sopenharmony_ci { PCI_VDEVICE(DLINK, 0x9021), CHIP_IP1000A }, 4228c2ecf20Sopenharmony_ci { PCI_VDEVICE(DLINK, 0x4020), CHIP_IP1000A }, 4238c2ecf20Sopenharmony_ci { } 4248c2ecf20Sopenharmony_ci}; 4258c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE (pci, rio_pci_tbl); 4268c2ecf20Sopenharmony_ci#define TX_TIMEOUT (4*HZ) 4278c2ecf20Sopenharmony_ci#define PACKET_SIZE 1536 4288c2ecf20Sopenharmony_ci#define MAX_JUMBO 8000 4298c2ecf20Sopenharmony_ci#define RIO_IO_SIZE 340 4308c2ecf20Sopenharmony_ci#define DEFAULT_RXC 5 4318c2ecf20Sopenharmony_ci#define DEFAULT_RXT 750 4328c2ecf20Sopenharmony_ci#define DEFAULT_TXC 1 4338c2ecf20Sopenharmony_ci#define MAX_TXC 8 4348c2ecf20Sopenharmony_ci#endif /* __DL2K_H__ */ 435