1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
260c140dfSLino Sanfilippo
360c140dfSLino Sanfilippo #ifndef _SLIC_H
460c140dfSLino Sanfilippo #define _SLIC_H
560c140dfSLino Sanfilippo
660c140dfSLino Sanfilippo #include <linux/types.h>
760c140dfSLino Sanfilippo #include <linux/netdevice.h>
860c140dfSLino Sanfilippo #include <linux/spinlock_types.h>
960c140dfSLino Sanfilippo #include <linux/dma-mapping.h>
1060c140dfSLino Sanfilippo #include <linux/pci.h>
1160c140dfSLino Sanfilippo #include <linux/list.h>
1260c140dfSLino Sanfilippo #include <linux/u64_stats_sync.h>
1360c140dfSLino Sanfilippo
1460c140dfSLino Sanfilippo #define SLIC_VGBSTAT_XPERR 0x40000000
1560c140dfSLino Sanfilippo #define SLIC_VGBSTAT_XERRSHFT 25
1660c140dfSLino Sanfilippo #define SLIC_VGBSTAT_XCSERR 0x23
1760c140dfSLino Sanfilippo #define SLIC_VGBSTAT_XUFLOW 0x22
1860c140dfSLino Sanfilippo #define SLIC_VGBSTAT_XHLEN 0x20
1960c140dfSLino Sanfilippo #define SLIC_VGBSTAT_NETERR 0x01000000
2060c140dfSLino Sanfilippo #define SLIC_VGBSTAT_NERRSHFT 16
2160c140dfSLino Sanfilippo #define SLIC_VGBSTAT_NERRMSK 0x1ff
2260c140dfSLino Sanfilippo #define SLIC_VGBSTAT_NCSERR 0x103
2360c140dfSLino Sanfilippo #define SLIC_VGBSTAT_NUFLOW 0x102
2460c140dfSLino Sanfilippo #define SLIC_VGBSTAT_NHLEN 0x100
2560c140dfSLino Sanfilippo #define SLIC_VGBSTAT_LNKERR 0x00000080
2660c140dfSLino Sanfilippo #define SLIC_VGBSTAT_LERRMSK 0xff
2760c140dfSLino Sanfilippo #define SLIC_VGBSTAT_LDEARLY 0x86
2860c140dfSLino Sanfilippo #define SLIC_VGBSTAT_LBOFLO 0x85
2960c140dfSLino Sanfilippo #define SLIC_VGBSTAT_LCODERR 0x84
3060c140dfSLino Sanfilippo #define SLIC_VGBSTAT_LDBLNBL 0x83
3160c140dfSLino Sanfilippo #define SLIC_VGBSTAT_LCRCERR 0x82
3260c140dfSLino Sanfilippo #define SLIC_VGBSTAT_LOFLO 0x81
3360c140dfSLino Sanfilippo #define SLIC_VGBSTAT_LUFLO 0x80
3460c140dfSLino Sanfilippo
3560c140dfSLino Sanfilippo #define SLIC_IRHDDR_FLEN_MSK 0x0000ffff
3660c140dfSLino Sanfilippo #define SLIC_IRHDDR_SVALID 0x80000000
3760c140dfSLino Sanfilippo #define SLIC_IRHDDR_ERR 0x10000000
3860c140dfSLino Sanfilippo
3960c140dfSLino Sanfilippo #define SLIC_VRHSTAT_802OE 0x80000000
4060c140dfSLino Sanfilippo #define SLIC_VRHSTAT_TPOFLO 0x10000000
4160c140dfSLino Sanfilippo #define SLIC_VRHSTATB_802UE 0x80000000
4260c140dfSLino Sanfilippo #define SLIC_VRHSTATB_RCVE 0x40000000
4360c140dfSLino Sanfilippo #define SLIC_VRHSTATB_BUFF 0x20000000
4460c140dfSLino Sanfilippo #define SLIC_VRHSTATB_CARRE 0x08000000
4560c140dfSLino Sanfilippo #define SLIC_VRHSTATB_LONGE 0x02000000
4660c140dfSLino Sanfilippo #define SLIC_VRHSTATB_PREA 0x01000000
4760c140dfSLino Sanfilippo #define SLIC_VRHSTATB_CRC 0x00800000
4860c140dfSLino Sanfilippo #define SLIC_VRHSTATB_DRBL 0x00400000
4960c140dfSLino Sanfilippo #define SLIC_VRHSTATB_CODE 0x00200000
5060c140dfSLino Sanfilippo #define SLIC_VRHSTATB_TPCSUM 0x00100000
5160c140dfSLino Sanfilippo #define SLIC_VRHSTATB_TPHLEN 0x00080000
5260c140dfSLino Sanfilippo #define SLIC_VRHSTATB_IPCSUM 0x00040000
5360c140dfSLino Sanfilippo #define SLIC_VRHSTATB_IPLERR 0x00020000
5460c140dfSLino Sanfilippo #define SLIC_VRHSTATB_IPHERR 0x00010000
5560c140dfSLino Sanfilippo
5660c140dfSLino Sanfilippo #define SLIC_CMD_XMT_REQ 0x01
5760c140dfSLino Sanfilippo #define SLIC_CMD_TYPE_DUMB 3
5860c140dfSLino Sanfilippo
5960c140dfSLino Sanfilippo #define SLIC_RESET_MAGIC 0xDEAD
6060c140dfSLino Sanfilippo #define SLIC_ICR_INT_OFF 0
6160c140dfSLino Sanfilippo #define SLIC_ICR_INT_ON 1
6260c140dfSLino Sanfilippo #define SLIC_ICR_INT_MASK 2
6360c140dfSLino Sanfilippo
6460c140dfSLino Sanfilippo #define SLIC_ISR_ERR 0x80000000
6560c140dfSLino Sanfilippo #define SLIC_ISR_RCV 0x40000000
6660c140dfSLino Sanfilippo #define SLIC_ISR_CMD 0x20000000
6760c140dfSLino Sanfilippo #define SLIC_ISR_IO 0x60000000
6860c140dfSLino Sanfilippo #define SLIC_ISR_UPC 0x10000000
6960c140dfSLino Sanfilippo #define SLIC_ISR_LEVENT 0x08000000
7060c140dfSLino Sanfilippo #define SLIC_ISR_RMISS 0x02000000
7160c140dfSLino Sanfilippo #define SLIC_ISR_UPCERR 0x01000000
7260c140dfSLino Sanfilippo #define SLIC_ISR_XDROP 0x00800000
7360c140dfSLino Sanfilippo #define SLIC_ISR_UPCBSY 0x00020000
7460c140dfSLino Sanfilippo
7560c140dfSLino Sanfilippo #define SLIC_ISR_PING_MASK 0x00700000
7660c140dfSLino Sanfilippo #define SLIC_ISR_UPCERR_MASK (SLIC_ISR_UPCERR | SLIC_ISR_UPCBSY)
7760c140dfSLino Sanfilippo #define SLIC_ISR_UPC_MASK (SLIC_ISR_UPC | SLIC_ISR_UPCERR_MASK)
7860c140dfSLino Sanfilippo #define SLIC_WCS_START 0x80000000
7960c140dfSLino Sanfilippo #define SLIC_WCS_COMPARE 0x40000000
8060c140dfSLino Sanfilippo #define SLIC_RCVWCS_BEGIN 0x40000000
8160c140dfSLino Sanfilippo #define SLIC_RCVWCS_FINISH 0x80000000
8260c140dfSLino Sanfilippo
8360c140dfSLino Sanfilippo #define SLIC_MIICR_REG_16 0x00100000
8460c140dfSLino Sanfilippo #define SLIC_MRV_REG16_XOVERON 0x0068
8560c140dfSLino Sanfilippo
8660c140dfSLino Sanfilippo #define SLIC_GIG_LINKUP 0x0001
8760c140dfSLino Sanfilippo #define SLIC_GIG_FULLDUPLEX 0x0002
8860c140dfSLino Sanfilippo #define SLIC_GIG_SPEED_MASK 0x000C
8960c140dfSLino Sanfilippo #define SLIC_GIG_SPEED_1000 0x0008
9060c140dfSLino Sanfilippo #define SLIC_GIG_SPEED_100 0x0004
9160c140dfSLino Sanfilippo #define SLIC_GIG_SPEED_10 0x0000
9260c140dfSLino Sanfilippo
9360c140dfSLino Sanfilippo #define SLIC_GMCR_RESET 0x80000000
9460c140dfSLino Sanfilippo #define SLIC_GMCR_GBIT 0x20000000
9560c140dfSLino Sanfilippo #define SLIC_GMCR_FULLD 0x10000000
9660c140dfSLino Sanfilippo #define SLIC_GMCR_GAPBB_SHIFT 14
9760c140dfSLino Sanfilippo #define SLIC_GMCR_GAPR1_SHIFT 7
9860c140dfSLino Sanfilippo #define SLIC_GMCR_GAPR2_SHIFT 0
9960c140dfSLino Sanfilippo #define SLIC_GMCR_GAPBB_1000 0x60
10060c140dfSLino Sanfilippo #define SLIC_GMCR_GAPR1_1000 0x2C
10160c140dfSLino Sanfilippo #define SLIC_GMCR_GAPR2_1000 0x40
10260c140dfSLino Sanfilippo #define SLIC_GMCR_GAPBB_100 0x70
10360c140dfSLino Sanfilippo #define SLIC_GMCR_GAPR1_100 0x2C
10460c140dfSLino Sanfilippo #define SLIC_GMCR_GAPR2_100 0x40
10560c140dfSLino Sanfilippo
10660c140dfSLino Sanfilippo #define SLIC_XCR_RESET 0x80000000
10760c140dfSLino Sanfilippo #define SLIC_XCR_XMTEN 0x40000000
10860c140dfSLino Sanfilippo #define SLIC_XCR_PAUSEEN 0x20000000
10960c140dfSLino Sanfilippo #define SLIC_XCR_LOADRNG 0x10000000
11060c140dfSLino Sanfilippo
11160c140dfSLino Sanfilippo #define SLIC_GXCR_RESET 0x80000000
11260c140dfSLino Sanfilippo #define SLIC_GXCR_XMTEN 0x40000000
11360c140dfSLino Sanfilippo #define SLIC_GXCR_PAUSEEN 0x20000000
11460c140dfSLino Sanfilippo
11560c140dfSLino Sanfilippo #define SLIC_GRCR_RESET 0x80000000
11660c140dfSLino Sanfilippo #define SLIC_GRCR_RCVEN 0x40000000
11760c140dfSLino Sanfilippo #define SLIC_GRCR_RCVALL 0x20000000
11860c140dfSLino Sanfilippo #define SLIC_GRCR_RCVBAD 0x10000000
11960c140dfSLino Sanfilippo #define SLIC_GRCR_CTLEN 0x08000000
12060c140dfSLino Sanfilippo #define SLIC_GRCR_ADDRAEN 0x02000000
12160c140dfSLino Sanfilippo #define SLIC_GRCR_HASHSIZE_SHIFT 17
12260c140dfSLino Sanfilippo #define SLIC_GRCR_HASHSIZE 14
12360c140dfSLino Sanfilippo
12460c140dfSLino Sanfilippo /* Reset Register */
12560c140dfSLino Sanfilippo #define SLIC_REG_RESET 0x0000
12660c140dfSLino Sanfilippo /* Interrupt Control Register */
12760c140dfSLino Sanfilippo #define SLIC_REG_ICR 0x0008
12860c140dfSLino Sanfilippo /* Interrupt status pointer */
12960c140dfSLino Sanfilippo #define SLIC_REG_ISP 0x0010
13060c140dfSLino Sanfilippo /* Interrupt status */
13160c140dfSLino Sanfilippo #define SLIC_REG_ISR 0x0018
13260c140dfSLino Sanfilippo /* Header buffer address reg
13360c140dfSLino Sanfilippo * 31-8 - phy addr of set of contiguous hdr buffers
13460c140dfSLino Sanfilippo * 7-0 - number of buffers passed
13560c140dfSLino Sanfilippo * Buffers are 256 bytes long on 256-byte boundaries.
13660c140dfSLino Sanfilippo */
13760c140dfSLino Sanfilippo #define SLIC_REG_HBAR 0x0020
13860c140dfSLino Sanfilippo /* Data buffer handle & address reg
13960c140dfSLino Sanfilippo * 4 sets of registers; Buffers are 2K bytes long 2 per 4K page.
14060c140dfSLino Sanfilippo */
14160c140dfSLino Sanfilippo #define SLIC_REG_DBAR 0x0028
14260c140dfSLino Sanfilippo /* Xmt Cmd buf addr regs.
14360c140dfSLino Sanfilippo * 1 per XMT interface
14460c140dfSLino Sanfilippo * 31-5 - phy addr of host command buffer
14560c140dfSLino Sanfilippo * 4-0 - length of cmd in multiples of 32 bytes
14660c140dfSLino Sanfilippo * Buffers are 32 bytes up to 512 bytes long
14760c140dfSLino Sanfilippo */
14860c140dfSLino Sanfilippo #define SLIC_REG_CBAR 0x0030
14960c140dfSLino Sanfilippo /* Write control store */
15060c140dfSLino Sanfilippo #define SLIC_REG_WCS 0x0034
15160c140dfSLino Sanfilippo /*Response buffer address reg.
15260c140dfSLino Sanfilippo * 31-8 - phy addr of set of contiguous response buffers
15360c140dfSLino Sanfilippo * 7-0 - number of buffers passed
15460c140dfSLino Sanfilippo * Buffers are 32 bytes long on 32-byte boundaries.
15560c140dfSLino Sanfilippo */
15660c140dfSLino Sanfilippo #define SLIC_REG_RBAR 0x0038
15760c140dfSLino Sanfilippo /* Read statistics (UPR) */
15860c140dfSLino Sanfilippo #define SLIC_REG_RSTAT 0x0040
15960c140dfSLino Sanfilippo /* Read link status */
16060c140dfSLino Sanfilippo #define SLIC_REG_LSTAT 0x0048
16160c140dfSLino Sanfilippo /* Write Mac Config */
16260c140dfSLino Sanfilippo #define SLIC_REG_WMCFG 0x0050
16360c140dfSLino Sanfilippo /* Write phy register */
16460c140dfSLino Sanfilippo #define SLIC_REG_WPHY 0x0058
16560c140dfSLino Sanfilippo /* Rcv Cmd buf addr reg */
16660c140dfSLino Sanfilippo #define SLIC_REG_RCBAR 0x0060
16760c140dfSLino Sanfilippo /* Read SLIC Config*/
16860c140dfSLino Sanfilippo #define SLIC_REG_RCONFIG 0x0068
16960c140dfSLino Sanfilippo /* Interrupt aggregation time */
17060c140dfSLino Sanfilippo #define SLIC_REG_INTAGG 0x0070
17160c140dfSLino Sanfilippo /* Write XMIT config reg */
17260c140dfSLino Sanfilippo #define SLIC_REG_WXCFG 0x0078
17360c140dfSLino Sanfilippo /* Write RCV config reg */
17460c140dfSLino Sanfilippo #define SLIC_REG_WRCFG 0x0080
17560c140dfSLino Sanfilippo /* Write rcv addr a low */
17660c140dfSLino Sanfilippo #define SLIC_REG_WRADDRAL 0x0088
17760c140dfSLino Sanfilippo /* Write rcv addr a high */
17860c140dfSLino Sanfilippo #define SLIC_REG_WRADDRAH 0x0090
17960c140dfSLino Sanfilippo /* Write rcv addr b low */
18060c140dfSLino Sanfilippo #define SLIC_REG_WRADDRBL 0x0098
18160c140dfSLino Sanfilippo /* Write rcv addr b high */
18260c140dfSLino Sanfilippo #define SLIC_REG_WRADDRBH 0x00a0
18360c140dfSLino Sanfilippo /* Low bits of mcast mask */
18460c140dfSLino Sanfilippo #define SLIC_REG_MCASTLOW 0x00a8
18560c140dfSLino Sanfilippo /* High bits of mcast mask */
18660c140dfSLino Sanfilippo #define SLIC_REG_MCASTHIGH 0x00b0
18760c140dfSLino Sanfilippo /* Ping the card */
18860c140dfSLino Sanfilippo #define SLIC_REG_PING 0x00b8
18960c140dfSLino Sanfilippo /* Dump command */
19060c140dfSLino Sanfilippo #define SLIC_REG_DUMP_CMD 0x00c0
19160c140dfSLino Sanfilippo /* Dump data pointer */
19260c140dfSLino Sanfilippo #define SLIC_REG_DUMP_DATA 0x00c8
19360c140dfSLino Sanfilippo /* Read card's pci_status register */
19460c140dfSLino Sanfilippo #define SLIC_REG_PCISTATUS 0x00d0
19560c140dfSLino Sanfilippo /* Write hostid field */
19660c140dfSLino Sanfilippo #define SLIC_REG_WRHOSTID 0x00d8
19760c140dfSLino Sanfilippo /* Put card in a low power state */
19860c140dfSLino Sanfilippo #define SLIC_REG_LOW_POWER 0x00e0
19960c140dfSLino Sanfilippo /* Force slic into quiescent state before soft reset */
20060c140dfSLino Sanfilippo #define SLIC_REG_QUIESCE 0x00e8
20160c140dfSLino Sanfilippo /* Reset interface queues */
20260c140dfSLino Sanfilippo #define SLIC_REG_RESET_IFACE 0x00f0
20360c140dfSLino Sanfilippo /* Register is only written when it has changed.
20460c140dfSLino Sanfilippo * Bits 63-32 for host i/f addrs.
20560c140dfSLino Sanfilippo */
20660c140dfSLino Sanfilippo #define SLIC_REG_ADDR_UPPER 0x00f8
20760c140dfSLino Sanfilippo /* 64 bit Header buffer address reg */
20860c140dfSLino Sanfilippo #define SLIC_REG_HBAR64 0x0100
20960c140dfSLino Sanfilippo /* 64 bit Data buffer handle & address reg */
21060c140dfSLino Sanfilippo #define SLIC_REG_DBAR64 0x0108
21160c140dfSLino Sanfilippo /* 64 bit Xmt Cmd buf addr regs. */
21260c140dfSLino Sanfilippo #define SLIC_REG_CBAR64 0x0110
21360c140dfSLino Sanfilippo /* 64 bit Response buffer address reg.*/
21460c140dfSLino Sanfilippo #define SLIC_REG_RBAR64 0x0118
21560c140dfSLino Sanfilippo /* 64 bit Rcv Cmd buf addr reg*/
21660c140dfSLino Sanfilippo #define SLIC_REG_RCBAR64 0x0120
21760c140dfSLino Sanfilippo /* Read statistics (64 bit UPR) */
21860c140dfSLino Sanfilippo #define SLIC_REG_RSTAT64 0x0128
21960c140dfSLino Sanfilippo /* Download Gigabit RCV sequencer ucode */
22060c140dfSLino Sanfilippo #define SLIC_REG_RCV_WCS 0x0130
22160c140dfSLino Sanfilippo /* Write VlanId field */
22260c140dfSLino Sanfilippo #define SLIC_REG_WRVLANID 0x0138
22360c140dfSLino Sanfilippo /* Read Transformer info */
22460c140dfSLino Sanfilippo #define SLIC_REG_READ_XF_INFO 0x0140
22560c140dfSLino Sanfilippo /* Write Transformer info */
22660c140dfSLino Sanfilippo #define SLIC_REG_WRITE_XF_INFO 0x0148
22760c140dfSLino Sanfilippo /* Write card ticks per second */
22860c140dfSLino Sanfilippo #define SLIC_REG_TICKS_PER_SEC 0x0170
22960c140dfSLino Sanfilippo #define SLIC_REG_HOSTID 0x1554
23060c140dfSLino Sanfilippo
23160c140dfSLino Sanfilippo #define PCI_VENDOR_ID_ALACRITECH 0x139A
23260c140dfSLino Sanfilippo #define PCI_DEVICE_ID_ALACRITECH_MOJAVE 0x0005
23360c140dfSLino Sanfilippo #define PCI_SUBDEVICE_ID_ALACRITECH_1000X1 0x0005
23460c140dfSLino Sanfilippo #define PCI_SUBDEVICE_ID_ALACRITECH_1000X1_2 0x0006
23560c140dfSLino Sanfilippo #define PCI_SUBDEVICE_ID_ALACRITECH_1000X1F 0x0007
23660c140dfSLino Sanfilippo #define PCI_SUBDEVICE_ID_ALACRITECH_CICADA 0x0008
23760c140dfSLino Sanfilippo #define PCI_SUBDEVICE_ID_ALACRITECH_SES1001T 0x2006
23860c140dfSLino Sanfilippo #define PCI_SUBDEVICE_ID_ALACRITECH_SES1001F 0x2007
23960c140dfSLino Sanfilippo #define PCI_DEVICE_ID_ALACRITECH_OASIS 0x0007
24060c140dfSLino Sanfilippo #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2002XT 0x000B
24160c140dfSLino Sanfilippo #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2002XF 0x000C
24260c140dfSLino Sanfilippo #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2001XT 0x000D
24360c140dfSLino Sanfilippo #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2001XF 0x000E
24460c140dfSLino Sanfilippo #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2104EF 0x000F
24560c140dfSLino Sanfilippo #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2104ET 0x0010
24660c140dfSLino Sanfilippo #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2102EF 0x0011
24760c140dfSLino Sanfilippo #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2102ET 0x0012
24860c140dfSLino Sanfilippo
24960c140dfSLino Sanfilippo /* Note: power of two required for number descriptors */
25060c140dfSLino Sanfilippo #define SLIC_NUM_RX_LES 256
25160c140dfSLino Sanfilippo #define SLIC_RX_BUFF_SIZE 2048
25260c140dfSLino Sanfilippo #define SLIC_RX_BUFF_ALIGN 256
25360c140dfSLino Sanfilippo #define SLIC_RX_BUFF_HDR_SIZE 34
25460c140dfSLino Sanfilippo #define SLIC_MAX_REQ_RX_DESCS 1
25560c140dfSLino Sanfilippo
25660c140dfSLino Sanfilippo #define SLIC_NUM_TX_DESCS 256
25760c140dfSLino Sanfilippo #define SLIC_TX_DESC_ALIGN 32
25860c140dfSLino Sanfilippo #define SLIC_MIN_TX_WAKEUP_DESCS 10
25960c140dfSLino Sanfilippo #define SLIC_MAX_REQ_TX_DESCS 1
26060c140dfSLino Sanfilippo #define SLIC_MAX_TX_COMPLETIONS 100
26160c140dfSLino Sanfilippo
26260c140dfSLino Sanfilippo #define SLIC_NUM_STAT_DESCS 128
26360c140dfSLino Sanfilippo #define SLIC_STATS_DESC_ALIGN 256
26460c140dfSLino Sanfilippo
26560c140dfSLino Sanfilippo #define SLIC_NUM_STAT_DESC_ARRAYS 4
26660c140dfSLino Sanfilippo #define SLIC_INVALID_STAT_DESC_IDX 0xffffffff
26760c140dfSLino Sanfilippo
26860c140dfSLino Sanfilippo #define SLIC_UPR_LSTAT 0
26960c140dfSLino Sanfilippo #define SLIC_UPR_CONFIG 1
27060c140dfSLino Sanfilippo
27160c140dfSLino Sanfilippo #define SLIC_EEPROM_SIZE 128
27260c140dfSLino Sanfilippo #define SLIC_EEPROM_MAGIC 0xa5a5
27360c140dfSLino Sanfilippo
27460c140dfSLino Sanfilippo #define SLIC_FIRMWARE_MOJAVE "slicoss/gbdownload.sys"
27560c140dfSLino Sanfilippo #define SLIC_FIRMWARE_OASIS "slicoss/oasisdownload.sys"
27660c140dfSLino Sanfilippo #define SLIC_RCV_FIRMWARE_MOJAVE "slicoss/gbrcvucode.sys"
27760c140dfSLino Sanfilippo #define SLIC_RCV_FIRMWARE_OASIS "slicoss/oasisrcvucode.sys"
27860c140dfSLino Sanfilippo #define SLIC_FIRMWARE_MIN_SIZE 64
27960c140dfSLino Sanfilippo #define SLIC_FIRMWARE_MAX_SECTIONS 3
28060c140dfSLino Sanfilippo
28160c140dfSLino Sanfilippo #define SLIC_MODEL_MOJAVE 0
28260c140dfSLino Sanfilippo #define SLIC_MODEL_OASIS 1
28360c140dfSLino Sanfilippo
28460c140dfSLino Sanfilippo #define SLIC_INC_STATS_COUNTER(st, counter) \
28560c140dfSLino Sanfilippo do { \
28660c140dfSLino Sanfilippo u64_stats_update_begin(&(st)->syncp); \
28760c140dfSLino Sanfilippo (st)->counter++; \
28860c140dfSLino Sanfilippo u64_stats_update_end(&(st)->syncp); \
28960c140dfSLino Sanfilippo } while (0)
29060c140dfSLino Sanfilippo
29160c140dfSLino Sanfilippo #define SLIC_GET_STATS_COUNTER(newst, st, counter) \
29260c140dfSLino Sanfilippo { \
29360c140dfSLino Sanfilippo unsigned int start; \
29460c140dfSLino Sanfilippo do { \
295*068c38adSThomas Gleixner start = u64_stats_fetch_begin(&(st)->syncp); \
29660c140dfSLino Sanfilippo newst = (st)->counter; \
297*068c38adSThomas Gleixner } while (u64_stats_fetch_retry(&(st)->syncp, start)); \
29860c140dfSLino Sanfilippo }
29960c140dfSLino Sanfilippo
30060c140dfSLino Sanfilippo struct slic_upr {
30160c140dfSLino Sanfilippo dma_addr_t paddr;
30260c140dfSLino Sanfilippo unsigned int type;
30360c140dfSLino Sanfilippo struct list_head list;
30460c140dfSLino Sanfilippo };
30560c140dfSLino Sanfilippo
30660c140dfSLino Sanfilippo struct slic_upr_list {
30760c140dfSLino Sanfilippo bool pending;
30860c140dfSLino Sanfilippo struct list_head list;
30960c140dfSLino Sanfilippo /* upr list lock */
31060c140dfSLino Sanfilippo spinlock_t lock;
31160c140dfSLino Sanfilippo };
31260c140dfSLino Sanfilippo
31360c140dfSLino Sanfilippo /* SLIC EEPROM structure for Mojave */
31460c140dfSLino Sanfilippo struct slic_mojave_eeprom {
31560c140dfSLino Sanfilippo __le16 id; /* 00 EEPROM/FLASH Magic code 'A5A5'*/
31660c140dfSLino Sanfilippo __le16 eeprom_code_size;/* 01 Size of EEPROM Codes (bytes * 4)*/
31760c140dfSLino Sanfilippo __le16 flash_size; /* 02 Flash size */
31860c140dfSLino Sanfilippo __le16 eeprom_size; /* 03 EEPROM Size */
31960c140dfSLino Sanfilippo __le16 vendor_id; /* 04 Vendor ID */
32060c140dfSLino Sanfilippo __le16 dev_id; /* 05 Device ID */
32160c140dfSLino Sanfilippo u8 rev_id; /* 06 Revision ID */
32260c140dfSLino Sanfilippo u8 class_code[3]; /* 07 Class Code */
32360c140dfSLino Sanfilippo u8 irqpin_dbg; /* 08 Debug Interrupt pin */
32460c140dfSLino Sanfilippo u8 irqpin; /* Network Interrupt Pin */
32560c140dfSLino Sanfilippo u8 min_grant; /* 09 Minimum grant */
32660c140dfSLino Sanfilippo u8 max_lat; /* Maximum Latency */
32760c140dfSLino Sanfilippo __le16 pci_stat; /* 10 PCI Status */
32860c140dfSLino Sanfilippo __le16 sub_vendor_id; /* 11 Subsystem Vendor Id */
32960c140dfSLino Sanfilippo __le16 sub_id; /* 12 Subsystem ID */
33060c140dfSLino Sanfilippo __le16 dev_id_dbg; /* 13 Debug Device Id */
33160c140dfSLino Sanfilippo __le16 ramrom; /* 14 Dram/Rom function */
33260c140dfSLino Sanfilippo __le16 dram_size2pci; /* 15 DRAM size to PCI (bytes * 64K) */
33360c140dfSLino Sanfilippo __le16 rom_size2pci; /* 16 ROM extension size to PCI (bytes * 4k) */
33460c140dfSLino Sanfilippo u8 pad[2]; /* 17 Padding */
33560c140dfSLino Sanfilippo u8 freetime; /* 18 FreeTime setting */
33660c140dfSLino Sanfilippo u8 ifctrl; /* 10-bit interface control (Mojave only) */
33760c140dfSLino Sanfilippo __le16 dram_size; /* 19 DRAM size (bytes * 64k) */
33860c140dfSLino Sanfilippo u8 mac[ETH_ALEN]; /* 20 MAC addresses */
33960c140dfSLino Sanfilippo u8 mac2[ETH_ALEN];
34060c140dfSLino Sanfilippo u8 pad2[6];
34160c140dfSLino Sanfilippo u16 dev_id2; /* Device ID for 2nd PCI function */
34260c140dfSLino Sanfilippo u8 irqpin2; /* Interrupt pin for 2nd PCI function */
34360c140dfSLino Sanfilippo u8 class_code2[3]; /* Class Code for 2nd PCI function */
34460c140dfSLino Sanfilippo u16 cfg_byte6; /* Config Byte 6 */
34560c140dfSLino Sanfilippo u16 pme_cap; /* Power Mgment capabilities */
34660c140dfSLino Sanfilippo u16 nwclk_ctrl; /* NetworkClockControls */
34760c140dfSLino Sanfilippo u8 fru_format; /* Alacritech FRU format type */
34860c140dfSLino Sanfilippo u8 fru_assembly[6]; /* Alacritech FRU information */
34960c140dfSLino Sanfilippo u8 fru_rev[2];
35060c140dfSLino Sanfilippo u8 fru_serial[14];
35160c140dfSLino Sanfilippo u8 fru_pad[3];
35260c140dfSLino Sanfilippo u8 oem_fru[28]; /* optional OEM FRU format type */
35360c140dfSLino Sanfilippo u8 pad3[4]; /* Pad to 128 bytes - includes 2 cksum bytes
35460c140dfSLino Sanfilippo * (if OEM FRU info exists) and two unusable
35560c140dfSLino Sanfilippo * bytes at the end
35660c140dfSLino Sanfilippo */
35760c140dfSLino Sanfilippo };
35860c140dfSLino Sanfilippo
35960c140dfSLino Sanfilippo /* SLIC EEPROM structure for Oasis */
36060c140dfSLino Sanfilippo struct slic_oasis_eeprom {
36160c140dfSLino Sanfilippo __le16 id; /* 00 EEPROM/FLASH Magic code 'A5A5' */
36260c140dfSLino Sanfilippo __le16 eeprom_code_size;/* 01 Size of EEPROM Codes (bytes * 4)*/
36360c140dfSLino Sanfilippo __le16 spidev0_cfg; /* 02 Flash Config for SPI device 0 */
36460c140dfSLino Sanfilippo __le16 spidev1_cfg; /* 03 Flash Config for SPI device 1 */
36560c140dfSLino Sanfilippo __le16 vendor_id; /* 04 Vendor ID */
36660c140dfSLino Sanfilippo __le16 dev_id; /* 05 Device ID (function 0) */
36760c140dfSLino Sanfilippo u8 rev_id; /* 06 Revision ID */
36860c140dfSLino Sanfilippo u8 class_code0[3]; /* 07 Class Code for PCI function 0 */
36960c140dfSLino Sanfilippo u8 irqpin1; /* 08 Interrupt pin for PCI function 1*/
37060c140dfSLino Sanfilippo u8 class_code1[3]; /* 09 Class Code for PCI function 1 */
37160c140dfSLino Sanfilippo u8 irqpin2; /* 10 Interrupt pin for PCI function 2*/
37260c140dfSLino Sanfilippo u8 irqpin0; /* Interrupt pin for PCI function 0*/
37360c140dfSLino Sanfilippo u8 min_grant; /* 11 Minimum grant */
37460c140dfSLino Sanfilippo u8 max_lat; /* Maximum Latency */
37560c140dfSLino Sanfilippo __le16 sub_vendor_id; /* 12 Subsystem Vendor Id */
37660c140dfSLino Sanfilippo __le16 sub_id; /* 13 Subsystem ID */
37760c140dfSLino Sanfilippo __le16 flash_size; /* 14 Flash size (bytes / 4K) */
37860c140dfSLino Sanfilippo __le16 dram_size2pci; /* 15 DRAM size to PCI (bytes / 64K) */
37960c140dfSLino Sanfilippo __le16 rom_size2pci; /* 16 Flash (ROM extension) size to PCI
38060c140dfSLino Sanfilippo * (bytes / 4K)
38160c140dfSLino Sanfilippo */
38260c140dfSLino Sanfilippo __le16 dev_id1; /* 17 Device Id (function 1) */
38360c140dfSLino Sanfilippo __le16 dev_id2; /* 18 Device Id (function 2) */
38460c140dfSLino Sanfilippo __le16 dev_stat_cfg; /* 19 Device Status Config Bytes 6-7 */
38560c140dfSLino Sanfilippo __le16 pme_cap; /* 20 Power Mgment capabilities */
38660c140dfSLino Sanfilippo u8 msi_cap; /* 21 MSI capabilities */
38760c140dfSLino Sanfilippo u8 clock_div; /* Clock divider */
38860c140dfSLino Sanfilippo __le16 pci_stat_lo; /* 22 PCI Status bits 15:0 */
38960c140dfSLino Sanfilippo __le16 pci_stat_hi; /* 23 PCI Status bits 31:16 */
39060c140dfSLino Sanfilippo __le16 dram_cfg_lo; /* 24 DRAM Configuration bits 15:0 */
39160c140dfSLino Sanfilippo __le16 dram_cfg_hi; /* 25 DRAM Configuration bits 31:16 */
39260c140dfSLino Sanfilippo __le16 dram_size; /* 26 DRAM size (bytes / 64K) */
39360c140dfSLino Sanfilippo __le16 gpio_tbi_ctrl; /* 27 GPIO/TBI controls for functions 1/0 */
39460c140dfSLino Sanfilippo __le16 eeprom_size; /* 28 EEPROM Size */
39560c140dfSLino Sanfilippo u8 mac[ETH_ALEN]; /* 29 MAC addresses (2 ports) */
39660c140dfSLino Sanfilippo u8 mac2[ETH_ALEN];
39760c140dfSLino Sanfilippo u8 fru_format; /* 35 Alacritech FRU format type */
39860c140dfSLino Sanfilippo u8 fru_assembly[6]; /* Alacritech FRU information */
39960c140dfSLino Sanfilippo u8 fru_rev[2];
40060c140dfSLino Sanfilippo u8 fru_serial[14];
40160c140dfSLino Sanfilippo u8 fru_pad[3];
40260c140dfSLino Sanfilippo u8 oem_fru[28]; /* optional OEM FRU information */
40360c140dfSLino Sanfilippo u8 pad[4]; /* Pad to 128 bytes - includes 2 checksum bytes
40460c140dfSLino Sanfilippo * (if OEM FRU info exists) and two unusable
40560c140dfSLino Sanfilippo * bytes at the end
40660c140dfSLino Sanfilippo */
40760c140dfSLino Sanfilippo };
40860c140dfSLino Sanfilippo
40960c140dfSLino Sanfilippo struct slic_stats {
41060c140dfSLino Sanfilippo u64 rx_packets;
41160c140dfSLino Sanfilippo u64 rx_bytes;
41260c140dfSLino Sanfilippo u64 rx_mcasts;
41360c140dfSLino Sanfilippo u64 rx_errors;
41460c140dfSLino Sanfilippo u64 tx_packets;
41560c140dfSLino Sanfilippo u64 tx_bytes;
41660c140dfSLino Sanfilippo /* HW STATS */
41760c140dfSLino Sanfilippo u64 rx_buff_miss;
41860c140dfSLino Sanfilippo u64 tx_dropped;
41960c140dfSLino Sanfilippo u64 irq_errs;
42060c140dfSLino Sanfilippo /* transport layer */
42160c140dfSLino Sanfilippo u64 rx_tpcsum;
42260c140dfSLino Sanfilippo u64 rx_tpoflow;
42360c140dfSLino Sanfilippo u64 rx_tphlen;
42460c140dfSLino Sanfilippo /* ip layer */
42560c140dfSLino Sanfilippo u64 rx_ipcsum;
42660c140dfSLino Sanfilippo u64 rx_iplen;
42760c140dfSLino Sanfilippo u64 rx_iphlen;
42860c140dfSLino Sanfilippo /* link layer */
42960c140dfSLino Sanfilippo u64 rx_early;
43060c140dfSLino Sanfilippo u64 rx_buffoflow;
43160c140dfSLino Sanfilippo u64 rx_lcode;
43260c140dfSLino Sanfilippo u64 rx_drbl;
43360c140dfSLino Sanfilippo u64 rx_crc;
43460c140dfSLino Sanfilippo u64 rx_oflow802;
43560c140dfSLino Sanfilippo u64 rx_uflow802;
43660c140dfSLino Sanfilippo /* oasis only */
43760c140dfSLino Sanfilippo u64 tx_carrier;
43860c140dfSLino Sanfilippo struct u64_stats_sync syncp;
43960c140dfSLino Sanfilippo };
44060c140dfSLino Sanfilippo
44160c140dfSLino Sanfilippo struct slic_shmem_data {
44260c140dfSLino Sanfilippo __le32 isr;
44360c140dfSLino Sanfilippo __le32 link;
44460c140dfSLino Sanfilippo };
44560c140dfSLino Sanfilippo
44660c140dfSLino Sanfilippo struct slic_shmem {
44760c140dfSLino Sanfilippo dma_addr_t isr_paddr;
44860c140dfSLino Sanfilippo dma_addr_t link_paddr;
44960c140dfSLino Sanfilippo struct slic_shmem_data *shmem_data;
45060c140dfSLino Sanfilippo };
45160c140dfSLino Sanfilippo
45260c140dfSLino Sanfilippo struct slic_rx_info_oasis {
45360c140dfSLino Sanfilippo __le32 frame_status;
45460c140dfSLino Sanfilippo __le32 frame_status_b;
45560c140dfSLino Sanfilippo __le32 time_stamp;
45660c140dfSLino Sanfilippo __le32 checksum;
45760c140dfSLino Sanfilippo };
45860c140dfSLino Sanfilippo
45960c140dfSLino Sanfilippo struct slic_rx_info_mojave {
46060c140dfSLino Sanfilippo __le32 frame_status;
46160c140dfSLino Sanfilippo __le16 byte_cnt;
46260c140dfSLino Sanfilippo __le16 tp_chksum;
46360c140dfSLino Sanfilippo __le16 ctx_hash;
46460c140dfSLino Sanfilippo __le16 mac_hash;
46560c140dfSLino Sanfilippo __le16 buff_lnk;
46660c140dfSLino Sanfilippo };
46760c140dfSLino Sanfilippo
46860c140dfSLino Sanfilippo struct slic_stat_desc {
46960c140dfSLino Sanfilippo __le32 hnd;
47060c140dfSLino Sanfilippo __u8 pad[8];
47160c140dfSLino Sanfilippo __le32 status;
47260c140dfSLino Sanfilippo __u8 pad2[16];
47360c140dfSLino Sanfilippo };
47460c140dfSLino Sanfilippo
47560c140dfSLino Sanfilippo struct slic_stat_queue {
47660c140dfSLino Sanfilippo struct slic_stat_desc *descs[SLIC_NUM_STAT_DESC_ARRAYS];
47760c140dfSLino Sanfilippo dma_addr_t paddr[SLIC_NUM_STAT_DESC_ARRAYS];
47860c140dfSLino Sanfilippo unsigned int addr_offset[SLIC_NUM_STAT_DESC_ARRAYS];
47960c140dfSLino Sanfilippo unsigned int active_array;
48060c140dfSLino Sanfilippo unsigned int len;
48160c140dfSLino Sanfilippo unsigned int done_idx;
48260c140dfSLino Sanfilippo size_t mem_size;
48360c140dfSLino Sanfilippo };
48460c140dfSLino Sanfilippo
48560c140dfSLino Sanfilippo struct slic_tx_desc {
48660c140dfSLino Sanfilippo __le32 hnd;
48760c140dfSLino Sanfilippo __le32 rsvd;
48860c140dfSLino Sanfilippo u8 cmd;
48960c140dfSLino Sanfilippo u8 flags;
49060c140dfSLino Sanfilippo __le16 rsvd2;
49160c140dfSLino Sanfilippo __le32 totlen;
49260c140dfSLino Sanfilippo __le32 paddrl;
49360c140dfSLino Sanfilippo __le32 paddrh;
49460c140dfSLino Sanfilippo __le32 len;
49560c140dfSLino Sanfilippo __le32 type;
49660c140dfSLino Sanfilippo };
49760c140dfSLino Sanfilippo
49860c140dfSLino Sanfilippo struct slic_tx_buffer {
49960c140dfSLino Sanfilippo struct sk_buff *skb;
50060c140dfSLino Sanfilippo DEFINE_DMA_UNMAP_ADDR(map_addr);
50160c140dfSLino Sanfilippo DEFINE_DMA_UNMAP_LEN(map_len);
50260c140dfSLino Sanfilippo struct slic_tx_desc *desc;
50360c140dfSLino Sanfilippo dma_addr_t desc_paddr;
50460c140dfSLino Sanfilippo };
50560c140dfSLino Sanfilippo
50660c140dfSLino Sanfilippo struct slic_tx_queue {
50760c140dfSLino Sanfilippo struct dma_pool *dma_pool;
50860c140dfSLino Sanfilippo struct slic_tx_buffer *txbuffs;
50960c140dfSLino Sanfilippo unsigned int len;
51060c140dfSLino Sanfilippo unsigned int put_idx;
51160c140dfSLino Sanfilippo unsigned int done_idx;
51260c140dfSLino Sanfilippo };
51360c140dfSLino Sanfilippo
51460c140dfSLino Sanfilippo struct slic_rx_desc {
51560c140dfSLino Sanfilippo u8 pad[16];
51660c140dfSLino Sanfilippo __le32 buffer;
51760c140dfSLino Sanfilippo __le32 length;
51860c140dfSLino Sanfilippo __le32 status;
51960c140dfSLino Sanfilippo };
52060c140dfSLino Sanfilippo
52160c140dfSLino Sanfilippo struct slic_rx_buffer {
52260c140dfSLino Sanfilippo struct sk_buff *skb;
52360c140dfSLino Sanfilippo DEFINE_DMA_UNMAP_ADDR(map_addr);
52460c140dfSLino Sanfilippo DEFINE_DMA_UNMAP_LEN(map_len);
52560c140dfSLino Sanfilippo unsigned int addr_offset;
52660c140dfSLino Sanfilippo };
52760c140dfSLino Sanfilippo
52860c140dfSLino Sanfilippo struct slic_rx_queue {
52960c140dfSLino Sanfilippo struct slic_rx_buffer *rxbuffs;
53060c140dfSLino Sanfilippo unsigned int len;
53160c140dfSLino Sanfilippo unsigned int done_idx;
53260c140dfSLino Sanfilippo unsigned int put_idx;
53360c140dfSLino Sanfilippo };
53460c140dfSLino Sanfilippo
53560c140dfSLino Sanfilippo struct slic_device {
53660c140dfSLino Sanfilippo struct pci_dev *pdev;
53760c140dfSLino Sanfilippo struct net_device *netdev;
53860c140dfSLino Sanfilippo void __iomem *regs;
53960c140dfSLino Sanfilippo /* upper address setting lock */
54060c140dfSLino Sanfilippo spinlock_t upper_lock;
54160c140dfSLino Sanfilippo struct slic_shmem shmem;
54260c140dfSLino Sanfilippo struct napi_struct napi;
54360c140dfSLino Sanfilippo struct slic_rx_queue rxq;
54460c140dfSLino Sanfilippo struct slic_tx_queue txq;
54560c140dfSLino Sanfilippo struct slic_stat_queue stq;
54660c140dfSLino Sanfilippo struct slic_stats stats;
54760c140dfSLino Sanfilippo struct slic_upr_list upr_list;
54860c140dfSLino Sanfilippo /* link configuration lock */
54960c140dfSLino Sanfilippo spinlock_t link_lock;
55060c140dfSLino Sanfilippo bool promisc;
55160c140dfSLino Sanfilippo int speed;
55260c140dfSLino Sanfilippo unsigned int duplex;
55360c140dfSLino Sanfilippo bool is_fiber;
55460c140dfSLino Sanfilippo unsigned char model;
55560c140dfSLino Sanfilippo };
55660c140dfSLino Sanfilippo
slic_read(struct slic_device * sdev,unsigned int reg)55760c140dfSLino Sanfilippo static inline u32 slic_read(struct slic_device *sdev, unsigned int reg)
55860c140dfSLino Sanfilippo {
55960c140dfSLino Sanfilippo return ioread32(sdev->regs + reg);
56060c140dfSLino Sanfilippo }
56160c140dfSLino Sanfilippo
slic_write(struct slic_device * sdev,unsigned int reg,u32 val)56260c140dfSLino Sanfilippo static inline void slic_write(struct slic_device *sdev, unsigned int reg,
56360c140dfSLino Sanfilippo u32 val)
56460c140dfSLino Sanfilippo {
56560c140dfSLino Sanfilippo iowrite32(val, sdev->regs + reg);
56660c140dfSLino Sanfilippo }
56760c140dfSLino Sanfilippo
slic_flush_write(struct slic_device * sdev)56860c140dfSLino Sanfilippo static inline void slic_flush_write(struct slic_device *sdev)
56960c140dfSLino Sanfilippo {
57060c140dfSLino Sanfilippo (void)ioread32(sdev->regs + SLIC_REG_HOSTID);
57160c140dfSLino Sanfilippo }
57260c140dfSLino Sanfilippo
57360c140dfSLino Sanfilippo #endif /* _SLIC_H */
574