18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ACENIC_H_
38c2ecf20Sopenharmony_ci#define _ACENIC_H_
48c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci/*
88c2ecf20Sopenharmony_ci * Generate TX index update each time, when TX ring is closed.
98c2ecf20Sopenharmony_ci * Normally, this is not useful, because results in more dma (and irqs
108c2ecf20Sopenharmony_ci * without TX_COAL_INTS_ONLY).
118c2ecf20Sopenharmony_ci */
128c2ecf20Sopenharmony_ci#define USE_TX_COAL_NOW	 0
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci/*
158c2ecf20Sopenharmony_ci * Addressing:
168c2ecf20Sopenharmony_ci *
178c2ecf20Sopenharmony_ci * The Tigon uses 64-bit host addresses, regardless of their actual
188c2ecf20Sopenharmony_ci * length, and it expects a big-endian format. For 32 bit systems the
198c2ecf20Sopenharmony_ci * upper 32 bits of the address are simply ignored (zero), however for
208c2ecf20Sopenharmony_ci * little endian 64 bit systems (Alpha) this looks strange with the
218c2ecf20Sopenharmony_ci * two parts of the address word being swapped.
228c2ecf20Sopenharmony_ci *
238c2ecf20Sopenharmony_ci * The addresses are split in two 32 bit words for all architectures
248c2ecf20Sopenharmony_ci * as some of them are in PCI shared memory and it is necessary to use
258c2ecf20Sopenharmony_ci * readl/writel to access them.
268c2ecf20Sopenharmony_ci *
278c2ecf20Sopenharmony_ci * The addressing code is derived from Pete Wyckoff's work, but
288c2ecf20Sopenharmony_ci * modified to deal properly with readl/writel usage.
298c2ecf20Sopenharmony_ci */
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_cistruct ace_regs {
328c2ecf20Sopenharmony_ci	u32	pad0[16];	/* PCI control registers */
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci	u32	HostCtrl;	/* 0x40 */
358c2ecf20Sopenharmony_ci	u32	LocalCtrl;
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci	u32	pad1[2];
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci	u32	MiscCfg;	/* 0x50 */
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci	u32	pad2[2];
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci	u32	PciState;
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci	u32	pad3[2];	/* 0x60 */
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci	u32	WinBase;
488c2ecf20Sopenharmony_ci	u32	WinData;
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci	u32	pad4[12];	/* 0x70 */
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci	u32	DmaWriteState;	/* 0xa0 */
538c2ecf20Sopenharmony_ci	u32	pad5[3];
548c2ecf20Sopenharmony_ci	u32	DmaReadState;	/* 0xb0 */
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci	u32	pad6[26];
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci	u32	AssistState;
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci	u32	pad7[8];	/* 0x120 */
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci	u32	CpuCtrl;	/* 0x140 */
638c2ecf20Sopenharmony_ci	u32	Pc;
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci	u32	pad8[3];
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci	u32	SramAddr;	/* 0x154 */
688c2ecf20Sopenharmony_ci	u32	SramData;
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci	u32	pad9[49];
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci	u32	MacRxState;	/* 0x220 */
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci	u32	pad10[7];
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci	u32	CpuBCtrl;	/* 0x240 */
778c2ecf20Sopenharmony_ci	u32	PcB;
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci	u32	pad11[3];
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci	u32	SramBAddr;	/* 0x254 */
828c2ecf20Sopenharmony_ci	u32	SramBData;
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci	u32	pad12[105];
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci	u32	pad13[32];	/* 0x400 */
878c2ecf20Sopenharmony_ci	u32	Stats[32];
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci	u32	Mb0Hi;		/* 0x500 */
908c2ecf20Sopenharmony_ci	u32	Mb0Lo;
918c2ecf20Sopenharmony_ci	u32	Mb1Hi;
928c2ecf20Sopenharmony_ci	u32	CmdPrd;
938c2ecf20Sopenharmony_ci	u32	Mb2Hi;
948c2ecf20Sopenharmony_ci	u32	TxPrd;
958c2ecf20Sopenharmony_ci	u32	Mb3Hi;
968c2ecf20Sopenharmony_ci	u32	RxStdPrd;
978c2ecf20Sopenharmony_ci	u32	Mb4Hi;
988c2ecf20Sopenharmony_ci	u32	RxJumboPrd;
998c2ecf20Sopenharmony_ci	u32	Mb5Hi;
1008c2ecf20Sopenharmony_ci	u32	RxMiniPrd;
1018c2ecf20Sopenharmony_ci	u32	Mb6Hi;
1028c2ecf20Sopenharmony_ci	u32	Mb6Lo;
1038c2ecf20Sopenharmony_ci	u32	Mb7Hi;
1048c2ecf20Sopenharmony_ci	u32	Mb7Lo;
1058c2ecf20Sopenharmony_ci	u32	Mb8Hi;
1068c2ecf20Sopenharmony_ci	u32	Mb8Lo;
1078c2ecf20Sopenharmony_ci	u32	Mb9Hi;
1088c2ecf20Sopenharmony_ci	u32	Mb9Lo;
1098c2ecf20Sopenharmony_ci	u32	MbAHi;
1108c2ecf20Sopenharmony_ci	u32	MbALo;
1118c2ecf20Sopenharmony_ci	u32	MbBHi;
1128c2ecf20Sopenharmony_ci	u32	MbBLo;
1138c2ecf20Sopenharmony_ci	u32	MbCHi;
1148c2ecf20Sopenharmony_ci	u32	MbCLo;
1158c2ecf20Sopenharmony_ci	u32	MbDHi;
1168c2ecf20Sopenharmony_ci	u32	MbDLo;
1178c2ecf20Sopenharmony_ci	u32	MbEHi;
1188c2ecf20Sopenharmony_ci	u32	MbELo;
1198c2ecf20Sopenharmony_ci	u32	MbFHi;
1208c2ecf20Sopenharmony_ci	u32	MbFLo;
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci	u32	pad14[32];
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci	u32	MacAddrHi;	/* 0x600 */
1258c2ecf20Sopenharmony_ci	u32	MacAddrLo;
1268c2ecf20Sopenharmony_ci	u32	InfoPtrHi;
1278c2ecf20Sopenharmony_ci	u32	InfoPtrLo;
1288c2ecf20Sopenharmony_ci	u32	MultiCastHi;	/* 0x610 */
1298c2ecf20Sopenharmony_ci	u32	MultiCastLo;
1308c2ecf20Sopenharmony_ci	u32	ModeStat;
1318c2ecf20Sopenharmony_ci	u32	DmaReadCfg;
1328c2ecf20Sopenharmony_ci	u32	DmaWriteCfg;	/* 0x620 */
1338c2ecf20Sopenharmony_ci	u32	TxBufRat;
1348c2ecf20Sopenharmony_ci	u32	EvtCsm;
1358c2ecf20Sopenharmony_ci	u32	CmdCsm;
1368c2ecf20Sopenharmony_ci	u32	TuneRxCoalTicks;/* 0x630 */
1378c2ecf20Sopenharmony_ci	u32	TuneTxCoalTicks;
1388c2ecf20Sopenharmony_ci	u32	TuneStatTicks;
1398c2ecf20Sopenharmony_ci	u32	TuneMaxTxDesc;
1408c2ecf20Sopenharmony_ci	u32	TuneMaxRxDesc;	/* 0x640 */
1418c2ecf20Sopenharmony_ci	u32	TuneTrace;
1428c2ecf20Sopenharmony_ci	u32	TuneLink;
1438c2ecf20Sopenharmony_ci	u32	TuneFastLink;
1448c2ecf20Sopenharmony_ci	u32	TracePtr;	/* 0x650 */
1458c2ecf20Sopenharmony_ci	u32	TraceStrt;
1468c2ecf20Sopenharmony_ci	u32	TraceLen;
1478c2ecf20Sopenharmony_ci	u32	IfIdx;
1488c2ecf20Sopenharmony_ci	u32	IfMtu;		/* 0x660 */
1498c2ecf20Sopenharmony_ci	u32	MaskInt;
1508c2ecf20Sopenharmony_ci	u32	GigLnkState;
1518c2ecf20Sopenharmony_ci	u32	FastLnkState;
1528c2ecf20Sopenharmony_ci	u32	pad16[4];	/* 0x670 */
1538c2ecf20Sopenharmony_ci	u32	RxRetCsm;	/* 0x680 */
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ci	u32	pad17[31];
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ci	u32	CmdRng[64];	/* 0x700 */
1588c2ecf20Sopenharmony_ci	u32	Window[0x200];
1598c2ecf20Sopenharmony_ci};
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_citypedef struct {
1638c2ecf20Sopenharmony_ci	u32 addrhi;
1648c2ecf20Sopenharmony_ci	u32 addrlo;
1658c2ecf20Sopenharmony_ci} aceaddr;
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci#define ACE_WINDOW_SIZE	0x800
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci#define ACE_JUMBO_MTU 9000
1718c2ecf20Sopenharmony_ci#define ACE_STD_MTU 1500
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci#define ACE_TRACE_SIZE 0x8000
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci/*
1768c2ecf20Sopenharmony_ci * Host control register bits.
1778c2ecf20Sopenharmony_ci */
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci#define IN_INT		0x01
1808c2ecf20Sopenharmony_ci#define CLR_INT		0x02
1818c2ecf20Sopenharmony_ci#define HW_RESET	0x08
1828c2ecf20Sopenharmony_ci#define BYTE_SWAP	0x10
1838c2ecf20Sopenharmony_ci#define WORD_SWAP	0x20
1848c2ecf20Sopenharmony_ci#define MASK_INTS	0x40
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_ci/*
1878c2ecf20Sopenharmony_ci * Local control register bits.
1888c2ecf20Sopenharmony_ci */
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_ci#define EEPROM_DATA_IN		0x800000
1918c2ecf20Sopenharmony_ci#define EEPROM_DATA_OUT		0x400000
1928c2ecf20Sopenharmony_ci#define EEPROM_WRITE_ENABLE	0x200000
1938c2ecf20Sopenharmony_ci#define EEPROM_CLK_OUT		0x100000
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ci#define EEPROM_BASE		0xa0000000
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci#define EEPROM_WRITE_SELECT	0xa0
1988c2ecf20Sopenharmony_ci#define EEPROM_READ_SELECT	0xa1
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci#define SRAM_BANK_512K		0x200
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci/*
2048c2ecf20Sopenharmony_ci * udelay() values for when clocking the eeprom
2058c2ecf20Sopenharmony_ci */
2068c2ecf20Sopenharmony_ci#define ACE_SHORT_DELAY		2
2078c2ecf20Sopenharmony_ci#define ACE_LONG_DELAY		4
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ci/*
2118c2ecf20Sopenharmony_ci * Misc Config bits
2128c2ecf20Sopenharmony_ci */
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci#define SYNC_SRAM_TIMING	0x100000
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ci/*
2188c2ecf20Sopenharmony_ci * CPU state bits.
2198c2ecf20Sopenharmony_ci */
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_ci#define CPU_RESET		0x01
2228c2ecf20Sopenharmony_ci#define CPU_TRACE		0x02
2238c2ecf20Sopenharmony_ci#define CPU_PROM_FAILED		0x10
2248c2ecf20Sopenharmony_ci#define CPU_HALT		0x00010000
2258c2ecf20Sopenharmony_ci#define CPU_HALTED		0xffff0000
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_ci/*
2298c2ecf20Sopenharmony_ci * PCI State bits.
2308c2ecf20Sopenharmony_ci */
2318c2ecf20Sopenharmony_ci
2328c2ecf20Sopenharmony_ci#define DMA_READ_MAX_4		0x04
2338c2ecf20Sopenharmony_ci#define DMA_READ_MAX_16		0x08
2348c2ecf20Sopenharmony_ci#define DMA_READ_MAX_32		0x0c
2358c2ecf20Sopenharmony_ci#define DMA_READ_MAX_64		0x10
2368c2ecf20Sopenharmony_ci#define DMA_READ_MAX_128	0x14
2378c2ecf20Sopenharmony_ci#define DMA_READ_MAX_256	0x18
2388c2ecf20Sopenharmony_ci#define DMA_READ_MAX_1K		0x1c
2398c2ecf20Sopenharmony_ci#define DMA_WRITE_MAX_4		0x20
2408c2ecf20Sopenharmony_ci#define DMA_WRITE_MAX_16	0x40
2418c2ecf20Sopenharmony_ci#define DMA_WRITE_MAX_32	0x60
2428c2ecf20Sopenharmony_ci#define DMA_WRITE_MAX_64	0x80
2438c2ecf20Sopenharmony_ci#define DMA_WRITE_MAX_128	0xa0
2448c2ecf20Sopenharmony_ci#define DMA_WRITE_MAX_256	0xc0
2458c2ecf20Sopenharmony_ci#define DMA_WRITE_MAX_1K	0xe0
2468c2ecf20Sopenharmony_ci#define DMA_READ_WRITE_MASK	0xfc
2478c2ecf20Sopenharmony_ci#define MEM_READ_MULTIPLE	0x00020000
2488c2ecf20Sopenharmony_ci#define PCI_66MHZ		0x00080000
2498c2ecf20Sopenharmony_ci#define PCI_32BIT		0x00100000
2508c2ecf20Sopenharmony_ci#define DMA_WRITE_ALL_ALIGN	0x00800000
2518c2ecf20Sopenharmony_ci#define READ_CMD_MEM		0x06000000
2528c2ecf20Sopenharmony_ci#define WRITE_CMD_MEM		0x70000000
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci/*
2568c2ecf20Sopenharmony_ci * Mode status
2578c2ecf20Sopenharmony_ci */
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci#define ACE_BYTE_SWAP_BD	0x02
2608c2ecf20Sopenharmony_ci#define ACE_WORD_SWAP_BD	0x04		/* not actually used */
2618c2ecf20Sopenharmony_ci#define ACE_WARN		0x08
2628c2ecf20Sopenharmony_ci#define ACE_BYTE_SWAP_DMA	0x10
2638c2ecf20Sopenharmony_ci#define ACE_NO_JUMBO_FRAG	0x200
2648c2ecf20Sopenharmony_ci#define ACE_FATAL		0x40000000
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_ci/*
2688c2ecf20Sopenharmony_ci * DMA config
2698c2ecf20Sopenharmony_ci */
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ci#define DMA_THRESH_1W		0x10
2728c2ecf20Sopenharmony_ci#define DMA_THRESH_2W		0x20
2738c2ecf20Sopenharmony_ci#define DMA_THRESH_4W		0x40
2748c2ecf20Sopenharmony_ci#define DMA_THRESH_8W		0x80
2758c2ecf20Sopenharmony_ci#define DMA_THRESH_16W		0x100
2768c2ecf20Sopenharmony_ci#define DMA_THRESH_32W		0x0	/* not described in doc, but exists. */
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ci/*
2808c2ecf20Sopenharmony_ci * Tuning parameters
2818c2ecf20Sopenharmony_ci */
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_ci#define TICKS_PER_SEC		1000000
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_ci/*
2878c2ecf20Sopenharmony_ci * Link bits
2888c2ecf20Sopenharmony_ci */
2898c2ecf20Sopenharmony_ci
2908c2ecf20Sopenharmony_ci#define LNK_PREF		0x00008000
2918c2ecf20Sopenharmony_ci#define LNK_10MB		0x00010000
2928c2ecf20Sopenharmony_ci#define LNK_100MB		0x00020000
2938c2ecf20Sopenharmony_ci#define LNK_1000MB		0x00040000
2948c2ecf20Sopenharmony_ci#define LNK_FULL_DUPLEX		0x00080000
2958c2ecf20Sopenharmony_ci#define LNK_HALF_DUPLEX		0x00100000
2968c2ecf20Sopenharmony_ci#define LNK_TX_FLOW_CTL_Y	0x00200000
2978c2ecf20Sopenharmony_ci#define LNK_NEG_ADVANCED	0x00400000
2988c2ecf20Sopenharmony_ci#define LNK_RX_FLOW_CTL_Y	0x00800000
2998c2ecf20Sopenharmony_ci#define LNK_NIC			0x01000000
3008c2ecf20Sopenharmony_ci#define LNK_JAM			0x02000000
3018c2ecf20Sopenharmony_ci#define LNK_JUMBO		0x04000000
3028c2ecf20Sopenharmony_ci#define LNK_ALTEON		0x08000000
3038c2ecf20Sopenharmony_ci#define LNK_NEG_FCTL		0x10000000
3048c2ecf20Sopenharmony_ci#define LNK_NEGOTIATE		0x20000000
3058c2ecf20Sopenharmony_ci#define LNK_ENABLE		0x40000000
3068c2ecf20Sopenharmony_ci#define LNK_UP			0x80000000
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci/*
3108c2ecf20Sopenharmony_ci * Event definitions
3118c2ecf20Sopenharmony_ci */
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci#define EVT_RING_ENTRIES	256
3148c2ecf20Sopenharmony_ci#define EVT_RING_SIZE	(EVT_RING_ENTRIES * sizeof(struct event))
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_cistruct event {
3178c2ecf20Sopenharmony_ci#ifdef __LITTLE_ENDIAN_BITFIELD
3188c2ecf20Sopenharmony_ci	u32	idx:12;
3198c2ecf20Sopenharmony_ci	u32	code:12;
3208c2ecf20Sopenharmony_ci	u32	evt:8;
3218c2ecf20Sopenharmony_ci#else
3228c2ecf20Sopenharmony_ci	u32	evt:8;
3238c2ecf20Sopenharmony_ci	u32	code:12;
3248c2ecf20Sopenharmony_ci	u32	idx:12;
3258c2ecf20Sopenharmony_ci#endif
3268c2ecf20Sopenharmony_ci	u32     pad;
3278c2ecf20Sopenharmony_ci};
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_ci/*
3318c2ecf20Sopenharmony_ci * Events
3328c2ecf20Sopenharmony_ci */
3338c2ecf20Sopenharmony_ci
3348c2ecf20Sopenharmony_ci#define E_FW_RUNNING		0x01
3358c2ecf20Sopenharmony_ci#define E_STATS_UPDATED		0x04
3368c2ecf20Sopenharmony_ci
3378c2ecf20Sopenharmony_ci#define E_STATS_UPDATE		0x04
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci#define E_LNK_STATE		0x06
3408c2ecf20Sopenharmony_ci#define E_C_LINK_UP		0x01
3418c2ecf20Sopenharmony_ci#define E_C_LINK_DOWN		0x02
3428c2ecf20Sopenharmony_ci#define E_C_LINK_10_100		0x03
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_ci#define E_ERROR			0x07
3458c2ecf20Sopenharmony_ci#define E_C_ERR_INVAL_CMD	0x01
3468c2ecf20Sopenharmony_ci#define E_C_ERR_UNIMP_CMD	0x02
3478c2ecf20Sopenharmony_ci#define E_C_ERR_BAD_CFG		0x03
3488c2ecf20Sopenharmony_ci
3498c2ecf20Sopenharmony_ci#define E_MCAST_LIST		0x08
3508c2ecf20Sopenharmony_ci#define E_C_MCAST_ADDR_ADD	0x01
3518c2ecf20Sopenharmony_ci#define E_C_MCAST_ADDR_DEL	0x02
3528c2ecf20Sopenharmony_ci
3538c2ecf20Sopenharmony_ci#define E_RESET_JUMBO_RNG	0x09
3548c2ecf20Sopenharmony_ci
3558c2ecf20Sopenharmony_ci
3568c2ecf20Sopenharmony_ci/*
3578c2ecf20Sopenharmony_ci * Commands
3588c2ecf20Sopenharmony_ci */
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_ci#define CMD_RING_ENTRIES	64
3618c2ecf20Sopenharmony_ci
3628c2ecf20Sopenharmony_cistruct cmd {
3638c2ecf20Sopenharmony_ci#ifdef __LITTLE_ENDIAN_BITFIELD
3648c2ecf20Sopenharmony_ci	u32	idx:12;
3658c2ecf20Sopenharmony_ci	u32	code:12;
3668c2ecf20Sopenharmony_ci	u32	evt:8;
3678c2ecf20Sopenharmony_ci#else
3688c2ecf20Sopenharmony_ci	u32	evt:8;
3698c2ecf20Sopenharmony_ci	u32	code:12;
3708c2ecf20Sopenharmony_ci	u32	idx:12;
3718c2ecf20Sopenharmony_ci#endif
3728c2ecf20Sopenharmony_ci};
3738c2ecf20Sopenharmony_ci
3748c2ecf20Sopenharmony_ci
3758c2ecf20Sopenharmony_ci#define C_HOST_STATE		0x01
3768c2ecf20Sopenharmony_ci#define C_C_STACK_UP		0x01
3778c2ecf20Sopenharmony_ci#define C_C_STACK_DOWN		0x02
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ci#define C_FDR_FILTERING		0x02
3808c2ecf20Sopenharmony_ci#define C_C_FDR_FILT_ENABLE	0x01
3818c2ecf20Sopenharmony_ci#define C_C_FDR_FILT_DISABLE	0x02
3828c2ecf20Sopenharmony_ci
3838c2ecf20Sopenharmony_ci#define C_SET_RX_PRD_IDX	0x03
3848c2ecf20Sopenharmony_ci#define C_UPDATE_STATS		0x04
3858c2ecf20Sopenharmony_ci#define C_RESET_JUMBO_RNG	0x05
3868c2ecf20Sopenharmony_ci#define C_ADD_MULTICAST_ADDR	0x08
3878c2ecf20Sopenharmony_ci#define C_DEL_MULTICAST_ADDR	0x09
3888c2ecf20Sopenharmony_ci
3898c2ecf20Sopenharmony_ci#define C_SET_PROMISC_MODE	0x0a
3908c2ecf20Sopenharmony_ci#define C_C_PROMISC_ENABLE	0x01
3918c2ecf20Sopenharmony_ci#define C_C_PROMISC_DISABLE	0x02
3928c2ecf20Sopenharmony_ci
3938c2ecf20Sopenharmony_ci#define C_LNK_NEGOTIATION	0x0b
3948c2ecf20Sopenharmony_ci#define C_C_NEGOTIATE_BOTH	0x00
3958c2ecf20Sopenharmony_ci#define C_C_NEGOTIATE_GIG	0x01
3968c2ecf20Sopenharmony_ci#define C_C_NEGOTIATE_10_100	0x02
3978c2ecf20Sopenharmony_ci
3988c2ecf20Sopenharmony_ci#define C_SET_MAC_ADDR		0x0c
3998c2ecf20Sopenharmony_ci#define C_CLEAR_PROFILE		0x0d
4008c2ecf20Sopenharmony_ci
4018c2ecf20Sopenharmony_ci#define C_SET_MULTICAST_MODE	0x0e
4028c2ecf20Sopenharmony_ci#define C_C_MCAST_ENABLE	0x01
4038c2ecf20Sopenharmony_ci#define C_C_MCAST_DISABLE	0x02
4048c2ecf20Sopenharmony_ci
4058c2ecf20Sopenharmony_ci#define C_CLEAR_STATS		0x0f
4068c2ecf20Sopenharmony_ci#define C_SET_RX_JUMBO_PRD_IDX	0x10
4078c2ecf20Sopenharmony_ci#define C_REFRESH_STATS		0x11
4088c2ecf20Sopenharmony_ci
4098c2ecf20Sopenharmony_ci
4108c2ecf20Sopenharmony_ci/*
4118c2ecf20Sopenharmony_ci * Descriptor flags
4128c2ecf20Sopenharmony_ci */
4138c2ecf20Sopenharmony_ci#define BD_FLG_TCP_UDP_SUM	0x01
4148c2ecf20Sopenharmony_ci#define BD_FLG_IP_SUM		0x02
4158c2ecf20Sopenharmony_ci#define BD_FLG_END		0x04
4168c2ecf20Sopenharmony_ci#define BD_FLG_MORE		0x08
4178c2ecf20Sopenharmony_ci#define BD_FLG_JUMBO		0x10
4188c2ecf20Sopenharmony_ci#define BD_FLG_UCAST		0x20
4198c2ecf20Sopenharmony_ci#define BD_FLG_MCAST		0x40
4208c2ecf20Sopenharmony_ci#define BD_FLG_BCAST		0x60
4218c2ecf20Sopenharmony_ci#define BD_FLG_TYP_MASK		0x60
4228c2ecf20Sopenharmony_ci#define BD_FLG_IP_FRAG		0x80
4238c2ecf20Sopenharmony_ci#define BD_FLG_IP_FRAG_END	0x100
4248c2ecf20Sopenharmony_ci#define BD_FLG_VLAN_TAG		0x200
4258c2ecf20Sopenharmony_ci#define BD_FLG_FRAME_ERROR	0x400
4268c2ecf20Sopenharmony_ci#define BD_FLG_COAL_NOW		0x800
4278c2ecf20Sopenharmony_ci#define BD_FLG_MINI		0x1000
4288c2ecf20Sopenharmony_ci
4298c2ecf20Sopenharmony_ci
4308c2ecf20Sopenharmony_ci/*
4318c2ecf20Sopenharmony_ci * Ring Control block flags
4328c2ecf20Sopenharmony_ci */
4338c2ecf20Sopenharmony_ci#define RCB_FLG_TCP_UDP_SUM	0x01
4348c2ecf20Sopenharmony_ci#define RCB_FLG_IP_SUM		0x02
4358c2ecf20Sopenharmony_ci#define RCB_FLG_NO_PSEUDO_HDR	0x08
4368c2ecf20Sopenharmony_ci#define RCB_FLG_VLAN_ASSIST	0x10
4378c2ecf20Sopenharmony_ci#define RCB_FLG_COAL_INT_ONLY	0x20
4388c2ecf20Sopenharmony_ci#define RCB_FLG_TX_HOST_RING	0x40
4398c2ecf20Sopenharmony_ci#define RCB_FLG_IEEE_SNAP_SUM	0x80
4408c2ecf20Sopenharmony_ci#define RCB_FLG_EXT_RX_BD	0x100
4418c2ecf20Sopenharmony_ci#define RCB_FLG_RNG_DISABLE	0x200
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_ci
4448c2ecf20Sopenharmony_ci/*
4458c2ecf20Sopenharmony_ci * TX ring - maximum TX ring entries for Tigon I's is 128
4468c2ecf20Sopenharmony_ci */
4478c2ecf20Sopenharmony_ci#define MAX_TX_RING_ENTRIES	256
4488c2ecf20Sopenharmony_ci#define TIGON_I_TX_RING_ENTRIES	128
4498c2ecf20Sopenharmony_ci#define TX_RING_SIZE		(MAX_TX_RING_ENTRIES * sizeof(struct tx_desc))
4508c2ecf20Sopenharmony_ci#define TX_RING_BASE		0x3800
4518c2ecf20Sopenharmony_ci
4528c2ecf20Sopenharmony_cistruct tx_desc{
4538c2ecf20Sopenharmony_ci        aceaddr	addr;
4548c2ecf20Sopenharmony_ci	u32	flagsize;
4558c2ecf20Sopenharmony_ci#if 0
4568c2ecf20Sopenharmony_ci/*
4578c2ecf20Sopenharmony_ci * This is in PCI shared mem and must be accessed with readl/writel
4588c2ecf20Sopenharmony_ci * real layout is:
4598c2ecf20Sopenharmony_ci */
4608c2ecf20Sopenharmony_ci#if __LITTLE_ENDIAN
4618c2ecf20Sopenharmony_ci	u16	flags;
4628c2ecf20Sopenharmony_ci	u16	size;
4638c2ecf20Sopenharmony_ci	u16	vlan;
4648c2ecf20Sopenharmony_ci	u16	reserved;
4658c2ecf20Sopenharmony_ci#else
4668c2ecf20Sopenharmony_ci	u16	size;
4678c2ecf20Sopenharmony_ci	u16	flags;
4688c2ecf20Sopenharmony_ci	u16	reserved;
4698c2ecf20Sopenharmony_ci	u16	vlan;
4708c2ecf20Sopenharmony_ci#endif
4718c2ecf20Sopenharmony_ci#endif
4728c2ecf20Sopenharmony_ci	u32	vlanres;
4738c2ecf20Sopenharmony_ci};
4748c2ecf20Sopenharmony_ci
4758c2ecf20Sopenharmony_ci
4768c2ecf20Sopenharmony_ci#define RX_STD_RING_ENTRIES	512
4778c2ecf20Sopenharmony_ci#define RX_STD_RING_SIZE	(RX_STD_RING_ENTRIES * sizeof(struct rx_desc))
4788c2ecf20Sopenharmony_ci
4798c2ecf20Sopenharmony_ci#define RX_JUMBO_RING_ENTRIES	256
4808c2ecf20Sopenharmony_ci#define RX_JUMBO_RING_SIZE	(RX_JUMBO_RING_ENTRIES *sizeof(struct rx_desc))
4818c2ecf20Sopenharmony_ci
4828c2ecf20Sopenharmony_ci#define RX_MINI_RING_ENTRIES	1024
4838c2ecf20Sopenharmony_ci#define RX_MINI_RING_SIZE	(RX_MINI_RING_ENTRIES *sizeof(struct rx_desc))
4848c2ecf20Sopenharmony_ci
4858c2ecf20Sopenharmony_ci#define RX_RETURN_RING_ENTRIES	2048
4868c2ecf20Sopenharmony_ci#define RX_RETURN_RING_SIZE	(RX_MAX_RETURN_RING_ENTRIES * \
4878c2ecf20Sopenharmony_ci				 sizeof(struct rx_desc))
4888c2ecf20Sopenharmony_ci
4898c2ecf20Sopenharmony_cistruct rx_desc{
4908c2ecf20Sopenharmony_ci	aceaddr	addr;
4918c2ecf20Sopenharmony_ci#ifdef __LITTLE_ENDIAN
4928c2ecf20Sopenharmony_ci	u16	size;
4938c2ecf20Sopenharmony_ci	u16	idx;
4948c2ecf20Sopenharmony_ci#else
4958c2ecf20Sopenharmony_ci	u16	idx;
4968c2ecf20Sopenharmony_ci	u16	size;
4978c2ecf20Sopenharmony_ci#endif
4988c2ecf20Sopenharmony_ci#ifdef __LITTLE_ENDIAN
4998c2ecf20Sopenharmony_ci	u16	flags;
5008c2ecf20Sopenharmony_ci	u16	type;
5018c2ecf20Sopenharmony_ci#else
5028c2ecf20Sopenharmony_ci	u16	type;
5038c2ecf20Sopenharmony_ci	u16	flags;
5048c2ecf20Sopenharmony_ci#endif
5058c2ecf20Sopenharmony_ci#ifdef __LITTLE_ENDIAN
5068c2ecf20Sopenharmony_ci	u16	tcp_udp_csum;
5078c2ecf20Sopenharmony_ci	u16	ip_csum;
5088c2ecf20Sopenharmony_ci#else
5098c2ecf20Sopenharmony_ci	u16	ip_csum;
5108c2ecf20Sopenharmony_ci	u16	tcp_udp_csum;
5118c2ecf20Sopenharmony_ci#endif
5128c2ecf20Sopenharmony_ci#ifdef __LITTLE_ENDIAN
5138c2ecf20Sopenharmony_ci	u16	vlan;
5148c2ecf20Sopenharmony_ci	u16	err_flags;
5158c2ecf20Sopenharmony_ci#else
5168c2ecf20Sopenharmony_ci	u16	err_flags;
5178c2ecf20Sopenharmony_ci	u16	vlan;
5188c2ecf20Sopenharmony_ci#endif
5198c2ecf20Sopenharmony_ci	u32	reserved;
5208c2ecf20Sopenharmony_ci	u32	opague;
5218c2ecf20Sopenharmony_ci};
5228c2ecf20Sopenharmony_ci
5238c2ecf20Sopenharmony_ci
5248c2ecf20Sopenharmony_ci/*
5258c2ecf20Sopenharmony_ci * This struct is shared with the NIC firmware.
5268c2ecf20Sopenharmony_ci */
5278c2ecf20Sopenharmony_cistruct ring_ctrl {
5288c2ecf20Sopenharmony_ci	aceaddr	rngptr;
5298c2ecf20Sopenharmony_ci#ifdef __LITTLE_ENDIAN
5308c2ecf20Sopenharmony_ci	u16	flags;
5318c2ecf20Sopenharmony_ci	u16	max_len;
5328c2ecf20Sopenharmony_ci#else
5338c2ecf20Sopenharmony_ci	u16	max_len;
5348c2ecf20Sopenharmony_ci	u16	flags;
5358c2ecf20Sopenharmony_ci#endif
5368c2ecf20Sopenharmony_ci	u32	pad;
5378c2ecf20Sopenharmony_ci};
5388c2ecf20Sopenharmony_ci
5398c2ecf20Sopenharmony_ci
5408c2ecf20Sopenharmony_cistruct ace_mac_stats {
5418c2ecf20Sopenharmony_ci	u32 excess_colls;
5428c2ecf20Sopenharmony_ci	u32 coll_1;
5438c2ecf20Sopenharmony_ci	u32 coll_2;
5448c2ecf20Sopenharmony_ci	u32 coll_3;
5458c2ecf20Sopenharmony_ci	u32 coll_4;
5468c2ecf20Sopenharmony_ci	u32 coll_5;
5478c2ecf20Sopenharmony_ci	u32 coll_6;
5488c2ecf20Sopenharmony_ci	u32 coll_7;
5498c2ecf20Sopenharmony_ci	u32 coll_8;
5508c2ecf20Sopenharmony_ci	u32 coll_9;
5518c2ecf20Sopenharmony_ci	u32 coll_10;
5528c2ecf20Sopenharmony_ci	u32 coll_11;
5538c2ecf20Sopenharmony_ci	u32 coll_12;
5548c2ecf20Sopenharmony_ci	u32 coll_13;
5558c2ecf20Sopenharmony_ci	u32 coll_14;
5568c2ecf20Sopenharmony_ci	u32 coll_15;
5578c2ecf20Sopenharmony_ci	u32 late_coll;
5588c2ecf20Sopenharmony_ci	u32 defers;
5598c2ecf20Sopenharmony_ci	u32 crc_err;
5608c2ecf20Sopenharmony_ci	u32 underrun;
5618c2ecf20Sopenharmony_ci	u32 crs_err;
5628c2ecf20Sopenharmony_ci	u32 pad[3];
5638c2ecf20Sopenharmony_ci	u32 drop_ula;
5648c2ecf20Sopenharmony_ci	u32 drop_mc;
5658c2ecf20Sopenharmony_ci	u32 drop_fc;
5668c2ecf20Sopenharmony_ci	u32 drop_space;
5678c2ecf20Sopenharmony_ci	u32 coll;
5688c2ecf20Sopenharmony_ci	u32 kept_bc;
5698c2ecf20Sopenharmony_ci	u32 kept_mc;
5708c2ecf20Sopenharmony_ci	u32 kept_uc;
5718c2ecf20Sopenharmony_ci};
5728c2ecf20Sopenharmony_ci
5738c2ecf20Sopenharmony_ci
5748c2ecf20Sopenharmony_cistruct ace_info {
5758c2ecf20Sopenharmony_ci	union {
5768c2ecf20Sopenharmony_ci		u32 stats[256];
5778c2ecf20Sopenharmony_ci	} s;
5788c2ecf20Sopenharmony_ci	struct ring_ctrl	evt_ctrl;
5798c2ecf20Sopenharmony_ci	struct ring_ctrl	cmd_ctrl;
5808c2ecf20Sopenharmony_ci	struct ring_ctrl	tx_ctrl;
5818c2ecf20Sopenharmony_ci	struct ring_ctrl	rx_std_ctrl;
5828c2ecf20Sopenharmony_ci	struct ring_ctrl	rx_jumbo_ctrl;
5838c2ecf20Sopenharmony_ci	struct ring_ctrl	rx_mini_ctrl;
5848c2ecf20Sopenharmony_ci	struct ring_ctrl	rx_return_ctrl;
5858c2ecf20Sopenharmony_ci	aceaddr	evt_prd_ptr;
5868c2ecf20Sopenharmony_ci	aceaddr	rx_ret_prd_ptr;
5878c2ecf20Sopenharmony_ci	aceaddr	tx_csm_ptr;
5888c2ecf20Sopenharmony_ci	aceaddr	stats2_ptr;
5898c2ecf20Sopenharmony_ci};
5908c2ecf20Sopenharmony_ci
5918c2ecf20Sopenharmony_ci
5928c2ecf20Sopenharmony_cistruct ring_info {
5938c2ecf20Sopenharmony_ci	struct sk_buff		*skb;
5948c2ecf20Sopenharmony_ci	DEFINE_DMA_UNMAP_ADDR(mapping);
5958c2ecf20Sopenharmony_ci};
5968c2ecf20Sopenharmony_ci
5978c2ecf20Sopenharmony_ci
5988c2ecf20Sopenharmony_ci/*
5998c2ecf20Sopenharmony_ci * Funny... As soon as we add maplen on alpha, it starts to work
6008c2ecf20Sopenharmony_ci * much slower. Hmm... is it because struct does not fit to one cacheline?
6018c2ecf20Sopenharmony_ci * So, split tx_ring_info.
6028c2ecf20Sopenharmony_ci */
6038c2ecf20Sopenharmony_cistruct tx_ring_info {
6048c2ecf20Sopenharmony_ci	struct sk_buff		*skb;
6058c2ecf20Sopenharmony_ci	DEFINE_DMA_UNMAP_ADDR(mapping);
6068c2ecf20Sopenharmony_ci	DEFINE_DMA_UNMAP_LEN(maplen);
6078c2ecf20Sopenharmony_ci};
6088c2ecf20Sopenharmony_ci
6098c2ecf20Sopenharmony_ci
6108c2ecf20Sopenharmony_ci/*
6118c2ecf20Sopenharmony_ci * struct ace_skb holding the rings of skb's. This is an awful lot of
6128c2ecf20Sopenharmony_ci * pointers, but I don't see any other smart mode to do this in an
6138c2ecf20Sopenharmony_ci * efficient manner ;-(
6148c2ecf20Sopenharmony_ci */
6158c2ecf20Sopenharmony_cistruct ace_skb
6168c2ecf20Sopenharmony_ci{
6178c2ecf20Sopenharmony_ci	struct tx_ring_info	tx_skbuff[MAX_TX_RING_ENTRIES];
6188c2ecf20Sopenharmony_ci	struct ring_info	rx_std_skbuff[RX_STD_RING_ENTRIES];
6198c2ecf20Sopenharmony_ci	struct ring_info	rx_mini_skbuff[RX_MINI_RING_ENTRIES];
6208c2ecf20Sopenharmony_ci	struct ring_info	rx_jumbo_skbuff[RX_JUMBO_RING_ENTRIES];
6218c2ecf20Sopenharmony_ci};
6228c2ecf20Sopenharmony_ci
6238c2ecf20Sopenharmony_ci
6248c2ecf20Sopenharmony_ci/*
6258c2ecf20Sopenharmony_ci * Struct private for the AceNIC.
6268c2ecf20Sopenharmony_ci *
6278c2ecf20Sopenharmony_ci * Elements are grouped so variables used by the tx handling goes
6288c2ecf20Sopenharmony_ci * together, and will go into the same cache lines etc. in order to
6298c2ecf20Sopenharmony_ci * avoid cache line contention between the rx and tx handling on SMP.
6308c2ecf20Sopenharmony_ci *
6318c2ecf20Sopenharmony_ci * Frequently accessed variables are put at the beginning of the
6328c2ecf20Sopenharmony_ci * struct to help the compiler generate better/shorter code.
6338c2ecf20Sopenharmony_ci */
6348c2ecf20Sopenharmony_cistruct ace_private
6358c2ecf20Sopenharmony_ci{
6368c2ecf20Sopenharmony_ci	struct net_device	*ndev;		/* backpointer */
6378c2ecf20Sopenharmony_ci	struct ace_info		*info;
6388c2ecf20Sopenharmony_ci	struct ace_regs	__iomem	*regs;		/* register base */
6398c2ecf20Sopenharmony_ci	struct ace_skb		*skb;
6408c2ecf20Sopenharmony_ci	dma_addr_t		info_dma;	/* 32/64 bit */
6418c2ecf20Sopenharmony_ci
6428c2ecf20Sopenharmony_ci	int			version, link;
6438c2ecf20Sopenharmony_ci	int			promisc, mcast_all;
6448c2ecf20Sopenharmony_ci
6458c2ecf20Sopenharmony_ci	/*
6468c2ecf20Sopenharmony_ci	 * TX elements
6478c2ecf20Sopenharmony_ci	 */
6488c2ecf20Sopenharmony_ci	struct tx_desc		*tx_ring;
6498c2ecf20Sopenharmony_ci	u32			tx_prd;
6508c2ecf20Sopenharmony_ci	volatile u32		tx_ret_csm;
6518c2ecf20Sopenharmony_ci	int			tx_ring_entries;
6528c2ecf20Sopenharmony_ci
6538c2ecf20Sopenharmony_ci	/*
6548c2ecf20Sopenharmony_ci	 * RX elements
6558c2ecf20Sopenharmony_ci	 */
6568c2ecf20Sopenharmony_ci	unsigned long		std_refill_busy
6578c2ecf20Sopenharmony_ci				__attribute__ ((aligned (SMP_CACHE_BYTES)));
6588c2ecf20Sopenharmony_ci	unsigned long		mini_refill_busy, jumbo_refill_busy;
6598c2ecf20Sopenharmony_ci	atomic_t		cur_rx_bufs;
6608c2ecf20Sopenharmony_ci	atomic_t		cur_mini_bufs;
6618c2ecf20Sopenharmony_ci	atomic_t		cur_jumbo_bufs;
6628c2ecf20Sopenharmony_ci	u32			rx_std_skbprd, rx_mini_skbprd, rx_jumbo_skbprd;
6638c2ecf20Sopenharmony_ci	u32			cur_rx;
6648c2ecf20Sopenharmony_ci
6658c2ecf20Sopenharmony_ci	struct rx_desc		*rx_std_ring;
6668c2ecf20Sopenharmony_ci	struct rx_desc		*rx_jumbo_ring;
6678c2ecf20Sopenharmony_ci	struct rx_desc		*rx_mini_ring;
6688c2ecf20Sopenharmony_ci	struct rx_desc		*rx_return_ring;
6698c2ecf20Sopenharmony_ci
6708c2ecf20Sopenharmony_ci	int			tasklet_pending, jumbo;
6718c2ecf20Sopenharmony_ci	struct tasklet_struct	ace_tasklet;
6728c2ecf20Sopenharmony_ci
6738c2ecf20Sopenharmony_ci	struct event		*evt_ring;
6748c2ecf20Sopenharmony_ci
6758c2ecf20Sopenharmony_ci	volatile u32		*evt_prd, *rx_ret_prd, *tx_csm;
6768c2ecf20Sopenharmony_ci
6778c2ecf20Sopenharmony_ci	dma_addr_t		tx_ring_dma;	/* 32/64 bit */
6788c2ecf20Sopenharmony_ci	dma_addr_t		rx_ring_base_dma;
6798c2ecf20Sopenharmony_ci	dma_addr_t		evt_ring_dma;
6808c2ecf20Sopenharmony_ci	dma_addr_t		evt_prd_dma, rx_ret_prd_dma, tx_csm_dma;
6818c2ecf20Sopenharmony_ci
6828c2ecf20Sopenharmony_ci	unsigned char		*trace_buf;
6838c2ecf20Sopenharmony_ci	struct pci_dev		*pdev;
6848c2ecf20Sopenharmony_ci	struct net_device	*next;
6858c2ecf20Sopenharmony_ci	volatile int		fw_running;
6868c2ecf20Sopenharmony_ci	int			board_idx;
6878c2ecf20Sopenharmony_ci	u16			pci_command;
6888c2ecf20Sopenharmony_ci	u8			pci_latency;
6898c2ecf20Sopenharmony_ci	const char		*name;
6908c2ecf20Sopenharmony_ci#ifdef INDEX_DEBUG
6918c2ecf20Sopenharmony_ci	spinlock_t		debug_lock
6928c2ecf20Sopenharmony_ci				__attribute__ ((aligned (SMP_CACHE_BYTES)));
6938c2ecf20Sopenharmony_ci	u32			last_tx, last_std_rx, last_mini_rx;
6948c2ecf20Sopenharmony_ci#endif
6958c2ecf20Sopenharmony_ci	int			pci_using_dac;
6968c2ecf20Sopenharmony_ci	u8			firmware_major;
6978c2ecf20Sopenharmony_ci	u8			firmware_minor;
6988c2ecf20Sopenharmony_ci	u8			firmware_fix;
6998c2ecf20Sopenharmony_ci	u32			firmware_start;
7008c2ecf20Sopenharmony_ci};
7018c2ecf20Sopenharmony_ci
7028c2ecf20Sopenharmony_ci
7038c2ecf20Sopenharmony_ci#define TX_RESERVED	MAX_SKB_FRAGS
7048c2ecf20Sopenharmony_ci
7058c2ecf20Sopenharmony_cistatic inline int tx_space (struct ace_private *ap, u32 csm, u32 prd)
7068c2ecf20Sopenharmony_ci{
7078c2ecf20Sopenharmony_ci	return (csm - prd - 1) & (ACE_TX_RING_ENTRIES(ap) - 1);
7088c2ecf20Sopenharmony_ci}
7098c2ecf20Sopenharmony_ci
7108c2ecf20Sopenharmony_ci#define tx_free(ap) 		tx_space((ap)->tx_ret_csm, (ap)->tx_prd, ap)
7118c2ecf20Sopenharmony_ci#define tx_ring_full(ap, csm, prd)	(tx_space(ap, csm, prd) <= TX_RESERVED)
7128c2ecf20Sopenharmony_ci
7138c2ecf20Sopenharmony_cistatic inline void set_aceaddr(aceaddr *aa, dma_addr_t addr)
7148c2ecf20Sopenharmony_ci{
7158c2ecf20Sopenharmony_ci	u64 baddr = (u64) addr;
7168c2ecf20Sopenharmony_ci	aa->addrlo = baddr & 0xffffffff;
7178c2ecf20Sopenharmony_ci	aa->addrhi = baddr >> 32;
7188c2ecf20Sopenharmony_ci	wmb();
7198c2ecf20Sopenharmony_ci}
7208c2ecf20Sopenharmony_ci
7218c2ecf20Sopenharmony_ci
7228c2ecf20Sopenharmony_cistatic inline void ace_set_txprd(struct ace_regs __iomem *regs,
7238c2ecf20Sopenharmony_ci				 struct ace_private *ap, u32 value)
7248c2ecf20Sopenharmony_ci{
7258c2ecf20Sopenharmony_ci#ifdef INDEX_DEBUG
7268c2ecf20Sopenharmony_ci	unsigned long flags;
7278c2ecf20Sopenharmony_ci	spin_lock_irqsave(&ap->debug_lock, flags);
7288c2ecf20Sopenharmony_ci	writel(value, &regs->TxPrd);
7298c2ecf20Sopenharmony_ci	if (value == ap->last_tx)
7308c2ecf20Sopenharmony_ci		printk(KERN_ERR "AceNIC RACE ALERT! writing identical value "
7318c2ecf20Sopenharmony_ci		       "to tx producer (%i)\n", value);
7328c2ecf20Sopenharmony_ci	ap->last_tx = value;
7338c2ecf20Sopenharmony_ci	spin_unlock_irqrestore(&ap->debug_lock, flags);
7348c2ecf20Sopenharmony_ci#else
7358c2ecf20Sopenharmony_ci	writel(value, &regs->TxPrd);
7368c2ecf20Sopenharmony_ci#endif
7378c2ecf20Sopenharmony_ci	wmb();
7388c2ecf20Sopenharmony_ci}
7398c2ecf20Sopenharmony_ci
7408c2ecf20Sopenharmony_ci
7418c2ecf20Sopenharmony_cistatic inline void ace_mask_irq(struct net_device *dev)
7428c2ecf20Sopenharmony_ci{
7438c2ecf20Sopenharmony_ci	struct ace_private *ap = netdev_priv(dev);
7448c2ecf20Sopenharmony_ci	struct ace_regs __iomem *regs = ap->regs;
7458c2ecf20Sopenharmony_ci
7468c2ecf20Sopenharmony_ci	if (ACE_IS_TIGON_I(ap))
7478c2ecf20Sopenharmony_ci		writel(1, &regs->MaskInt);
7488c2ecf20Sopenharmony_ci	else
7498c2ecf20Sopenharmony_ci		writel(readl(&regs->HostCtrl) | MASK_INTS, &regs->HostCtrl);
7508c2ecf20Sopenharmony_ci
7518c2ecf20Sopenharmony_ci	ace_sync_irq(dev->irq);
7528c2ecf20Sopenharmony_ci}
7538c2ecf20Sopenharmony_ci
7548c2ecf20Sopenharmony_ci
7558c2ecf20Sopenharmony_cistatic inline void ace_unmask_irq(struct net_device *dev)
7568c2ecf20Sopenharmony_ci{
7578c2ecf20Sopenharmony_ci	struct ace_private *ap = netdev_priv(dev);
7588c2ecf20Sopenharmony_ci	struct ace_regs __iomem *regs = ap->regs;
7598c2ecf20Sopenharmony_ci
7608c2ecf20Sopenharmony_ci	if (ACE_IS_TIGON_I(ap))
7618c2ecf20Sopenharmony_ci		writel(0, &regs->MaskInt);
7628c2ecf20Sopenharmony_ci	else
7638c2ecf20Sopenharmony_ci		writel(readl(&regs->HostCtrl) & ~MASK_INTS, &regs->HostCtrl);
7648c2ecf20Sopenharmony_ci}
7658c2ecf20Sopenharmony_ci
7668c2ecf20Sopenharmony_ci
7678c2ecf20Sopenharmony_ci/*
7688c2ecf20Sopenharmony_ci * Prototypes
7698c2ecf20Sopenharmony_ci */
7708c2ecf20Sopenharmony_cistatic int ace_init(struct net_device *dev);
7718c2ecf20Sopenharmony_cistatic void ace_load_std_rx_ring(struct net_device *dev, int nr_bufs);
7728c2ecf20Sopenharmony_cistatic void ace_load_mini_rx_ring(struct net_device *dev, int nr_bufs);
7738c2ecf20Sopenharmony_cistatic void ace_load_jumbo_rx_ring(struct net_device *dev, int nr_bufs);
7748c2ecf20Sopenharmony_cistatic irqreturn_t ace_interrupt(int irq, void *dev_id);
7758c2ecf20Sopenharmony_cistatic int ace_load_firmware(struct net_device *dev);
7768c2ecf20Sopenharmony_cistatic int ace_open(struct net_device *dev);
7778c2ecf20Sopenharmony_cistatic netdev_tx_t ace_start_xmit(struct sk_buff *skb,
7788c2ecf20Sopenharmony_ci				  struct net_device *dev);
7798c2ecf20Sopenharmony_cistatic int ace_close(struct net_device *dev);
7808c2ecf20Sopenharmony_cistatic void ace_tasklet(struct tasklet_struct *t);
7818c2ecf20Sopenharmony_cistatic void ace_dump_trace(struct ace_private *ap);
7828c2ecf20Sopenharmony_cistatic void ace_set_multicast_list(struct net_device *dev);
7838c2ecf20Sopenharmony_cistatic int ace_change_mtu(struct net_device *dev, int new_mtu);
7848c2ecf20Sopenharmony_cistatic int ace_set_mac_addr(struct net_device *dev, void *p);
7858c2ecf20Sopenharmony_cistatic void ace_set_rxtx_parms(struct net_device *dev, int jumbo);
7868c2ecf20Sopenharmony_cistatic int ace_allocate_descriptors(struct net_device *dev);
7878c2ecf20Sopenharmony_cistatic void ace_free_descriptors(struct net_device *dev);
7888c2ecf20Sopenharmony_cistatic void ace_init_cleanup(struct net_device *dev);
7898c2ecf20Sopenharmony_cistatic struct net_device_stats *ace_get_stats(struct net_device *dev);
7908c2ecf20Sopenharmony_cistatic int read_eeprom_byte(struct net_device *dev, unsigned long offset);
7918c2ecf20Sopenharmony_ci
7928c2ecf20Sopenharmony_ci#endif /* _ACENIC_H_ */
793