162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Network device driver for Cell Processor-Based Blade and Celleb platform
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * (C) Copyright IBM Corp. 2005
662306a36Sopenharmony_ci * (C) Copyright 2006 TOSHIBA CORPORATION
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci * Authors : Utz Bacher <utz.bacher@de.ibm.com>
962306a36Sopenharmony_ci *           Jens Osterkamp <Jens.Osterkamp@de.ibm.com>
1062306a36Sopenharmony_ci */
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#ifndef _SPIDER_NET_H
1362306a36Sopenharmony_ci#define _SPIDER_NET_H
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#define VERSION "2.0 B"
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci#include <linux/sungem_phy.h>
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ciint spider_net_stop(struct net_device *netdev);
2062306a36Sopenharmony_ciint spider_net_open(struct net_device *netdev);
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ciextern const struct ethtool_ops spider_net_ethtool_ops;
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ciextern char spider_net_driver_name[];
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci#define SPIDER_NET_MAX_FRAME			2312
2762306a36Sopenharmony_ci#define SPIDER_NET_MAX_MTU			2294
2862306a36Sopenharmony_ci#define SPIDER_NET_MIN_MTU			64
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci#define SPIDER_NET_RXBUF_ALIGN			128
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci#define SPIDER_NET_RX_DESCRIPTORS_DEFAULT	256
3362306a36Sopenharmony_ci#define SPIDER_NET_RX_DESCRIPTORS_MIN		16
3462306a36Sopenharmony_ci#define SPIDER_NET_RX_DESCRIPTORS_MAX		512
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci#define SPIDER_NET_TX_DESCRIPTORS_DEFAULT	256
3762306a36Sopenharmony_ci#define SPIDER_NET_TX_DESCRIPTORS_MIN		16
3862306a36Sopenharmony_ci#define SPIDER_NET_TX_DESCRIPTORS_MAX		512
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci#define SPIDER_NET_TX_TIMER			(HZ/5)
4162306a36Sopenharmony_ci#define SPIDER_NET_ANEG_TIMER			(HZ)
4262306a36Sopenharmony_ci#define SPIDER_NET_ANEG_TIMEOUT			5
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci#define SPIDER_NET_RX_CSUM_DEFAULT		1
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci#define SPIDER_NET_WATCHDOG_TIMEOUT		50*HZ
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci#define SPIDER_NET_FIRMWARE_SEQS	6
4962306a36Sopenharmony_ci#define SPIDER_NET_FIRMWARE_SEQWORDS	1024
5062306a36Sopenharmony_ci#define SPIDER_NET_FIRMWARE_LEN		(SPIDER_NET_FIRMWARE_SEQS * \
5162306a36Sopenharmony_ci					 SPIDER_NET_FIRMWARE_SEQWORDS * \
5262306a36Sopenharmony_ci					 sizeof(u32))
5362306a36Sopenharmony_ci#define SPIDER_NET_FIRMWARE_NAME	"spider_fw.bin"
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci/** spider_net SMMIO registers */
5662306a36Sopenharmony_ci#define SPIDER_NET_GHIINT0STS		0x00000000
5762306a36Sopenharmony_ci#define SPIDER_NET_GHIINT1STS		0x00000004
5862306a36Sopenharmony_ci#define SPIDER_NET_GHIINT2STS		0x00000008
5962306a36Sopenharmony_ci#define SPIDER_NET_GHIINT0MSK		0x00000010
6062306a36Sopenharmony_ci#define SPIDER_NET_GHIINT1MSK		0x00000014
6162306a36Sopenharmony_ci#define SPIDER_NET_GHIINT2MSK		0x00000018
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci#define SPIDER_NET_GRESUMINTNUM		0x00000020
6462306a36Sopenharmony_ci#define SPIDER_NET_GREINTNUM		0x00000024
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ci#define SPIDER_NET_GFFRMNUM		0x00000028
6762306a36Sopenharmony_ci#define SPIDER_NET_GFAFRMNUM		0x0000002c
6862306a36Sopenharmony_ci#define SPIDER_NET_GFBFRMNUM		0x00000030
6962306a36Sopenharmony_ci#define SPIDER_NET_GFCFRMNUM		0x00000034
7062306a36Sopenharmony_ci#define SPIDER_NET_GFDFRMNUM		0x00000038
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci/* clear them (don't use it) */
7362306a36Sopenharmony_ci#define SPIDER_NET_GFREECNNUM		0x0000003c
7462306a36Sopenharmony_ci#define SPIDER_NET_GONETIMENUM		0x00000040
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci#define SPIDER_NET_GTOUTFRMNUM		0x00000044
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci#define SPIDER_NET_GTXMDSET		0x00000050
7962306a36Sopenharmony_ci#define SPIDER_NET_GPCCTRL		0x00000054
8062306a36Sopenharmony_ci#define SPIDER_NET_GRXMDSET		0x00000058
8162306a36Sopenharmony_ci#define SPIDER_NET_GIPSECINIT		0x0000005c
8262306a36Sopenharmony_ci#define SPIDER_NET_GFTRESTRT		0x00000060
8362306a36Sopenharmony_ci#define SPIDER_NET_GRXDMAEN		0x00000064
8462306a36Sopenharmony_ci#define SPIDER_NET_GMRWOLCTRL		0x00000068
8562306a36Sopenharmony_ci#define SPIDER_NET_GPCWOPCMD		0x0000006c
8662306a36Sopenharmony_ci#define SPIDER_NET_GPCROPCMD		0x00000070
8762306a36Sopenharmony_ci#define SPIDER_NET_GTTFRMCNT		0x00000078
8862306a36Sopenharmony_ci#define SPIDER_NET_GTESTMD		0x0000007c
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci#define SPIDER_NET_GSINIT		0x00000080
9162306a36Sopenharmony_ci#define SPIDER_NET_GSnPRGADR		0x00000084
9262306a36Sopenharmony_ci#define SPIDER_NET_GSnPRGDAT		0x00000088
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci#define SPIDER_NET_GMACOPEMD		0x00000100
9562306a36Sopenharmony_ci#define SPIDER_NET_GMACLENLMT		0x00000108
9662306a36Sopenharmony_ci#define SPIDER_NET_GMACST		0x00000110
9762306a36Sopenharmony_ci#define SPIDER_NET_GMACINTEN		0x00000118
9862306a36Sopenharmony_ci#define SPIDER_NET_GMACPHYCTRL		0x00000120
9962306a36Sopenharmony_ci
10062306a36Sopenharmony_ci#define SPIDER_NET_GMACAPAUSE		0x00000154
10162306a36Sopenharmony_ci#define SPIDER_NET_GMACTXPAUSE		0x00000164
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ci#define SPIDER_NET_GMACMODE		0x000001b0
10462306a36Sopenharmony_ci#define SPIDER_NET_GMACBSTLMT		0x000001b4
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci#define SPIDER_NET_GMACUNIMACU		0x000001c0
10762306a36Sopenharmony_ci#define SPIDER_NET_GMACUNIMACL		0x000001c8
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci#define SPIDER_NET_GMRMHFILnR		0x00000400
11062306a36Sopenharmony_ci#define SPIDER_NET_MULTICAST_HASHES	256
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci#define SPIDER_NET_GMRUAFILnR		0x00000500
11362306a36Sopenharmony_ci#define SPIDER_NET_GMRUA0FIL15R		0x00000578
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_ci#define SPIDER_NET_GTTQMSK		0x00000934
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ci/* RX DMA controller registers, all 0x00000a.. are for DMA controller A,
11862306a36Sopenharmony_ci * 0x00000b.. for DMA controller B, etc. */
11962306a36Sopenharmony_ci#define SPIDER_NET_GDADCHA		0x00000a00
12062306a36Sopenharmony_ci#define SPIDER_NET_GDADMACCNTR		0x00000a04
12162306a36Sopenharmony_ci#define SPIDER_NET_GDACTDPA		0x00000a08
12262306a36Sopenharmony_ci#define SPIDER_NET_GDACTDCNT		0x00000a0c
12362306a36Sopenharmony_ci#define SPIDER_NET_GDACDBADDR		0x00000a20
12462306a36Sopenharmony_ci#define SPIDER_NET_GDACDBSIZE		0x00000a24
12562306a36Sopenharmony_ci#define SPIDER_NET_GDACNEXTDA		0x00000a28
12662306a36Sopenharmony_ci#define SPIDER_NET_GDACCOMST		0x00000a2c
12762306a36Sopenharmony_ci#define SPIDER_NET_GDAWBCOMST		0x00000a30
12862306a36Sopenharmony_ci#define SPIDER_NET_GDAWBRSIZE		0x00000a34
12962306a36Sopenharmony_ci#define SPIDER_NET_GDAWBVSIZE		0x00000a38
13062306a36Sopenharmony_ci#define SPIDER_NET_GDAWBTRST		0x00000a3c
13162306a36Sopenharmony_ci#define SPIDER_NET_GDAWBTRERR		0x00000a40
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_ci/* TX DMA controller registers */
13462306a36Sopenharmony_ci#define SPIDER_NET_GDTDCHA		0x00000e00
13562306a36Sopenharmony_ci#define SPIDER_NET_GDTDMACCNTR		0x00000e04
13662306a36Sopenharmony_ci#define SPIDER_NET_GDTCDPA		0x00000e08
13762306a36Sopenharmony_ci#define SPIDER_NET_GDTDMASEL		0x00000e14
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci#define SPIDER_NET_ECMODE		0x00000f00
14062306a36Sopenharmony_ci/* clock and reset control register */
14162306a36Sopenharmony_ci#define SPIDER_NET_CKRCTRL		0x00000ff0
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci/** SCONFIG registers */
14462306a36Sopenharmony_ci#define SPIDER_NET_SCONFIG_IOACTE	0x00002810
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci/** interrupt mask registers */
14762306a36Sopenharmony_ci#define SPIDER_NET_INT0_MASK_VALUE	0x3f7fe2c7
14862306a36Sopenharmony_ci#define SPIDER_NET_INT1_MASK_VALUE	0x0000fff2
14962306a36Sopenharmony_ci#define SPIDER_NET_INT2_MASK_VALUE	0x000003f1
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci/* we rely on flagged descriptor interrupts */
15262306a36Sopenharmony_ci#define SPIDER_NET_FRAMENUM_VALUE	0x00000000
15362306a36Sopenharmony_ci/* set this first, then the FRAMENUM_VALUE */
15462306a36Sopenharmony_ci#define SPIDER_NET_GFXFRAMES_VALUE	0x00000000
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_ci#define SPIDER_NET_STOP_SEQ_VALUE	0x00000000
15762306a36Sopenharmony_ci#define SPIDER_NET_RUN_SEQ_VALUE	0x0000007e
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_ci#define SPIDER_NET_PHY_CTRL_VALUE	0x00040040
16062306a36Sopenharmony_ci/* #define SPIDER_NET_PHY_CTRL_VALUE	0x01070080*/
16162306a36Sopenharmony_ci#define SPIDER_NET_RXMODE_VALUE		0x00000011
16262306a36Sopenharmony_ci/* auto retransmission in case of MAC aborts */
16362306a36Sopenharmony_ci#define SPIDER_NET_TXMODE_VALUE		0x00010000
16462306a36Sopenharmony_ci#define SPIDER_NET_RESTART_VALUE	0x00000000
16562306a36Sopenharmony_ci#define SPIDER_NET_WOL_VALUE		0x00001111
16662306a36Sopenharmony_ci#if 0
16762306a36Sopenharmony_ci#define SPIDER_NET_WOL_VALUE		0x00000000
16862306a36Sopenharmony_ci#endif
16962306a36Sopenharmony_ci#define SPIDER_NET_IPSECINIT_VALUE	0x6f716f71
17062306a36Sopenharmony_ci
17162306a36Sopenharmony_ci/* pause frames: automatic, no upper retransmission count */
17262306a36Sopenharmony_ci/* outside loopback mode: ETOMOD signal dont matter, not connected */
17362306a36Sopenharmony_ci/* ETOMOD signal is brought to PHY reset. bit 2 must be 1 in Celleb */
17462306a36Sopenharmony_ci#define SPIDER_NET_OPMODE_VALUE		0x00000067
17562306a36Sopenharmony_ci/*#define SPIDER_NET_OPMODE_VALUE		0x001b0062*/
17662306a36Sopenharmony_ci#define SPIDER_NET_LENLMT_VALUE		0x00000908
17762306a36Sopenharmony_ci
17862306a36Sopenharmony_ci#define SPIDER_NET_MACAPAUSE_VALUE	0x00000800 /* about 1 ms */
17962306a36Sopenharmony_ci#define SPIDER_NET_TXPAUSE_VALUE	0x00000000
18062306a36Sopenharmony_ci
18162306a36Sopenharmony_ci#define SPIDER_NET_MACMODE_VALUE	0x00000001
18262306a36Sopenharmony_ci#define SPIDER_NET_BURSTLMT_VALUE	0x00000200 /* about 16 us */
18362306a36Sopenharmony_ci
18462306a36Sopenharmony_ci/* DMAC control register GDMACCNTR
18562306a36Sopenharmony_ci *
18662306a36Sopenharmony_ci * 1(0)				enable r/tx dma
18762306a36Sopenharmony_ci *  0000000				fixed to 0
18862306a36Sopenharmony_ci *
18962306a36Sopenharmony_ci *         000000			fixed to 0
19062306a36Sopenharmony_ci *               0(1)			en/disable descr writeback on force end
19162306a36Sopenharmony_ci *                0(1)			force end
19262306a36Sopenharmony_ci *
19362306a36Sopenharmony_ci *                 000000		fixed to 0
19462306a36Sopenharmony_ci *                       00		burst alignment: 128 bytes
19562306a36Sopenharmony_ci *                       11		burst alignment: 1024 bytes
19662306a36Sopenharmony_ci *
19762306a36Sopenharmony_ci *                         00000	fixed to 0
19862306a36Sopenharmony_ci *                              0	descr writeback size 32 bytes
19962306a36Sopenharmony_ci *                               0(1)	descr chain end interrupt enable
20062306a36Sopenharmony_ci *                                0(1)	descr status writeback enable */
20162306a36Sopenharmony_ci
20262306a36Sopenharmony_ci/* to set RX_DMA_EN */
20362306a36Sopenharmony_ci#define SPIDER_NET_DMA_RX_VALUE		0x80000000
20462306a36Sopenharmony_ci#define SPIDER_NET_DMA_RX_FEND_VALUE	0x00030003
20562306a36Sopenharmony_ci/* to set TX_DMA_EN */
20662306a36Sopenharmony_ci#define SPIDER_NET_TX_DMA_EN           0x80000000
20762306a36Sopenharmony_ci#define SPIDER_NET_GDTBSTA             0x00000300
20862306a36Sopenharmony_ci#define SPIDER_NET_GDTDCEIDIS          0x00000002
20962306a36Sopenharmony_ci#define SPIDER_NET_DMA_TX_VALUE        SPIDER_NET_TX_DMA_EN | \
21062306a36Sopenharmony_ci                                       SPIDER_NET_GDTDCEIDIS | \
21162306a36Sopenharmony_ci                                       SPIDER_NET_GDTBSTA
21262306a36Sopenharmony_ci
21362306a36Sopenharmony_ci#define SPIDER_NET_DMA_TX_FEND_VALUE	0x00030003
21462306a36Sopenharmony_ci
21562306a36Sopenharmony_ci/* SPIDER_NET_UA_DESCR_VALUE is OR'ed with the unicast address */
21662306a36Sopenharmony_ci#define SPIDER_NET_UA_DESCR_VALUE	0x00080000
21762306a36Sopenharmony_ci#define SPIDER_NET_PROMISC_VALUE	0x00080000
21862306a36Sopenharmony_ci#define SPIDER_NET_NONPROMISC_VALUE	0x00000000
21962306a36Sopenharmony_ci
22062306a36Sopenharmony_ci#define SPIDER_NET_DMASEL_VALUE		0x00000001
22162306a36Sopenharmony_ci
22262306a36Sopenharmony_ci#define SPIDER_NET_ECMODE_VALUE		0x00000000
22362306a36Sopenharmony_ci
22462306a36Sopenharmony_ci#define SPIDER_NET_CKRCTRL_RUN_VALUE	0x1fff010f
22562306a36Sopenharmony_ci#define SPIDER_NET_CKRCTRL_STOP_VALUE	0x0000010f
22662306a36Sopenharmony_ci
22762306a36Sopenharmony_ci#define SPIDER_NET_SBIMSTATE_VALUE	0x00000000
22862306a36Sopenharmony_ci#define SPIDER_NET_SBTMSTATE_VALUE	0x00000000
22962306a36Sopenharmony_ci
23062306a36Sopenharmony_ci/* SPIDER_NET_GHIINT0STS bits, in reverse order so that they can be used
23162306a36Sopenharmony_ci * with 1 << SPIDER_NET_... */
23262306a36Sopenharmony_cienum spider_net_int0_status {
23362306a36Sopenharmony_ci	SPIDER_NET_GPHYINT = 0,
23462306a36Sopenharmony_ci	SPIDER_NET_GMAC2INT,
23562306a36Sopenharmony_ci	SPIDER_NET_GMAC1INT,
23662306a36Sopenharmony_ci	SPIDER_NET_GIPSINT,
23762306a36Sopenharmony_ci	SPIDER_NET_GFIFOINT,
23862306a36Sopenharmony_ci	SPIDER_NET_GDMACINT,
23962306a36Sopenharmony_ci	SPIDER_NET_GSYSINT,
24062306a36Sopenharmony_ci	SPIDER_NET_GPWOPCMPINT,
24162306a36Sopenharmony_ci	SPIDER_NET_GPROPCMPINT,
24262306a36Sopenharmony_ci	SPIDER_NET_GPWFFINT,
24362306a36Sopenharmony_ci	SPIDER_NET_GRMDADRINT,
24462306a36Sopenharmony_ci	SPIDER_NET_GRMARPINT,
24562306a36Sopenharmony_ci	SPIDER_NET_GRMMPINT,
24662306a36Sopenharmony_ci	SPIDER_NET_GDTDEN0INT,
24762306a36Sopenharmony_ci	SPIDER_NET_GDDDEN0INT,
24862306a36Sopenharmony_ci	SPIDER_NET_GDCDEN0INT,
24962306a36Sopenharmony_ci	SPIDER_NET_GDBDEN0INT,
25062306a36Sopenharmony_ci	SPIDER_NET_GDADEN0INT,
25162306a36Sopenharmony_ci	SPIDER_NET_GDTFDCINT,
25262306a36Sopenharmony_ci	SPIDER_NET_GDDFDCINT,
25362306a36Sopenharmony_ci	SPIDER_NET_GDCFDCINT,
25462306a36Sopenharmony_ci	SPIDER_NET_GDBFDCINT,
25562306a36Sopenharmony_ci	SPIDER_NET_GDAFDCINT,
25662306a36Sopenharmony_ci	SPIDER_NET_GTTEDINT,
25762306a36Sopenharmony_ci	SPIDER_NET_GDTDCEINT,
25862306a36Sopenharmony_ci	SPIDER_NET_GRFDNMINT,
25962306a36Sopenharmony_ci	SPIDER_NET_GRFCNMINT,
26062306a36Sopenharmony_ci	SPIDER_NET_GRFBNMINT,
26162306a36Sopenharmony_ci	SPIDER_NET_GRFANMINT,
26262306a36Sopenharmony_ci	SPIDER_NET_GRFNMINT,
26362306a36Sopenharmony_ci	SPIDER_NET_G1TMCNTINT,
26462306a36Sopenharmony_ci	SPIDER_NET_GFREECNTINT
26562306a36Sopenharmony_ci};
26662306a36Sopenharmony_ci/* GHIINT1STS bits */
26762306a36Sopenharmony_cienum spider_net_int1_status {
26862306a36Sopenharmony_ci	SPIDER_NET_GTMFLLINT = 0,
26962306a36Sopenharmony_ci	SPIDER_NET_GRMFLLINT,
27062306a36Sopenharmony_ci	SPIDER_NET_GTMSHTINT,
27162306a36Sopenharmony_ci	SPIDER_NET_GDTINVDINT,
27262306a36Sopenharmony_ci	SPIDER_NET_GRFDFLLINT,
27362306a36Sopenharmony_ci	SPIDER_NET_GDDDCEINT,
27462306a36Sopenharmony_ci	SPIDER_NET_GDDINVDINT,
27562306a36Sopenharmony_ci	SPIDER_NET_GRFCFLLINT,
27662306a36Sopenharmony_ci	SPIDER_NET_GDCDCEINT,
27762306a36Sopenharmony_ci	SPIDER_NET_GDCINVDINT,
27862306a36Sopenharmony_ci	SPIDER_NET_GRFBFLLINT,
27962306a36Sopenharmony_ci	SPIDER_NET_GDBDCEINT,
28062306a36Sopenharmony_ci	SPIDER_NET_GDBINVDINT,
28162306a36Sopenharmony_ci	SPIDER_NET_GRFAFLLINT,
28262306a36Sopenharmony_ci	SPIDER_NET_GDADCEINT,
28362306a36Sopenharmony_ci	SPIDER_NET_GDAINVDINT,
28462306a36Sopenharmony_ci	SPIDER_NET_GDTRSERINT,
28562306a36Sopenharmony_ci	SPIDER_NET_GDDRSERINT,
28662306a36Sopenharmony_ci	SPIDER_NET_GDCRSERINT,
28762306a36Sopenharmony_ci	SPIDER_NET_GDBRSERINT,
28862306a36Sopenharmony_ci	SPIDER_NET_GDARSERINT,
28962306a36Sopenharmony_ci	SPIDER_NET_GDSERINT,
29062306a36Sopenharmony_ci	SPIDER_NET_GDTPTERINT,
29162306a36Sopenharmony_ci	SPIDER_NET_GDDPTERINT,
29262306a36Sopenharmony_ci	SPIDER_NET_GDCPTERINT,
29362306a36Sopenharmony_ci	SPIDER_NET_GDBPTERINT,
29462306a36Sopenharmony_ci	SPIDER_NET_GDAPTERINT
29562306a36Sopenharmony_ci};
29662306a36Sopenharmony_ci/* GHIINT2STS bits */
29762306a36Sopenharmony_cienum spider_net_int2_status {
29862306a36Sopenharmony_ci	SPIDER_NET_GPROPERINT = 0,
29962306a36Sopenharmony_ci	SPIDER_NET_GMCTCRSNGINT,
30062306a36Sopenharmony_ci	SPIDER_NET_GMCTLCOLINT,
30162306a36Sopenharmony_ci	SPIDER_NET_GMCTTMOTINT,
30262306a36Sopenharmony_ci	SPIDER_NET_GMCRCAERINT,
30362306a36Sopenharmony_ci	SPIDER_NET_GMCRCALERINT,
30462306a36Sopenharmony_ci	SPIDER_NET_GMCRALNERINT,
30562306a36Sopenharmony_ci	SPIDER_NET_GMCROVRINT,
30662306a36Sopenharmony_ci	SPIDER_NET_GMCRRNTINT,
30762306a36Sopenharmony_ci	SPIDER_NET_GMCRRXERINT,
30862306a36Sopenharmony_ci	SPIDER_NET_GTITCSERINT,
30962306a36Sopenharmony_ci	SPIDER_NET_GTIFMTERINT,
31062306a36Sopenharmony_ci	SPIDER_NET_GTIPKTRVKINT,
31162306a36Sopenharmony_ci	SPIDER_NET_GTISPINGINT,
31262306a36Sopenharmony_ci	SPIDER_NET_GTISADNGINT,
31362306a36Sopenharmony_ci	SPIDER_NET_GTISPDNGINT,
31462306a36Sopenharmony_ci	SPIDER_NET_GRIFMTERINT,
31562306a36Sopenharmony_ci	SPIDER_NET_GRIPKTRVKINT,
31662306a36Sopenharmony_ci	SPIDER_NET_GRISPINGINT,
31762306a36Sopenharmony_ci	SPIDER_NET_GRISADNGINT,
31862306a36Sopenharmony_ci	SPIDER_NET_GRISPDNGINT
31962306a36Sopenharmony_ci};
32062306a36Sopenharmony_ci
32162306a36Sopenharmony_ci#define SPIDER_NET_TXINT	(1 << SPIDER_NET_GDTFDCINT)
32262306a36Sopenharmony_ci
32362306a36Sopenharmony_ci/* We rely on flagged descriptor interrupts */
32462306a36Sopenharmony_ci#define SPIDER_NET_RXINT	( (1 << SPIDER_NET_GDAFDCINT) )
32562306a36Sopenharmony_ci
32662306a36Sopenharmony_ci#define SPIDER_NET_LINKINT	( 1 << SPIDER_NET_GMAC2INT )
32762306a36Sopenharmony_ci
32862306a36Sopenharmony_ci#define SPIDER_NET_ERRINT	( 0xffffffff & \
32962306a36Sopenharmony_ci				  (~SPIDER_NET_TXINT) & \
33062306a36Sopenharmony_ci				  (~SPIDER_NET_RXINT) & \
33162306a36Sopenharmony_ci				  (~SPIDER_NET_LINKINT) )
33262306a36Sopenharmony_ci
33362306a36Sopenharmony_ci#define SPIDER_NET_GPREXEC			0x80000000
33462306a36Sopenharmony_ci#define SPIDER_NET_GPRDAT_MASK			0x0000ffff
33562306a36Sopenharmony_ci
33662306a36Sopenharmony_ci#define SPIDER_NET_DMAC_NOINTR_COMPLETE		0x00800000
33762306a36Sopenharmony_ci#define SPIDER_NET_DMAC_TXFRMTL		0x00040000
33862306a36Sopenharmony_ci#define SPIDER_NET_DMAC_TCP			0x00020000
33962306a36Sopenharmony_ci#define SPIDER_NET_DMAC_UDP			0x00030000
34062306a36Sopenharmony_ci#define SPIDER_NET_TXDCEST			0x08000000
34162306a36Sopenharmony_ci
34262306a36Sopenharmony_ci#define SPIDER_NET_DESCR_RXFDIS        0x00000001
34362306a36Sopenharmony_ci#define SPIDER_NET_DESCR_RXDCEIS       0x00000002
34462306a36Sopenharmony_ci#define SPIDER_NET_DESCR_RXDEN0IS      0x00000004
34562306a36Sopenharmony_ci#define SPIDER_NET_DESCR_RXINVDIS      0x00000008
34662306a36Sopenharmony_ci#define SPIDER_NET_DESCR_RXRERRIS      0x00000010
34762306a36Sopenharmony_ci#define SPIDER_NET_DESCR_RXFDCIMS      0x00000100
34862306a36Sopenharmony_ci#define SPIDER_NET_DESCR_RXDCEIMS      0x00000200
34962306a36Sopenharmony_ci#define SPIDER_NET_DESCR_RXDEN0IMS     0x00000400
35062306a36Sopenharmony_ci#define SPIDER_NET_DESCR_RXINVDIMS     0x00000800
35162306a36Sopenharmony_ci#define SPIDER_NET_DESCR_RXRERRMIS     0x00001000
35262306a36Sopenharmony_ci#define SPIDER_NET_DESCR_UNUSED        0x077fe0e0
35362306a36Sopenharmony_ci
35462306a36Sopenharmony_ci#define SPIDER_NET_DESCR_IND_PROC_MASK		0xF0000000
35562306a36Sopenharmony_ci#define SPIDER_NET_DESCR_COMPLETE		0x00000000 /* used in rx and tx */
35662306a36Sopenharmony_ci#define SPIDER_NET_DESCR_RESPONSE_ERROR		0x10000000 /* used in rx and tx */
35762306a36Sopenharmony_ci#define SPIDER_NET_DESCR_PROTECTION_ERROR	0x20000000 /* used in rx and tx */
35862306a36Sopenharmony_ci#define SPIDER_NET_DESCR_FRAME_END		0x40000000 /* used in rx */
35962306a36Sopenharmony_ci#define SPIDER_NET_DESCR_FORCE_END		0x50000000 /* used in rx and tx */
36062306a36Sopenharmony_ci#define SPIDER_NET_DESCR_CARDOWNED		0xA0000000 /* used in rx and tx */
36162306a36Sopenharmony_ci#define SPIDER_NET_DESCR_NOT_IN_USE		0xF0000000
36262306a36Sopenharmony_ci#define SPIDER_NET_DESCR_TXDESFLG		0x00800000
36362306a36Sopenharmony_ci
36462306a36Sopenharmony_ci#define SPIDER_NET_DESCR_BAD_STATUS   (SPIDER_NET_DESCR_RXDEN0IS | \
36562306a36Sopenharmony_ci                                       SPIDER_NET_DESCR_RXRERRIS | \
36662306a36Sopenharmony_ci                                       SPIDER_NET_DESCR_RXDEN0IMS | \
36762306a36Sopenharmony_ci                                       SPIDER_NET_DESCR_RXINVDIMS | \
36862306a36Sopenharmony_ci                                       SPIDER_NET_DESCR_RXRERRMIS | \
36962306a36Sopenharmony_ci                                       SPIDER_NET_DESCR_UNUSED)
37062306a36Sopenharmony_ci
37162306a36Sopenharmony_ci/* Descriptor, as defined by the hardware */
37262306a36Sopenharmony_cistruct spider_net_hw_descr {
37362306a36Sopenharmony_ci	u32 buf_addr;
37462306a36Sopenharmony_ci	u32 buf_size;
37562306a36Sopenharmony_ci	u32 next_descr_addr;
37662306a36Sopenharmony_ci	u32 dmac_cmd_status;
37762306a36Sopenharmony_ci	u32 result_size;
37862306a36Sopenharmony_ci	u32 valid_size;	/* all zeroes for tx */
37962306a36Sopenharmony_ci	u32 data_status;
38062306a36Sopenharmony_ci	u32 data_error;	/* all zeroes for tx */
38162306a36Sopenharmony_ci} __attribute__((aligned(32)));
38262306a36Sopenharmony_ci
38362306a36Sopenharmony_cistruct spider_net_descr {
38462306a36Sopenharmony_ci	struct spider_net_hw_descr *hwdescr;
38562306a36Sopenharmony_ci	struct sk_buff *skb;
38662306a36Sopenharmony_ci	u32 bus_addr;
38762306a36Sopenharmony_ci	struct spider_net_descr *next;
38862306a36Sopenharmony_ci	struct spider_net_descr *prev;
38962306a36Sopenharmony_ci};
39062306a36Sopenharmony_ci
39162306a36Sopenharmony_cistruct spider_net_descr_chain {
39262306a36Sopenharmony_ci	spinlock_t lock;
39362306a36Sopenharmony_ci	struct spider_net_descr *head;
39462306a36Sopenharmony_ci	struct spider_net_descr *tail;
39562306a36Sopenharmony_ci	struct spider_net_descr *ring;
39662306a36Sopenharmony_ci	int num_desc;
39762306a36Sopenharmony_ci	struct spider_net_hw_descr *hwring;
39862306a36Sopenharmony_ci	dma_addr_t dma_addr;
39962306a36Sopenharmony_ci};
40062306a36Sopenharmony_ci
40162306a36Sopenharmony_ci/* descriptor data_status bits */
40262306a36Sopenharmony_ci#define SPIDER_NET_RX_IPCHK		29
40362306a36Sopenharmony_ci#define SPIDER_NET_RX_TCPCHK		28
40462306a36Sopenharmony_ci#define SPIDER_NET_VLAN_PACKET		21
40562306a36Sopenharmony_ci#define SPIDER_NET_DATA_STATUS_CKSUM_MASK ( (1 << SPIDER_NET_RX_IPCHK) | \
40662306a36Sopenharmony_ci					  (1 << SPIDER_NET_RX_TCPCHK) )
40762306a36Sopenharmony_ci
40862306a36Sopenharmony_ci/* descriptor data_error bits */
40962306a36Sopenharmony_ci#define SPIDER_NET_RX_IPCHKERR		27
41062306a36Sopenharmony_ci#define SPIDER_NET_RX_RXTCPCHKERR	28
41162306a36Sopenharmony_ci
41262306a36Sopenharmony_ci#define SPIDER_NET_DATA_ERR_CKSUM_MASK	(1 << SPIDER_NET_RX_IPCHKERR)
41362306a36Sopenharmony_ci
41462306a36Sopenharmony_ci/* the cases we don't pass the packet to the stack.
41562306a36Sopenharmony_ci * 701b8000 would be correct, but every packets gets that flag */
41662306a36Sopenharmony_ci#define SPIDER_NET_DESTROY_RX_FLAGS	0x700b8000
41762306a36Sopenharmony_ci
41862306a36Sopenharmony_ci#define SPIDER_NET_DEFAULT_MSG		( NETIF_MSG_DRV | \
41962306a36Sopenharmony_ci					  NETIF_MSG_PROBE | \
42062306a36Sopenharmony_ci					  NETIF_MSG_LINK | \
42162306a36Sopenharmony_ci					  NETIF_MSG_TIMER | \
42262306a36Sopenharmony_ci					  NETIF_MSG_IFDOWN | \
42362306a36Sopenharmony_ci					  NETIF_MSG_IFUP | \
42462306a36Sopenharmony_ci					  NETIF_MSG_RX_ERR | \
42562306a36Sopenharmony_ci					  NETIF_MSG_TX_ERR | \
42662306a36Sopenharmony_ci					  NETIF_MSG_TX_QUEUED | \
42762306a36Sopenharmony_ci					  NETIF_MSG_INTR | \
42862306a36Sopenharmony_ci					  NETIF_MSG_TX_DONE | \
42962306a36Sopenharmony_ci					  NETIF_MSG_RX_STATUS | \
43062306a36Sopenharmony_ci					  NETIF_MSG_PKTDATA | \
43162306a36Sopenharmony_ci					  NETIF_MSG_HW | \
43262306a36Sopenharmony_ci					  NETIF_MSG_WOL )
43362306a36Sopenharmony_ci
43462306a36Sopenharmony_cistruct spider_net_extra_stats {
43562306a36Sopenharmony_ci	unsigned long rx_desc_error;
43662306a36Sopenharmony_ci	unsigned long tx_timeouts;
43762306a36Sopenharmony_ci	unsigned long alloc_rx_skb_error;
43862306a36Sopenharmony_ci	unsigned long rx_iommu_map_error;
43962306a36Sopenharmony_ci	unsigned long tx_iommu_map_error;
44062306a36Sopenharmony_ci	unsigned long rx_desc_unk_state;
44162306a36Sopenharmony_ci};
44262306a36Sopenharmony_ci
44362306a36Sopenharmony_cistruct spider_net_card {
44462306a36Sopenharmony_ci	struct net_device *netdev;
44562306a36Sopenharmony_ci	struct pci_dev *pdev;
44662306a36Sopenharmony_ci	struct mii_phy phy;
44762306a36Sopenharmony_ci
44862306a36Sopenharmony_ci	struct napi_struct napi;
44962306a36Sopenharmony_ci
45062306a36Sopenharmony_ci	int medium;
45162306a36Sopenharmony_ci
45262306a36Sopenharmony_ci	void __iomem *regs;
45362306a36Sopenharmony_ci
45462306a36Sopenharmony_ci	struct spider_net_descr_chain tx_chain;
45562306a36Sopenharmony_ci	struct spider_net_descr_chain rx_chain;
45662306a36Sopenharmony_ci	struct spider_net_descr *low_watermark;
45762306a36Sopenharmony_ci
45862306a36Sopenharmony_ci	int aneg_count;
45962306a36Sopenharmony_ci	struct timer_list aneg_timer;
46062306a36Sopenharmony_ci	struct timer_list tx_timer;
46162306a36Sopenharmony_ci	struct work_struct tx_timeout_task;
46262306a36Sopenharmony_ci	atomic_t tx_timeout_task_counter;
46362306a36Sopenharmony_ci	wait_queue_head_t waitq;
46462306a36Sopenharmony_ci	int num_rx_ints;
46562306a36Sopenharmony_ci	int ignore_rx_ramfull;
46662306a36Sopenharmony_ci
46762306a36Sopenharmony_ci	/* for ethtool */
46862306a36Sopenharmony_ci	int msg_enable;
46962306a36Sopenharmony_ci	struct spider_net_extra_stats spider_stats;
47062306a36Sopenharmony_ci
47162306a36Sopenharmony_ci	/* Must be last item in struct */
47262306a36Sopenharmony_ci	struct spider_net_descr darray[];
47362306a36Sopenharmony_ci};
47462306a36Sopenharmony_ci
47562306a36Sopenharmony_ci#endif
476