📄 r8168.h
字号:
#endif#ifndef ETHTOOL_BUSINFO_LEN#define ETHTOOL_BUSINFO_LEN 32#endif/*****************************************************************************/enum RTL8168_DSM_STATE { DSM_MAC_INIT = 1, DSM_NIC_GOTO_D3 = 2, DSM_IF_DOWN = 3, DSM_NIC_RESUME_D3 = 4, DSM_IF_UP = 5,};enum RTL8168_registers { MAC0 = 0, /* Ethernet hardware address. */ MAC4 = 0x04, MAR0 = 8, /* Multicast filter. */ CounterAddrLow = 0x10, CounterAddrHigh = 0x14, TxDescStartAddrLow = 0x20, TxDescStartAddrHigh = 0x24, TxHDescStartAddrLow = 0x28, TxHDescStartAddrHigh = 0x2c, FLASH = 0x30, ERSR = 0x36, ChipCmd = 0x37, TxPoll = 0x38, IntrMask = 0x3C, IntrStatus = 0x3E, TxConfig = 0x40, RxConfig = 0x44, TCTR = 0x48, Cfg9346 = 0x50, Config0 = 0x51, Config1 = 0x52, Config2 = 0x53, Config3 = 0x54, Config4 = 0x55, Config5 = 0x56, TimeIntr = 0x58, PHYAR = 0x60, CSIDR = 0x64, CSIAR = 0x68, PHYstatus = 0x6C, MACDBG = 0x6D, GPIO = 0x6E, EPHYAR = 0x80, DBG_reg = 0xD1, RxMaxSize = 0xDA, CPlusCmd = 0xE0, IntrMitigate = 0xE2, RxDescAddrLow = 0xE4, RxDescAddrHigh = 0xE8, Reserved1 = 0xEC, FuncEvent = 0xF0, FuncEventMask = 0xF4, FuncPresetState = 0xF8, FuncForceEvent = 0xFC,};enum RTL8168_register_content { /* InterruptStatusBits */ SYSErr = 0x8000, PCSTimeout = 0x4000, SWInt = 0x0100, TxDescUnavail = 0x0080, RxFIFOOver = 0x0040, LinkChg = 0x0020, RxDescUnavail = 0x0010, TxErr = 0x0008, TxOK = 0x0004, RxErr = 0x0002, RxOK = 0x0001, /* RxStatusDesc */ RxRWT = (1 << 22), RxRES = (1 << 21), RxRUNT = (1 << 20), RxCRC = (1 << 19), /* ChipCmdBits */ StopReq = 0x80, CmdReset = 0x10, CmdRxEnb = 0x08, CmdTxEnb = 0x04, RxBufEmpty = 0x01, /* Cfg9346Bits */ Cfg9346_Lock = 0x00, Cfg9346_Unlock = 0xC0, /* rx_mode_bits */ AcceptErr = 0x20, AcceptRunt = 0x10, AcceptBroadcast = 0x08, AcceptMulticast = 0x04, AcceptMyPhys = 0x02, AcceptAllPhys = 0x01, /* Transmit Priority Polling*/ HPQ = 0x80, NPQ = 0x40, FSWInt = 0x01, /* RxConfigBits */ Reserved2_shift = 13, RxCfgDMAShift = 8, RxCfg_128_int_en = (1 << 15), RxCfg_fet_multi_en = (1 << 14), RxCfg_half_refetch = (1 << 13), /* TxConfigBits */ TxInterFrameGapShift = 24, TxDMAShift = 8, /* DMA burst value (0-7) is shift this many bits */ TxMACLoopBack = (1 << 17), /* MAC loopback */ /* Config1 register p.24 */ LEDS1 = (1 << 7), LEDS0 = (1 << 6), Speed_down = (1 << 4), MEMMAP = (1 << 3), IOMAP = (1 << 2), VPD = (1 << 1), PMEnable = (1 << 0), /* Power Management Enable */ /* Config3 register */ MagicPacket = (1 << 5), /* Wake up when receives a Magic Packet */ LinkUp = (1 << 4), /* This bit is reserved in RTL8168B.*/ /* Wake up when the cable connection is re-established */ ECRCEN = (1 << 3), /* This bit is reserved in RTL8168B*/ Jumbo_En0 = (1 << 2), /* This bit is reserved in RTL8168B*/ RDY_TO_L23 = (1 << 1), /* This bit is reserved in RTL8168B*/ Beacon_en = (1 << 0), /* This bit is reserved in RTL8168B*/ /* Config4 register */ Jumbo_En1 = (1 << 1), /* This bit is reserved in RTL8168B*/ /* Config5 register */ BWF = (1 << 6), /* Accept Broadcast wakeup frame */ MWF = (1 << 5), /* Accept Multicast wakeup frame */ UWF = (1 << 4), /* Accept Unicast wakeup frame */ LanWake = (1 << 1), /* LanWake enable/disable */ PMEStatus = (1 << 0), /* PME status can be reset by PCI RST# */ /* CPlusCmd */ EnableBist = (1 << 15), Macdbgo_oe = (1 << 14), Normal_mode = (1 << 13), Force_halfdup = (1 << 12), Force_rxflow_en = (1 << 11), Force_txflow_en = (1 << 10), Cxpl_dbg_sel = (1 << 9),//This bit is reserved in RTL8168B ASF = (1 << 8),//This bit is reserved in RTL8168C PktCntrDisable = (1 << 7), RxVlan = (1 << 6), RxChkSum = (1 << 5), Macdbgo_sel = 0x001C, INTT_0 = 0x0000, INTT_1 = 0x0001, INTT_2 = 0x0002, INTT_3 = 0x0003, /* rtl8168_PHYstatus */ TxFlowCtrl = 0x40, RxFlowCtrl = 0x20, _1000bpsF = 0x10, _100bps = 0x08, _10bps = 0x04, LinkStatus = 0x02, FullDup = 0x01, /* DBG_reg */ Fix_Nak_1 = (1 << 4), Fix_Nak_2 = (1 << 3), DBGPIN_E2 = (1 << 0), /* DumpCounterCommand */ CounterDump = 0x8, /* PHY access */ PHYAR_Flag = 0x80000000, PHYAR_Write = 0x80000000, PHYAR_Read = 0x00000000, PHYAR_Reg_Mask = 0x1f, PHYAR_Reg_shift = 16, PHYAR_Data_Mask = 0xffff, /* EPHY access */ EPHYAR_Flag = 0x80000000, EPHYAR_Write = 0x80000000, EPHYAR_Read = 0x00000000, EPHYAR_Reg_Mask = 0x1f, EPHYAR_Reg_shift = 16, EPHYAR_Data_Mask = 0xffff, /* CSI access */ CSIAR_Flag = 0x80000000, CSIAR_Write = 0x80000000, CSIAR_Read = 0x00000000, CSIAR_ByteEn = 0x0f, CSIAR_ByteEn_shift = 12, CSIAR_Addr_Mask = 0x0fff, /* GPIO */ GPIO_en = (1 << 0), };enum _DescStatusBit { DescOwn = (1 << 31), /* Descriptor is owned by NIC */ RingEnd = (1 << 30), /* End of descriptor ring */ FirstFrag = (1 << 29), /* First segment of a packet */ LastFrag = (1 << 28), /* Final segment of a packet */ /* Tx private */ /*------ offset 0 of tx descriptor ------*/ LargeSend = (1 << 27), /* TCP Large Send Offload (TSO) */ MSSShift = 16, /* MSS value position */ MSSMask = 0xfff, /* MSS value + LargeSend bit: 12 bits */ TxIPCS = (1 << 18), /* Calculate IP checksum */ TxUDPCS = (1 << 17), /* Calculate UDP/IP checksum */ TxTCPCS = (1 << 16), /* Calculate TCP/IP checksum */ TxVlanTag = (1 << 17), /* Add VLAN tag */ /*@@@@@@ offset 4 of tx descriptor => bits for RTL8168C/CP only begin @@@@@@*/ TxUDPCS_C = (1 << 31), /* Calculate UDP/IP checksum */ TxTCPCS_C = (1 << 30), /* Calculate TCP/IP checksum */ TxIPCS_C = (1 << 29), /* Calculate IP checksum */ /*@@@@@@ offset 4 of tx descriptor => bits for RTL8168C/CP only end @@@@@@*/ /* Rx private */ /*------ offset 0 of rx descriptor ------*/ PID1 = (1 << 18), /* Protocol ID bit 1/2 */ PID0 = (1 << 17), /* Protocol ID bit 2/2 */#define RxProtoUDP (PID1)#define RxProtoTCP (PID0)#define RxProtoIP (PID1 | PID0)#define RxProtoMask RxProtoIP RxIPF = (1 << 16), /* IP checksum failed */ RxUDPF = (1 << 15), /* UDP/IP checksum failed */ RxTCPF = (1 << 14), /* TCP/IP checksum failed */ RxVlanTag = (1 << 16), /* VLAN tag available */ /*@@@@@@ offset 0 of rx descriptor => bits for RTL8168C/CP only begin @@@@@@*/ RxUDPT = (1 << 18), RxTCPT = (1 << 17), /*@@@@@@ offset 0 of rx descriptor => bits for RTL8168C/CP only end @@@@@@*/ /*@@@@@@ offset 4 of rx descriptor => bits for RTL8168C/CP only begin @@@@@@*/ RxV6F = (1 << 31), RxV4F = (1 << 30), /*@@@@@@ offset 4 of rx descriptor => bits for RTL8168C/CP only end @@@@@@*/};enum features {// RTL_FEATURE_WOL = (1 << 0), RTL_FEATURE_MSI = (1 << 1),};#define RsvdMask 0x3fffc000struct TxDesc { u32 opts1; u32 opts2; u64 addr;};struct RxDesc { u32 opts1; u32 opts2; u64 addr;};struct ring_info { struct sk_buff *skb; u32 len; u8 __pad[sizeof(void *) - sizeof(u32)];};struct pci_resource { u8 cmd; u8 cls; u16 io_base_h; u16 io_base_l; u16 mem_base_h; u16 mem_base_l; u8 ilr; u16 resv_0x20_h; u16 resv_0x20_l; u16 resv_0x24_h; u16 resv_0x24_l;};struct rtl8168_private { void __iomem *mmio_addr; /* memory map physical address */ struct pci_dev *pci_dev; /* Index of PCI device */ struct net_device *dev;#ifdef CONFIG_R8168_NAPI #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) struct napi_struct napi; #endif#endif struct net_device_stats stats; /* statistics of net device */ spinlock_t lock; /* spin lock flag */ spinlock_t phy_lock; /* spin lock flag for GPHY */ u32 msg_enable; u32 tx_tcp_csum_cmd; u32 tx_udp_csum_cmd; u32 tx_ip_csum_cmd; int max_jumbo_frame_size; int chipset; int mcfg; u32 cur_rx; /* Index into the Rx descriptor buffer of next Rx pkt. */ u32 cur_tx; /* Index into the Tx descriptor buffer of next Rx pkt. */ u32 dirty_rx; u32 dirty_tx; struct TxDesc *TxDescArray; /* 256-aligned Tx descriptor ring */ struct RxDesc *RxDescArray; /* 256-aligned Rx descriptor ring */ dma_addr_t TxPhyAddr; dma_addr_t RxPhyAddr; struct sk_buff *Rx_skbuff[NUM_RX_DESC]; /* Rx data buffers */ struct ring_info tx_skb[NUM_TX_DESC]; /* Tx data buffers */ unsigned rx_buf_sz; int rx_fifo_overflow; struct timer_list esd_timer; struct pci_resource pci_cfg_space; unsigned int esd_flag; unsigned int pci_cfg_is_read; unsigned int rtl8168_rx_config; u16 cp_cmd; u16 intr_mask; int phy_auto_nego_reg; int phy_1000_ctrl_reg; u8 mac_addr[NODE_ADDRESS_SIZE];#ifdef CONFIG_R8168_VLAN struct vlan_group *vlgrp;#endif u8 autoneg; u16 speed; u8 duplex; int (*set_speed)(struct net_device *, u8 autoneg, u16 speed, u8 duplex); void (*get_settings)(struct net_device *, struct ethtool_cmd *); void (*phy_reset_enable)(struct net_device *); unsigned int (*phy_reset_pending)(struct net_device *); unsigned int (*link_ok)(struct net_device *);#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) struct work_struct task;#else struct delayed_work task;#endif unsigned wol_enabled; unsigned features;};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -