#define TI_MISC_HOST_CTL 0x040
#define TI_MISC_LOCAL_CTL 0x044
#define TI_SEM_AB 0x048
#define TI_MISC_CONF 0x050
#define TI_TIMER_BITS 0x054
#define TI_TIMERREF 0x058
#define TI_PCI_STATE 0x05C
#define TI_MAIN_EVENT_A 0x060
#define TI_MAILBOX_EVENT_A 0x064
#define TI_WINBASE 0x068
#define TI_WINDATA 0x06C
#define TI_MAIN_EVENT_B 0x070
#define TI_MAILBOX_EVENT_B 0x074
#define TI_TIMERREF_B 0x078
#define TI_SERIAL 0x07C
#define TI_MHC_INTSTATE 0x00000001
#define TI_MHC_CLEARINT 0x00000002
#define TI_MHC_RESET 0x00000008
#define TI_MHC_BYTE_SWAP_ENB 0x00000010
#define TI_MHC_WORD_SWAP_ENB 0x00000020
#define TI_MHC_MASK_INTS 0x00000040
#define TI_MHC_CHIP_REV_MASK 0xF0000000
#define TI_MHC_BIGENDIAN_INIT \
(TI_MHC_BYTE_SWAP_ENB|TI_MHC_WORD_SWAP_ENB|TI_MHC_CLEARINT)
#define TI_MHC_LITTLEENDIAN_INIT \
(TI_MHC_WORD_SWAP_ENB|TI_MHC_CLEARINT)
#define TI_REV_TIGON_I 0x40000000
#define TI_REV_TIGON_II 0x60000000
#define TI_FIRMWARE_MAJOR 0xc
#define TI_FIRMWARE_MINOR 0x4
#define TI_FIRMWARE_FIX 0xd
#define TI_MLC_EE_WRITE_ENB 0x00000010
#define TI_MLC_SRAM_BANK_256K 0x00000200
#define TI_MLC_SRAM_BANK_SIZE 0x00000300
#define TI_MLC_LOCALADDR_21 0x00004000
#define TI_MLC_LOCALADDR_22 0x00008000
#define TI_MLC_SBUS_WRITEERR 0x00080000
#define TI_MLC_EE_CLK 0x00100000
#define TI_MLC_EE_TXEN 0x00200000
#define TI_MLC_EE_DOUT 0x00400000
#define TI_MLC_EE_DIN 0x00800000
#define TI_EE_MAC_OFFSET 0x8c
#define TI_DMA_ASSIST 0x11C
#define TI_CPU_STATE 0x140
#define TI_CPU_PROGRAM_COUNTER 0x144
#define TI_SRAM_ADDR 0x154
#define TI_SRAM_DATA 0x158
#define TI_GEN_0 0x180
#define TI_GEN_X 0x1FC
#define TI_MAC_TX_STATE 0x200
#define TI_MAC_RX_STATE 0x220
#define TI_CPU_CTL_B 0x240
#define TI_CPU_PROGRAM_COUNTER_B 0x244
#define TI_SRAM_ADDR_B 0x254
#define TI_SRAM_DATA_B 0x258
#define TI_GEN_B_0 0x280
#define TI_GEN_B_X 0x2FC
#define TI_MCR_SRAM_SYNCHRONOUS 0x00100000
#define TI_PCISTATE_FORCE_RESET 0x00000001
#define TI_PCISTATE_PROVIDE_LEN 0x00000002
#define TI_PCISTATE_READ_MAXDMA 0x0000001C
#define TI_PCISTATE_WRITE_MAXDMA 0x000000E0
#define TI_PCISTATE_MINDMA 0x0000FF00
#define TI_PCISTATE_FIFO_RETRY_ENB 0x00010000
#define TI_PCISTATE_USE_MEM_RD_MULT 0x00020000
#define TI_PCISTATE_NO_SWAP_READ_DMA 0x00040000
#define TI_PCISTATE_NO_SWAP_WRITE_DMA 0x00080000
#define TI_PCISTATE_66MHZ_BUS 0x00080000
#define TI_PCISTATE_32BIT_BUS 0x00100000
#define TI_PCISTATE_ENB_BYTE_ENABLES 0x00800000
#define TI_PCISTATE_READ_CMD 0x0F000000
#define TI_PCISTATE_WRITE_CMD 0xF0000000
#define TI_PCI_READMAX_4 0x04
#define TI_PCI_READMAX_16 0x08
#define TI_PCI_READMAX_32 0x0C
#define TI_PCI_READMAX_64 0x10
#define TI_PCI_READMAX_128 0x14
#define TI_PCI_READMAX_256 0x18
#define TI_PCI_READMAX_1024 0x1C
#define TI_PCI_WRITEMAX_4 0x20
#define TI_PCI_WRITEMAX_16 0x40
#define TI_PCI_WRITEMAX_32 0x60
#define TI_PCI_WRITEMAX_64 0x80
#define TI_PCI_WRITEMAX_128 0xA0
#define TI_PCI_WRITEMAX_256 0xC0
#define TI_PCI_WRITEMAX_1024 0xE0
#define TI_PCI_READ_CMD 0x06000000
#define TI_PCI_WRITE_CMD 0x70000000
#define TI_DMASTATE_ENABLE 0x00000001
#define TI_DMASTATE_PAUSE 0x00000002
#define TI_CPUSTATE_RESET 0x00000001
#define TI_CPUSTATE_STEP 0x00000002
#define TI_CPUSTATE_ROMFAIL 0x00000010
#define TI_CPUSTATE_HALT 0x00010000
#define TI_TXSTATE_RESET 0x00000001
#define TI_TXSTATE_ENB 0x00000002
#define TI_TXSTATE_STOP 0x00000004
#define TI_RXSTATE_RESET 0x00000001
#define TI_RXSTATE_ENB 0x00000002
#define TI_RXSTATE_STOP 0x00000004
#define TI_MB_HOSTINTR_HI 0x500
#define TI_MB_HOSTINTR_LO 0x504
#define TI_MB_HOSTINTR TI_MB_HOSTINTR_LO
#define TI_MB_CMDPROD_IDX_HI 0x508
#define TI_MB_CMDPROD_IDX_LO 0x50C
#define TI_MB_CMDPROD_IDX TI_MB_CMDPROD_IDX_LO
#define TI_MB_SENDPROD_IDX_HI 0x510
#define TI_MB_SENDPROD_IDX_LO 0x514
#define TI_MB_SENDPROD_IDX TI_MB_SENDPROD_IDX_LO
#define TI_MB_STDRXPROD_IDX_HI 0x518
#define TI_MB_STDRXPROD_IDX_LO 0x51C
#define TI_MB_STDRXPROD_IDX TI_MB_STDRXPROD_IDX_LO
#define TI_MB_JUMBORXPROD_IDX_HI 0x520
#define TI_MB_JUMBORXPROD_IDX_LO 0x524
#define TI_MB_JUMBORXPROD_IDX TI_MB_JUMBORXPROD_IDX_LO
#define TI_MB_MINIRXPROD_IDX_HI 0x528
#define TI_MB_MINIRXPROD_IDX_LO 0x52C
#define TI_MB_MINIRXPROD_IDX TI_MB_MINIRXPROD_IDX_LO
#define TI_MB_RSVD 0x530
#define TI_GCR_BASE 0x600
#define TI_GCR_MACADDR 0x600
#define TI_GCR_PAR0 0x600
#define TI_GCR_PAR1 0x604
#define TI_GCR_GENINFO_HI 0x608
#define TI_GCR_GENINFO_LO 0x60C
#define TI_GCR_MCASTADDR 0x610
#define TI_GCR_MAR0 0x610
#define TI_GCR_MAR1 0x614
#define TI_GCR_OPMODE 0x618
#define TI_GCR_DMA_READCFG 0x61C
#define TI_GCR_DMA_WRITECFG 0x620
#define TI_GCR_TX_BUFFER_RATIO 0x624
#define TI_GCR_EVENTCONS_IDX 0x628
#define TI_GCR_CMDCONS_IDX 0x62C
#define TI_GCR_TUNEPARMS 0x630
#define TI_GCR_RX_COAL_TICKS 0x630
#define TI_GCR_TX_COAL_TICKS 0x634
#define TI_GCR_STAT_TICKS 0x638
#define TI_GCR_TX_MAX_COAL_BD 0x63C
#define TI_GCR_RX_MAX_COAL_BD 0x640
#define TI_GCR_NIC_TRACING 0x644
#define TI_GCR_GLINK 0x648
#define TI_GCR_LINK 0x64C
#define TI_GCR_NICTRACE_PTR 0x650
#define TI_GCR_NICTRACE_START 0x654
#define TI_GCR_NICTRACE_LEN 0x658
#define TI_GCR_IFINDEX 0x65C
#define TI_GCR_IFMTU 0x660
#define TI_GCR_MASK_INTRS 0x664
#define TI_GCR_GLINK_STAT 0x668
#define TI_GCR_LINK_STAT 0x66C
#define TI_GCR_RXRETURNCONS_IDX 0x680
#define TI_GCR_CMDRING 0x700
#define TI_GCR_NIC_ADDR(x) (x - TI_GCR_BASE);
#define TI_WINDOW 0x800
#define TI_WINLEN 0x800
#define TI_TICKS_PER_SEC 1000000
#define TI_OPMODE_BYTESWAP_BD 0x00000002
#define TI_OPMODE_WORDSWAP_BD 0x00000004
#define TI_OPMODE_WARN_ENB 0x00000008
#define TI_OPMODE_BYTESWAP_DATA 0x00000010
#define TI_OPMODE_1_DMA_ACTIVE 0x00000040
#define TI_OPMODE_SBUS 0x00000100
#define TI_OPMODE_DONT_FRAG_JUMBO 0x00000200
#define TI_OPMODE_INCLUDE_CRC 0x00000400
#define TI_OPMODE_RX_BADFRAMES 0x00000800
#define TI_OPMODE_NO_EVENT_INTRS 0x00001000
#define TI_OPMODE_NO_TX_INTRS 0x00002000
#define TI_OPMODE_NO_RX_INTRS 0x00004000
#define TI_OPMODE_FATAL_ENB 0x40000000
#define TI_DMA_STATE_THRESH_16W 0x00000100
#define TI_DMA_STATE_THRESH_8W 0x00000080
#define TI_DMA_STATE_THRESH_4W 0x00000040
#define TI_DMA_STATE_THRESH_2W 0x00000020
#define TI_DMA_STATE_THRESH_1W 0x00000010
#define TI_DMA_STATE_FORCE_32_BIT 0x00000008
#define TI_GLNK_SENSE_NO_BEG 0x00002000
#define TI_GLNK_LOOPBACK 0x00004000
#define TI_GLNK_PREF 0x00008000
#define TI_GLNK_1000MB 0x00040000
#define TI_GLNK_FULL_DUPLEX 0x00080000
#define TI_GLNK_TX_FLOWCTL_Y 0x00200000
#define TI_GLNK_RX_FLOWCTL_Y 0x00800000
#define TI_GLNK_AUTONEGENB 0x20000000
#define TI_GLNK_ENB 0x40000000
#define TI_LNK_LOOPBACK 0x00004000
#define TI_LNK_PREF 0x00008000
#define TI_LNK_10MB 0x00010000
#define TI_LNK_100MB 0x00020000
#define TI_LNK_1000MB 0x00040000
#define TI_LNK_FULL_DUPLEX 0x00080000
#define TI_LNK_HALF_DUPLEX 0x00100000
#define TI_LNK_TX_FLOWCTL_Y 0x00200000
#define TI_LNK_RX_FLOWCTL_Y 0x00800000
#define TI_LNK_AUTONEGENB 0x20000000
#define TI_LNK_ENB 0x40000000
#define TI_EVENT_RING_CNT 256
#define TI_CMD_RING_CNT 64
#define TI_STD_RX_RING_CNT 512
#define TI_JUMBO_RX_RING_CNT 256
#define TI_MINI_RX_RING_CNT 1024
#define TI_RETURN_RING_CNT 2048
#define TI_TX_RING_CNT_128 128
#define TI_TX_RING_BASE_128 0x3800
#define TI_TX_RING_CNT_256 256
#define TI_TX_RING_BASE_256 0x3000
#define TI_TX_RING_CNT_512 512
#define TI_TX_RING_BASE_512 0x2000
#define TI_TX_RING_CNT TI_TX_RING_CNT_512
#define TI_TX_RING_BASE TI_TX_RING_BASE_512
#define TI_MEM_MAX 0x7FFFFF
#ifdef __64_bit_pci_addressing__
typedef struct {
u_int64_t ti_addr;
} ti_hostaddr;
#define TI_HOSTADDR(x) x.ti_addr
#else
typedef struct {
uint32_t ti_addr_hi;
uint32_t ti_addr_lo;
} ti_hostaddr;
#define TI_HOSTADDR(x) x.ti_addr_lo
#endif
struct ti_rcb {
ti_hostaddr ti_hostaddr;
#if BYTE_ORDER == BIG_ENDIAN
uint16_t ti_max_len;
uint16_t ti_flags;
#else
uint16_t ti_flags;
uint16_t ti_max_len;
#endif
uint32_t ti_unused;
};
#define TI_RCB_FLAG_TCP_UDP_CKSUM 0x00000001
#define TI_RCB_FLAG_IP_CKSUM 0x00000002
#define TI_RCB_FLAG_NO_PHDR_CKSUM 0x00000008
#define TI_RCB_FLAG_VLAN_ASSIST 0x00000010
#define TI_RCB_FLAG_COAL_UPD_ONLY 0x00000020
#define TI_RCB_FLAG_HOST_RING 0x00000040
#define TI_RCB_FLAG_IEEE_SNAP_CKSUM 0x00000080
#define TI_RCB_FLAG_USE_EXT_RX_BD 0x00000100
#define TI_RCB_FLAG_RING_DISABLED 0x00000200
struct ti_producer {
uint32_t ti_idx;
uint32_t ti_unused;
};
struct ti_stats {
volatile uint32_t dot3StatsAlignmentErrors;
volatile uint32_t dot3StatsFCSErrors;
volatile uint32_t dot3StatsSingleCollisionFrames;
volatile uint32_t dot3StatsMultipleCollisionFrames;
volatile uint32_t dot3StatsSQETestErrors;
volatile uint32_t dot3StatsDeferredTransmissions;
volatile uint32_t dot3StatsLateCollisions;
volatile uint32_t dot3StatsExcessiveCollisions;
volatile uint32_t dot3StatsInternalMacTransmitErrors;
volatile uint32_t dot3StatsCarrierSenseErrors;
volatile uint32_t dot3StatsFrameTooLongs;
volatile uint32_t dot3StatsInternalMacReceiveErrors;
volatile uint32_t ifIndex;
volatile uint32_t ifType;
volatile uint32_t ifMtu;
volatile uint32_t ifSpeed;
volatile uint32_t ifAdminStatus;
#define IF_ADMIN_STATUS_UP 1
#define IF_ADMIN_STATUS_DOWN 2
#define IF_ADMIN_STATUS_TESTING 3
volatile uint32_t ifOperStatus;
#define IF_OPER_STATUS_UP 1
#define IF_OPER_STATUS_DOWN 2
#define IF_OPER_STATUS_TESTING 3
#define IF_OPER_STATUS_UNKNOWN 4
#define IF_OPER_STATUS_DORMANT 5
volatile uint32_t ifLastChange;
volatile uint32_t ifInDiscards;
volatile uint32_t ifInErrors;
volatile uint32_t ifInUnknownProtos;
volatile uint32_t ifOutDiscards;
volatile uint32_t ifOutErrors;
volatile uint32_t ifOutQLen;
volatile uint8_t ifPhysAddress[8];
volatile uint8_t ifDescr[32];
uint32_t alignIt;
volatile uint64_t ifHCInOctets;
volatile uint64_t ifHCInUcastPkts;
volatile uint64_t ifHCInMulticastPkts;
volatile uint64_t ifHCInBroadcastPkts;
volatile uint64_t ifHCOutOctets;
volatile uint64_t ifHCOutUcastPkts;
volatile uint64_t ifHCOutMulticastPkts;
volatile uint64_t ifHCOutBroadcastPkts;
volatile uint32_t ifLinkUpDownTrapEnable;
volatile uint32_t ifHighSpeed;
volatile uint32_t ifPromiscuousMode;
volatile uint32_t ifConnectorPresent;
volatile uint32_t nicCmdsHostState;
volatile uint32_t nicCmdsFDRFiltering;
volatile uint32_t nicCmdsSetRecvProdIndex;
volatile uint32_t nicCmdsUpdateGencommStats;
volatile uint32_t nicCmdsResetJumboRing;
volatile uint32_t nicCmdsAddMCastAddr;
volatile uint32_t nicCmdsDelMCastAddr;
volatile uint32_t nicCmdsSetPromiscMode;
volatile uint32_t nicCmdsLinkNegotiate;
volatile uint32_t nicCmdsSetMACAddr;
volatile uint32_t nicCmdsClearProfile;
volatile uint32_t nicCmdsSetMulticastMode;
volatile uint32_t nicCmdsClearStats;
volatile uint32_t nicCmdsSetRecvJumboProdIndex;
volatile uint32_t nicCmdsSetRecvMiniProdIndex;
volatile uint32_t nicCmdsRefreshStats;
volatile uint32_t nicCmdsUnknown;
volatile uint32_t nicEventsNICFirmwareOperational;
volatile uint32_t nicEventsStatsUpdated;
volatile uint32_t nicEventsLinkStateChanged;
volatile uint32_t nicEventsError;
volatile uint32_t nicEventsMCastListUpdated;
volatile uint32_t nicEventsResetJumboRing;
volatile uint32_t nicRingSetSendProdIndex;
volatile uint32_t nicRingSetSendConsIndex;
volatile uint32_t nicRingSetRecvReturnProdIndex;
volatile uint32_t nicInterrupts;
volatile uint32_t nicAvoidedInterrupts;
volatile uint32_t nicEventThresholdHit;
volatile uint32_t nicSendThresholdHit;
volatile uint32_t nicRecvThresholdHit;
volatile uint32_t nicDmaRdOverrun;
volatile uint32_t nicDmaRdUnderrun;
volatile uint32_t nicDmaWrOverrun;
volatile uint32_t nicDmaWrUnderrun;
volatile uint32_t nicDmaWrMasterAborts;
volatile uint32_t nicDmaRdMasterAborts;
volatile uint32_t nicDmaWriteRingFull;
volatile uint32_t nicDmaReadRingFull;
volatile uint32_t nicEventRingFull;
volatile uint32_t nicEventProducerRingFull;
volatile uint32_t nicTxMacDescrRingFull;
volatile uint32_t nicOutOfTxBufSpaceFrameRetry;
volatile uint32_t nicNoMoreWrDMADescriptors;
volatile uint32_t nicNoMoreRxBDs;
volatile uint32_t nicNoSpaceInReturnRing;
volatile uint32_t nicSendBDs;
volatile uint32_t nicRecvBDs;
volatile uint32_t nicJumboRecvBDs;
volatile uint32_t nicMiniRecvBDs;
volatile uint32_t nicTotalRecvBDs;
volatile uint32_t nicTotalSendBDs;
volatile uint32_t nicJumboSpillOver;
volatile uint32_t nicSbusHangCleared;
volatile uint32_t nicEnqEventDelayed;
volatile uint32_t nicMacRxLateColls;
volatile uint32_t nicMacRxLinkLostDuringPkt;
volatile uint32_t nicMacRxPhyDecodeErr;
volatile uint32_t nicMacRxMacAbort;
volatile uint32_t nicMacRxTruncNoResources;
volatile uint32_t nicMacRxDropUla;
volatile uint32_t nicMacRxDropMcast;
volatile uint32_t nicMacRxFlowControl;
volatile uint32_t nicMacRxDropSpace;
volatile uint32_t nicMacRxColls;
volatile uint32_t nicMacRxTotalAttns;
volatile uint32_t nicMacRxLinkAttns;
volatile uint32_t nicMacRxSyncAttns;
volatile uint32_t nicMacRxConfigAttns;
volatile uint32_t nicMacReset;
volatile uint32_t nicMacRxBufDescrAttns;
volatile uint32_t nicMacRxBufAttns;
volatile uint32_t nicMacRxZeroFrameCleanup;
volatile uint32_t nicMacRxOneFrameCleanup;
volatile uint32_t nicMacRxMultipleFrameCleanup;
volatile uint32_t nicMacRxTimerCleanup;
volatile uint32_t nicMacRxDmaCleanup;
volatile uint32_t nicMacTxCollisionHistogram[15];
volatile uint32_t nicMacTxTotalAttns;
volatile uint32_t nicProfile[32];
uint32_t pad[75];
};
struct ti_gib {
struct ti_stats ti_stats;
struct ti_rcb ti_ev_rcb;
struct ti_rcb ti_cmd_rcb;
struct ti_rcb ti_tx_rcb;
struct ti_rcb ti_std_rx_rcb;
struct ti_rcb ti_jumbo_rx_rcb;
struct ti_rcb ti_mini_rx_rcb;
struct ti_rcb ti_return_rcb;
ti_hostaddr ti_ev_prodidx_ptr;
ti_hostaddr ti_return_prodidx_ptr;
ti_hostaddr ti_tx_considx_ptr;
ti_hostaddr ti_refresh_stats_ptr;
};
struct ti_rx_desc {
ti_hostaddr ti_addr;
#if BYTE_ORDER == BIG_ENDIAN
uint16_t ti_idx;
uint16_t ti_len;
#else
uint16_t ti_len;
uint16_t ti_idx;
#endif
#if BYTE_ORDER == BIG_ENDIAN
uint16_t ti_type;
uint16_t ti_flags;
#else
uint16_t ti_flags;
uint16_t ti_type;
#endif
#if BYTE_ORDER == BIG_ENDIAN
uint16_t ti_ip_cksum;
uint16_t ti_tcp_udp_cksum;
#else
uint16_t ti_tcp_udp_cksum;
uint16_t ti_ip_cksum;
#endif
#if BYTE_ORDER == BIG_ENDIAN
uint16_t ti_error_flags;
uint16_t ti_vlan_tag;
#else
uint16_t ti_vlan_tag;
uint16_t ti_error_flags;
#endif
uint32_t ti_rsvd;
uint32_t ti_opaque;
};
struct ti_rx_desc_ext {
ti_hostaddr ti_addr1;
ti_hostaddr ti_addr2;
ti_hostaddr ti_addr3;
#if BYTE_ORDER == BIG_ENDIAN
uint16_t ti_len1;
uint16_t ti_len2;
#else
uint16_t ti_len2;
uint16_t ti_len1;
#endif
#if BYTE_ORDER == BIG_ENDIAN
uint16_t ti_len3;
uint16_t ti_rsvd0;
#else
uint16_t ti_rsvd0;
uint16_t ti_len3;
#endif
ti_hostaddr ti_addr0;
#if BYTE_ORDER == BIG_ENDIAN
uint16_t ti_idx;
uint16_t ti_len0;
#else
uint16_t ti_len0;
uint16_t ti_idx;
#endif
#if BYTE_ORDER == BIG_ENDIAN
uint16_t ti_type;
uint16_t ti_flags;
#else
uint16_t ti_flags;
uint16_t ti_type;
#endif
#if BYTE_ORDER == BIG_ENDIAN
uint16_t ti_ip_cksum;
uint16_t ti_tcp_udp_cksum;
#else
uint16_t ti_tcp_udp_cksum;
uint16_t ti_ip_cksum;
#endif
#if BYTE_ORDER == BIG_ENDIAN
uint16_t ti_error_flags;
uint16_t ti_vlan_tag;
#else
uint16_t ti_vlan_tag;
uint16_t ti_error_flags;
#endif
uint32_t ti_rsvd1;
uint32_t ti_opaque;
};
struct ti_tx_desc {
ti_hostaddr ti_addr;
#if BYTE_ORDER == BIG_ENDIAN
uint16_t ti_len;
uint16_t ti_flags;
#else
uint16_t ti_flags;
uint16_t ti_len;
#endif
#if BYTE_ORDER == BIG_ENDIAN
uint16_t ti_rsvd;
uint16_t ti_vlan_tag;
#else
uint16_t ti_vlan_tag;
uint16_t ti_rsvd;
#endif
};
#define TI_PAGE_SIZE PAGE_SIZE
#define TI_BDERR_CRC 0x0001
#define TI_BDERR_COLLDETECT 0x0002
#define TI_BDERR_LINKLOST 0x0004
#define TI_BDERR_DECODE 0x0008
#define TI_BDERR_ODD_NIBBLES 0x0010
#define TI_BDERR_MAC_ABRT 0x0020
#define TI_BDERR_RUNT 0x0040
#define TI_BDERR_TRUNC 0x0080
#define TI_BDERR_GIANT 0x0100
#define TI_BDFLAG_TCP_UDP_CKSUM 0x0001
#define TI_BDFLAG_IP_CKSUM 0x0002
#define TI_BDFLAG_END 0x0004
#define TI_BDFLAG_MORE 0x0008
#define TI_BDFLAG_JUMBO_RING 0x0010
#define TI_BDFLAG_UCAST_PKT 0x0020
#define TI_BDFLAG_MCAST_PKT 0x0040
#define TI_BDFLAG_BCAST_PKT 0x0060
#define TI_BDFLAG_IP_FRAG 0x0080
#define TI_BDFLAG_IP_FRAG_END 0x0100
#define TI_BDFLAG_VLAN_TAG 0x0200
#define TI_BDFLAG_ERROR 0x0400
#define TI_BDFLAG_COAL_NOW 0x0800
#define TI_BDFLAG_MINI_RING 0x1000
#define TI_BDTYPE_TYPE_NULL 0x0000
#define TI_BDTYPE_SEND_BD 0x0001
#define TI_BDTYPE_RECV_BD 0x0002
#define TI_BDTYPE_RECV_JUMBO_BD 0x0003
#define TI_BDTYPE_RECV_BD_LAST 0x0004
#define TI_BDTYPE_SEND_DATA 0x0005
#define TI_BDTYPE_SEND_DATA_LAST 0x0006
#define TI_BDTYPE_RECV_DATA 0x0007
#define TI_BDTYPE_RECV_DATA_LAST 0x000b
#define TI_BDTYPE_EVENT_RUPT 0x000c
#define TI_BDTYPE_EVENT_NO_RUPT 0x000d
#define TI_BDTYPE_ODD_START 0x000e
#define TI_BDTYPE_UPDATE_STATS 0x000f
#define TI_BDTYPE_SEND_DUMMY_DMA 0x0010
#define TI_BDTYPE_EVENT_PROD 0x0011
#define TI_BDTYPE_TX_CONS 0x0012
#define TI_BDTYPE_RX_PROD 0x0013
#define TI_BDTYPE_REFRESH_STATS 0x0014
#define TI_BDTYPE_SEND_DATA_LAST_VLAN 0x0015
#define TI_BDTYPE_SEND_DATA_COAL 0x0016
#define TI_BDTYPE_SEND_DATA_LAST_COAL 0x0017
#define TI_BDTYPE_SEND_DATA_LAST_VLAN_COAL 0x0018
#define TI_BDTYPE_TX_CONS_NO_INTR 0x0019
struct ti_cmd_desc {
uint32_t ti_cmdx;
};
#define TI_CMD_CMD(cmd) (((((cmd)->ti_cmdx)) >> 24) & 0xff)
#define TI_CMD_CODE(cmd) (((((cmd)->ti_cmdx)) >> 12) & 0xfff)
#define TI_CMD_IDX(cmd) ((((cmd)->ti_cmdx)) & 0xfff)
#define TI_CMD_HOST_STATE 0x01
#define TI_CMD_CODE_STACK_UP 0x01
#define TI_CMD_CODE_STACK_DOWN 0x02
#define TI_CMD_FDR_FILTERING 0x02
#define TI_CMD_CODE_FILT_ENB 0x01
#define TI_CMD_CODE_FILT_DIS 0x02
#define TI_CMD_SET_RX_PROD_IDX 0x03
#define TI_CMD_UPDATE_GENCOM 0x04
#define TI_CMD_RESET_JUMBO_RING 0x05
#define TI_CMD_SET_PARTIAL_RX_CNT 0x06
#define TI_CMD_ADD_MCAST_ADDR 0x08
#define TI_CMD_DEL_MCAST_ADDR 0x09
#define TI_CMD_SET_PROMISC_MODE 0x0A
#define TI_CMD_CODE_PROMISC_ENB 0x01
#define TI_CMD_CODE_PROMISC_DIS 0x02
#define TI_CMD_LINK_NEGOTIATION 0x0B
#define TI_CMD_CODE_NEGOTIATE_BOTH 0x00
#define TI_CMD_CODE_NEGOTIATE_GIGABIT 0x01
#define TI_CMD_CODE_NEGOTIATE_10_100 0x02
#define TI_CMD_SET_MAC_ADDR 0x0C
#define TI_CMD_CLR_PROFILE 0x0D
#define TI_CMD_SET_ALLMULTI 0x0E
#define TI_CMD_CODE_ALLMULTI_ENB 0x01
#define TI_CMD_CODE_ALLMULTI_DIS 0x02
#define TI_CMD_CLR_STATS 0x0F
#define TI_CMD_SET_RX_JUMBO_PROD_IDX 0x10
#define TI_CMD_RFRSH_STATS 0x11
#define TI_CMD_EXT_ADD_MCAST 0x12
#define TI_CMD_EXT_DEL_MCAST 0x13
#define TI_DO_CMD(x, y, z) do { \
cmd.ti_cmdx = (((x) << 24) | ((y) << 12) | ((z))); \
ti_cmd(sc, &cmd); \
} while(0)
#define TI_DO_CMD_EXT(x, y, z, v, w) do { \
cmd.ti_cmdx = (((x) << 24) | ((y) << 12) | ((z))); \
ti_cmd_ext(sc, &cmd, (v), (w)); \
} while(0)
#define TI_INC(x, y) do { (x) = ((x) + 1) % (y); } while(0)
#define TI_UPDATE_JUMBOPROD(x, y) do { \
if ((x)->ti_hwrev == TI_HWREV_TIGON) \
TI_DO_CMD(TI_CMD_SET_RX_JUMBO_PROD_IDX, 0, y); \
else \
CSR_WRITE_4(x, TI_MB_JUMBORXPROD_IDX, y); \
} while(0)
#define TI_UPDATE_MINIPROD(x, y) \
CSR_WRITE_4(x, TI_MB_MINIRXPROD_IDX, y)
#define TI_UPDATE_STDPROD(x, y) do { \
if ((x)->ti_hwrev == TI_HWREV_TIGON) \
TI_DO_CMD(TI_CMD_SET_RX_PROD_IDX, 0, y); \
else \
CSR_WRITE_4(x, TI_MB_STDRXPROD_IDX, y); \
} while(0)
struct ti_event_desc {
uint32_t ti_eventx;
uint32_t ti_rsvd;
};
#define TI_EVENT_EVENT(e) (((((e)->ti_eventx)) >> 24) & 0xff)
#define TI_EVENT_CODE(e) (((((e)->ti_eventx)) >> 12) & 0xfff)
#define TI_EVENT_IDX(e) (((((e)->ti_eventx))) & 0xfff)
#define TI_EV_FIRMWARE_UP 0x01
#define TI_EV_STATS_UPDATED 0x04
#define TI_EV_LINKSTAT_CHANGED 0x06
#define TI_EV_CODE_GIG_LINK_UP 0x01
#define TI_EV_CODE_LINK_DOWN 0x02
#define TI_EV_CODE_LINK_UP 0x03
#define TI_EV_ERROR 0x07
#define TI_EV_CODE_ERR_INVAL_CMD 0x01
#define TI_EV_CODE_ERR_UNIMP_CMD 0x02
#define TI_EV_CODE_ERR_BADCFG 0x03
#define TI_EV_MCAST_UPDATED 0x08
#define TI_EV_CODE_MCAST_ADD 0x01
#define TI_EV_CODE_MCAST_DEL 0x02
#define TI_EV_RESET_JUMBO_RING 0x09
#ifdef __BUS_SPACE_HAS_STREAM_METHODS
#define CSR_WRITE_4(sc, reg, val) \
bus_space_write_stream_4((sc)->ti_btag, (sc)->ti_bhandle, reg, val)
#define CSR_READ_4(sc, reg) \
bus_space_read_stream_4((sc)->ti_btag, (sc)->ti_bhandle, reg)
#else
#define CSR_WRITE_4(sc, reg, val) \
bus_space_write_4((sc)->ti_btag, (sc)->ti_bhandle, reg, val)
#define CSR_READ_4(sc, reg) \
bus_space_read_4((sc)->ti_btag, (sc)->ti_bhandle, reg)
#endif
#define TI_SETBIT(sc, reg, x) \
CSR_WRITE_4(sc, reg, (CSR_READ_4(sc, reg) | (x)))
#define TI_CLRBIT(sc, reg, x) \
CSR_WRITE_4(sc, reg, (CSR_READ_4(sc, reg) & ~(x)))
#ifndef TI_SSLOTS
#define TI_SSLOTS 256
#endif
#ifndef TI_MSLOTS
#define TI_MSLOTS 256
#endif
#ifndef TI_JSLOTS
#define TI_JSLOTS 384
#endif
#define TI_RSLOTS 128
#define TI_JRAWLEN (ETHER_MAX_LEN_JUMBO + ETHER_ALIGN + sizeof(uint64_t))
#define TI_JLEN (TI_JRAWLEN + (sizeof(uint64_t) - \
(TI_JRAWLEN % sizeof(uint64_t))))
#define TI_JPAGESZ PAGE_SIZE
#define TI_RESID (TI_JPAGESZ - (TI_JLEN * TI_JSLOTS) % TI_JPAGESZ)
#define TI_JMEM ((TI_JLEN * TI_JSLOTS) + TI_RESID)
struct ti_ring_data {
struct ti_rx_desc ti_rx_std_ring[TI_STD_RX_RING_CNT];
struct ti_rx_desc ti_rx_jumbo_ring[TI_JUMBO_RX_RING_CNT];
struct ti_rx_desc ti_rx_mini_ring[TI_MINI_RX_RING_CNT];
struct ti_rx_desc ti_rx_return_ring[TI_RETURN_RING_CNT];
struct ti_event_desc ti_event_ring[TI_EVENT_RING_CNT];
struct ti_tx_desc ti_tx_ring[TI_TX_RING_CNT];
struct ti_producer ti_ev_prodidx_r;
uint32_t ti_pad0[6];
struct ti_producer ti_return_prodidx_r;
uint32_t ti_pad1[6];
struct ti_producer ti_tx_considx_r;
uint32_t ti_pad2[6];
struct ti_gib ti_info;
};
#define TI_CDOFF(x) offsetof(struct ti_ring_data, x)
#define TI_CDRXSTDOFF(x) TI_CDOFF(ti_rx_std_ring[(x)])
#define TI_CDRXJUMBOOFF(x) TI_CDOFF(ti_rx_jumbo_ring[(x)])
#define TI_CDRXMINIOFF(x) TI_CDOFF(ti_rx_mini_ring[(x)])
#define TI_CDRXRTNOFF(x) TI_CDOFF(ti_rx_return_ring[(x)])
#define TI_CDEVENTOFF(x) TI_CDOFF(ti_event_ring[(x)])
#define TI_CDTXOFF(x) TI_CDOFF(ti_tx_ring[(x)])
#define TI_CDEVPRODOFF TI_CDOFF(ti_ev_prodidx_r)
#define TI_CDRTNPRODOFF TI_CDOFF(ti_return_prodidx_r)
#define TI_CDTXCONSOFF TI_CDOFF(ti_tx_considx_r)
#define TI_CDGIBOFF TI_CDOFF(ti_info)
#define TI_CDSTATSOFF TI_CDOFF(ti_info.ti_stats)
struct ti_chain_data {
struct mbuf *ti_tx_chain[TI_TX_RING_CNT];
struct mbuf *ti_rx_std_chain[TI_STD_RX_RING_CNT];
struct mbuf *ti_rx_jumbo_chain[TI_JUMBO_RX_RING_CNT];
struct mbuf *ti_rx_mini_chain[TI_MINI_RX_RING_CNT];
void * ti_jslots[TI_JSLOTS];
void *ti_jumbo_buf;
};
struct ti_type {
uint16_t ti_vid;
uint16_t ti_did;
const char *ti_name;
};
#define TI_HWREV_TIGON 0x01
#define TI_HWREV_TIGON_II 0x02
#define TI_TIMEOUT 1000
#define TI_TXCONS_UNSET 0xFFFF
struct ti_mc_entry {
struct ether_addr mc_addr;
SIMPLEQ_ENTRY(ti_mc_entry) mc_entries;
};
struct ti_jpool_entry {
int slot;
SIMPLEQ_ENTRY(ti_jpool_entry) jpool_entries;
};
struct txdmamap_pool_entry {
bus_dmamap_t dmamap;
SIMPLEQ_ENTRY(txdmamap_pool_entry) link;
};
struct ti_softc {
device_t sc_dev;
struct ethercom ethercom;
bus_space_handle_t ti_bhandle;
char *ti_vhandle;
bus_space_tag_t ti_btag;
void *ti_intrhand;
struct ifmedia ifmedia;
uint8_t ti_hwrev;
uint8_t ti_copper;
uint8_t ti_linkstat;
struct ti_ring_data *ti_rdata;
#define ti_ev_prodidx ti_rdata->ti_ev_prodidx_r
#define ti_return_prodidx ti_rdata->ti_return_prodidx_r
#define ti_tx_considx ti_rdata->ti_tx_considx_r
struct ti_tx_desc *ti_tx_ring_nic;
struct ti_chain_data ti_cdata;
uint64_t ti_if_collisions;
int (*sc_tx_encap)(struct ti_softc *,
struct mbuf *, uint32_t *);
void (*sc_tx_eof)(struct ti_softc *);
uint16_t ti_tx_saved_considx;
uint16_t ti_rx_saved_considx;
uint16_t ti_ev_saved_considx;
uint16_t ti_cmd_saved_prodidx;
uint16_t ti_std;
uint16_t ti_mini;
uint16_t ti_jumbo;
SIMPLEQ_HEAD(, ti_mc_entry) ti_mc_listhead;
SIMPLEQ_HEAD(, ti_jpool_entry) ti_jfree_listhead;
SIMPLEQ_HEAD(, ti_jpool_entry) ti_jinuse_listhead;
uint32_t ti_stat_ticks;
uint32_t ti_rx_coal_ticks;
uint32_t ti_tx_coal_ticks;
uint32_t ti_rx_max_coal_bds;
uint32_t ti_tx_max_coal_bds;
uint32_t ti_tx_buf_ratio;
u_short ti_if_flags;
int ti_txcnt;
void *sc_ih;
bus_dma_tag_t sc_dmat;
bus_dmamap_t info_dmamap;
uint32_t info_dmaaddr;
bus_dmamap_t jumbo_dmamap;
uint32_t jumbo_dmaaddr;
bus_dmamap_t mini_dmamap[TI_MINI_RX_RING_CNT];
bus_dmamap_t std_dmamap[TI_STD_RX_RING_CNT];
SIMPLEQ_HEAD(, txdmamap_pool_entry) txdma_list;
struct txdmamap_pool_entry *txdma[TI_TX_RING_CNT];
};
#define TI_CDRXSTDADDR(sc, x) ((sc)->info_dmaaddr + TI_CDRXSTDOFF((x)))
#define TI_CDRXJUMBOADDR(sc, x) ((sc)->info_dmaaddr + TI_CDRXJUMBOOFF((x)))
#define TI_CDRXMINIADDR(sc, x) ((sc)->info_dmaaddr + TI_CDRXMINIOFF((x)))
#define TI_CDRXRTNADDR(sc, x) ((sc)->info_dmaaddr + TI_CDRXRTNOFF((x)))
#define TI_CDEVENTADDR(sc, x) ((sc)->info_dmaaddr + TI_CDEVENTOFF((x)))
#define TI_CDTXADDR(sc, x) ((sc)->info_dmaaddr + TI_CDTXOFF((x)))
#define TI_CDEVPRODADDR(sc) ((sc)->info_dmaaddr + TI_CDEVPRODOFF)
#define TI_CDRTNPRODADDR(sc) ((sc)->info_dmaaddr + TI_CDRTNPRODOFF)
#define TI_CDTXCONSADDR(sc) ((sc)->info_dmaaddr + TI_CDTXCONSOFF)
#define TI_CDGIBADDR(sc) ((sc)->info_dmaaddr + TI_CDGIBOFF)
#define TI_CDSTATSADDR(sc) ((sc)->info_dmaaddr + TI_CDSTATSOFF)
#define TI_CDRXSTDSYNC(sc, x, ops) \
bus_dmamap_sync((sc)->sc_dmat, (sc)->info_dmamap, \
TI_CDRXSTDOFF((x)), sizeof(struct ti_rx_desc), (ops))
#define TI_CDRXJUMBOSYNC(sc, x, ops) \
bus_dmamap_sync((sc)->sc_dmat, (sc)->info_dmamap, \
TI_CDRXJUMBOOFF((x)), sizeof(struct ti_rx_desc), (ops))
#define TI_CDRXMINISYNC(sc, x, ops) \
bus_dmamap_sync((sc)->sc_dmat, (sc)->info_dmamap, \
TI_CDRXMINIOFF((x)), sizeof(struct ti_rx_desc), (ops))
#define TI_CDRXRTNSYNC(sc, x, ops) \
bus_dmamap_sync((sc)->sc_dmat, (sc)->info_dmamap, \
TI_CDRXRTNOFF((x)), sizeof(struct ti_rx_desc), (ops))
#define TI_CDEVENTSYNC(sc, x, ops) \
bus_dmamap_sync((sc)->sc_dmat, (sc)->info_dmamap, \
TI_CDEVENTOFF((x)), sizeof(struct ti_event_desc), (ops))
#define TI_CDTXSYNC(sc, x, n, ops) \
do { \
int __x, __n; \
\
__x = (x); \
__n = (n); \
\
\
if ((__x + __n) > TI_TX_RING_CNT) { \
bus_dmamap_sync((sc)->sc_dmat, (sc)->info_dmamap, \
TI_CDTXOFF(__x), sizeof(struct ti_tx_desc) * \
(TI_TX_RING_CNT - __x), (ops)); \
__n -= (TI_TX_RING_CNT - __x); \
__x = 0; \
} \
\
\
bus_dmamap_sync((sc)->sc_dmat, (sc)->info_dmamap, \
TI_CDTXOFF(__x), sizeof(struct ti_tx_desc) * (__n), (ops)); \
} while (0)
#define TI_CEVPRODSYNC(sc, ops) \
bus_dmamap_sync((sc)->sc_dmat, (sc)->info_dmamap, \
TI_CDEVPRODOFF, sizeof(struct ti_producer), (ops))
#define TI_CDRTNPRODSYNC(sc, ops) \
bus_dmamap_sync((sc)->sc_dmat, (sc)->info_dmamap, \
TI_CDRTNPRODOFF, sizeof(struct ti_producer), (ops))
#define TI_CDTXCONSSYNC(sc, ops) \
bus_dmamap_sync((sc)->sc_dmat, (sc)->info_dmamap, \
TI_CDTXCONSOFF, sizeof(struct ti_producer), (ops))
#define TI_CDGIBSYNC(sc, ops) \
bus_dmamap_sync((sc)->sc_dmat, (sc)->info_dmamap, \
TI_CDGIBOFF, sizeof(struct ti_gib), (ops))
#define TI_CDSTATSSYNC(sc, ops) \
bus_dmamap_sync((sc)->sc_dmat, (sc)->info_dmamap, \
TI_CDSTATSOFF, sizeof(struct ti_stats), (ops))
#define EEPROM_CTL_READ 0xA1
#define EEPROM_CTL_WRITE 0xA0
#define EEPROM_START() do { \
TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK); \
TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_DOUT); \
TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN); \
TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_DOUT); \
TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK); \
} while(0)
#define EEPROM_STOP() do { \
TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN); \
TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_DOUT); \
TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK); \
TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN); \
TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_DOUT); \
TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN); \
TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK); \
} while(0)