18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci#ifndef _SLIC_H 48c2ecf20Sopenharmony_ci#define _SLIC_H 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#include <linux/types.h> 78c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 88c2ecf20Sopenharmony_ci#include <linux/spinlock_types.h> 98c2ecf20Sopenharmony_ci#include <linux/dma-mapping.h> 108c2ecf20Sopenharmony_ci#include <linux/pci.h> 118c2ecf20Sopenharmony_ci#include <linux/list.h> 128c2ecf20Sopenharmony_ci#include <linux/u64_stats_sync.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#define SLIC_VGBSTAT_XPERR 0x40000000 158c2ecf20Sopenharmony_ci#define SLIC_VGBSTAT_XERRSHFT 25 168c2ecf20Sopenharmony_ci#define SLIC_VGBSTAT_XCSERR 0x23 178c2ecf20Sopenharmony_ci#define SLIC_VGBSTAT_XUFLOW 0x22 188c2ecf20Sopenharmony_ci#define SLIC_VGBSTAT_XHLEN 0x20 198c2ecf20Sopenharmony_ci#define SLIC_VGBSTAT_NETERR 0x01000000 208c2ecf20Sopenharmony_ci#define SLIC_VGBSTAT_NERRSHFT 16 218c2ecf20Sopenharmony_ci#define SLIC_VGBSTAT_NERRMSK 0x1ff 228c2ecf20Sopenharmony_ci#define SLIC_VGBSTAT_NCSERR 0x103 238c2ecf20Sopenharmony_ci#define SLIC_VGBSTAT_NUFLOW 0x102 248c2ecf20Sopenharmony_ci#define SLIC_VGBSTAT_NHLEN 0x100 258c2ecf20Sopenharmony_ci#define SLIC_VGBSTAT_LNKERR 0x00000080 268c2ecf20Sopenharmony_ci#define SLIC_VGBSTAT_LERRMSK 0xff 278c2ecf20Sopenharmony_ci#define SLIC_VGBSTAT_LDEARLY 0x86 288c2ecf20Sopenharmony_ci#define SLIC_VGBSTAT_LBOFLO 0x85 298c2ecf20Sopenharmony_ci#define SLIC_VGBSTAT_LCODERR 0x84 308c2ecf20Sopenharmony_ci#define SLIC_VGBSTAT_LDBLNBL 0x83 318c2ecf20Sopenharmony_ci#define SLIC_VGBSTAT_LCRCERR 0x82 328c2ecf20Sopenharmony_ci#define SLIC_VGBSTAT_LOFLO 0x81 338c2ecf20Sopenharmony_ci#define SLIC_VGBSTAT_LUFLO 0x80 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#define SLIC_IRHDDR_FLEN_MSK 0x0000ffff 368c2ecf20Sopenharmony_ci#define SLIC_IRHDDR_SVALID 0x80000000 378c2ecf20Sopenharmony_ci#define SLIC_IRHDDR_ERR 0x10000000 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci#define SLIC_VRHSTAT_802OE 0x80000000 408c2ecf20Sopenharmony_ci#define SLIC_VRHSTAT_TPOFLO 0x10000000 418c2ecf20Sopenharmony_ci#define SLIC_VRHSTATB_802UE 0x80000000 428c2ecf20Sopenharmony_ci#define SLIC_VRHSTATB_RCVE 0x40000000 438c2ecf20Sopenharmony_ci#define SLIC_VRHSTATB_BUFF 0x20000000 448c2ecf20Sopenharmony_ci#define SLIC_VRHSTATB_CARRE 0x08000000 458c2ecf20Sopenharmony_ci#define SLIC_VRHSTATB_LONGE 0x02000000 468c2ecf20Sopenharmony_ci#define SLIC_VRHSTATB_PREA 0x01000000 478c2ecf20Sopenharmony_ci#define SLIC_VRHSTATB_CRC 0x00800000 488c2ecf20Sopenharmony_ci#define SLIC_VRHSTATB_DRBL 0x00400000 498c2ecf20Sopenharmony_ci#define SLIC_VRHSTATB_CODE 0x00200000 508c2ecf20Sopenharmony_ci#define SLIC_VRHSTATB_TPCSUM 0x00100000 518c2ecf20Sopenharmony_ci#define SLIC_VRHSTATB_TPHLEN 0x00080000 528c2ecf20Sopenharmony_ci#define SLIC_VRHSTATB_IPCSUM 0x00040000 538c2ecf20Sopenharmony_ci#define SLIC_VRHSTATB_IPLERR 0x00020000 548c2ecf20Sopenharmony_ci#define SLIC_VRHSTATB_IPHERR 0x00010000 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#define SLIC_CMD_XMT_REQ 0x01 578c2ecf20Sopenharmony_ci#define SLIC_CMD_TYPE_DUMB 3 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci#define SLIC_RESET_MAGIC 0xDEAD 608c2ecf20Sopenharmony_ci#define SLIC_ICR_INT_OFF 0 618c2ecf20Sopenharmony_ci#define SLIC_ICR_INT_ON 1 628c2ecf20Sopenharmony_ci#define SLIC_ICR_INT_MASK 2 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#define SLIC_ISR_ERR 0x80000000 658c2ecf20Sopenharmony_ci#define SLIC_ISR_RCV 0x40000000 668c2ecf20Sopenharmony_ci#define SLIC_ISR_CMD 0x20000000 678c2ecf20Sopenharmony_ci#define SLIC_ISR_IO 0x60000000 688c2ecf20Sopenharmony_ci#define SLIC_ISR_UPC 0x10000000 698c2ecf20Sopenharmony_ci#define SLIC_ISR_LEVENT 0x08000000 708c2ecf20Sopenharmony_ci#define SLIC_ISR_RMISS 0x02000000 718c2ecf20Sopenharmony_ci#define SLIC_ISR_UPCERR 0x01000000 728c2ecf20Sopenharmony_ci#define SLIC_ISR_XDROP 0x00800000 738c2ecf20Sopenharmony_ci#define SLIC_ISR_UPCBSY 0x00020000 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#define SLIC_ISR_PING_MASK 0x00700000 768c2ecf20Sopenharmony_ci#define SLIC_ISR_UPCERR_MASK (SLIC_ISR_UPCERR | SLIC_ISR_UPCBSY) 778c2ecf20Sopenharmony_ci#define SLIC_ISR_UPC_MASK (SLIC_ISR_UPC | SLIC_ISR_UPCERR_MASK) 788c2ecf20Sopenharmony_ci#define SLIC_WCS_START 0x80000000 798c2ecf20Sopenharmony_ci#define SLIC_WCS_COMPARE 0x40000000 808c2ecf20Sopenharmony_ci#define SLIC_RCVWCS_BEGIN 0x40000000 818c2ecf20Sopenharmony_ci#define SLIC_RCVWCS_FINISH 0x80000000 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci#define SLIC_MIICR_REG_16 0x00100000 848c2ecf20Sopenharmony_ci#define SLIC_MRV_REG16_XOVERON 0x0068 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci#define SLIC_GIG_LINKUP 0x0001 878c2ecf20Sopenharmony_ci#define SLIC_GIG_FULLDUPLEX 0x0002 888c2ecf20Sopenharmony_ci#define SLIC_GIG_SPEED_MASK 0x000C 898c2ecf20Sopenharmony_ci#define SLIC_GIG_SPEED_1000 0x0008 908c2ecf20Sopenharmony_ci#define SLIC_GIG_SPEED_100 0x0004 918c2ecf20Sopenharmony_ci#define SLIC_GIG_SPEED_10 0x0000 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci#define SLIC_GMCR_RESET 0x80000000 948c2ecf20Sopenharmony_ci#define SLIC_GMCR_GBIT 0x20000000 958c2ecf20Sopenharmony_ci#define SLIC_GMCR_FULLD 0x10000000 968c2ecf20Sopenharmony_ci#define SLIC_GMCR_GAPBB_SHIFT 14 978c2ecf20Sopenharmony_ci#define SLIC_GMCR_GAPR1_SHIFT 7 988c2ecf20Sopenharmony_ci#define SLIC_GMCR_GAPR2_SHIFT 0 998c2ecf20Sopenharmony_ci#define SLIC_GMCR_GAPBB_1000 0x60 1008c2ecf20Sopenharmony_ci#define SLIC_GMCR_GAPR1_1000 0x2C 1018c2ecf20Sopenharmony_ci#define SLIC_GMCR_GAPR2_1000 0x40 1028c2ecf20Sopenharmony_ci#define SLIC_GMCR_GAPBB_100 0x70 1038c2ecf20Sopenharmony_ci#define SLIC_GMCR_GAPR1_100 0x2C 1048c2ecf20Sopenharmony_ci#define SLIC_GMCR_GAPR2_100 0x40 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci#define SLIC_XCR_RESET 0x80000000 1078c2ecf20Sopenharmony_ci#define SLIC_XCR_XMTEN 0x40000000 1088c2ecf20Sopenharmony_ci#define SLIC_XCR_PAUSEEN 0x20000000 1098c2ecf20Sopenharmony_ci#define SLIC_XCR_LOADRNG 0x10000000 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci#define SLIC_GXCR_RESET 0x80000000 1128c2ecf20Sopenharmony_ci#define SLIC_GXCR_XMTEN 0x40000000 1138c2ecf20Sopenharmony_ci#define SLIC_GXCR_PAUSEEN 0x20000000 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci#define SLIC_GRCR_RESET 0x80000000 1168c2ecf20Sopenharmony_ci#define SLIC_GRCR_RCVEN 0x40000000 1178c2ecf20Sopenharmony_ci#define SLIC_GRCR_RCVALL 0x20000000 1188c2ecf20Sopenharmony_ci#define SLIC_GRCR_RCVBAD 0x10000000 1198c2ecf20Sopenharmony_ci#define SLIC_GRCR_CTLEN 0x08000000 1208c2ecf20Sopenharmony_ci#define SLIC_GRCR_ADDRAEN 0x02000000 1218c2ecf20Sopenharmony_ci#define SLIC_GRCR_HASHSIZE_SHIFT 17 1228c2ecf20Sopenharmony_ci#define SLIC_GRCR_HASHSIZE 14 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci/* Reset Register */ 1258c2ecf20Sopenharmony_ci#define SLIC_REG_RESET 0x0000 1268c2ecf20Sopenharmony_ci/* Interrupt Control Register */ 1278c2ecf20Sopenharmony_ci#define SLIC_REG_ICR 0x0008 1288c2ecf20Sopenharmony_ci/* Interrupt status pointer */ 1298c2ecf20Sopenharmony_ci#define SLIC_REG_ISP 0x0010 1308c2ecf20Sopenharmony_ci/* Interrupt status */ 1318c2ecf20Sopenharmony_ci#define SLIC_REG_ISR 0x0018 1328c2ecf20Sopenharmony_ci/* Header buffer address reg 1338c2ecf20Sopenharmony_ci * 31-8 - phy addr of set of contiguous hdr buffers 1348c2ecf20Sopenharmony_ci * 7-0 - number of buffers passed 1358c2ecf20Sopenharmony_ci * Buffers are 256 bytes long on 256-byte boundaries. 1368c2ecf20Sopenharmony_ci */ 1378c2ecf20Sopenharmony_ci#define SLIC_REG_HBAR 0x0020 1388c2ecf20Sopenharmony_ci/* Data buffer handle & address reg 1398c2ecf20Sopenharmony_ci * 4 sets of registers; Buffers are 2K bytes long 2 per 4K page. 1408c2ecf20Sopenharmony_ci */ 1418c2ecf20Sopenharmony_ci#define SLIC_REG_DBAR 0x0028 1428c2ecf20Sopenharmony_ci/* Xmt Cmd buf addr regs. 1438c2ecf20Sopenharmony_ci * 1 per XMT interface 1448c2ecf20Sopenharmony_ci * 31-5 - phy addr of host command buffer 1458c2ecf20Sopenharmony_ci * 4-0 - length of cmd in multiples of 32 bytes 1468c2ecf20Sopenharmony_ci * Buffers are 32 bytes up to 512 bytes long 1478c2ecf20Sopenharmony_ci */ 1488c2ecf20Sopenharmony_ci#define SLIC_REG_CBAR 0x0030 1498c2ecf20Sopenharmony_ci/* Write control store */ 1508c2ecf20Sopenharmony_ci#define SLIC_REG_WCS 0x0034 1518c2ecf20Sopenharmony_ci/*Response buffer address reg. 1528c2ecf20Sopenharmony_ci * 31-8 - phy addr of set of contiguous response buffers 1538c2ecf20Sopenharmony_ci * 7-0 - number of buffers passed 1548c2ecf20Sopenharmony_ci * Buffers are 32 bytes long on 32-byte boundaries. 1558c2ecf20Sopenharmony_ci */ 1568c2ecf20Sopenharmony_ci#define SLIC_REG_RBAR 0x0038 1578c2ecf20Sopenharmony_ci/* Read statistics (UPR) */ 1588c2ecf20Sopenharmony_ci#define SLIC_REG_RSTAT 0x0040 1598c2ecf20Sopenharmony_ci/* Read link status */ 1608c2ecf20Sopenharmony_ci#define SLIC_REG_LSTAT 0x0048 1618c2ecf20Sopenharmony_ci/* Write Mac Config */ 1628c2ecf20Sopenharmony_ci#define SLIC_REG_WMCFG 0x0050 1638c2ecf20Sopenharmony_ci/* Write phy register */ 1648c2ecf20Sopenharmony_ci#define SLIC_REG_WPHY 0x0058 1658c2ecf20Sopenharmony_ci/* Rcv Cmd buf addr reg */ 1668c2ecf20Sopenharmony_ci#define SLIC_REG_RCBAR 0x0060 1678c2ecf20Sopenharmony_ci/* Read SLIC Config*/ 1688c2ecf20Sopenharmony_ci#define SLIC_REG_RCONFIG 0x0068 1698c2ecf20Sopenharmony_ci/* Interrupt aggregation time */ 1708c2ecf20Sopenharmony_ci#define SLIC_REG_INTAGG 0x0070 1718c2ecf20Sopenharmony_ci/* Write XMIT config reg */ 1728c2ecf20Sopenharmony_ci#define SLIC_REG_WXCFG 0x0078 1738c2ecf20Sopenharmony_ci/* Write RCV config reg */ 1748c2ecf20Sopenharmony_ci#define SLIC_REG_WRCFG 0x0080 1758c2ecf20Sopenharmony_ci/* Write rcv addr a low */ 1768c2ecf20Sopenharmony_ci#define SLIC_REG_WRADDRAL 0x0088 1778c2ecf20Sopenharmony_ci/* Write rcv addr a high */ 1788c2ecf20Sopenharmony_ci#define SLIC_REG_WRADDRAH 0x0090 1798c2ecf20Sopenharmony_ci/* Write rcv addr b low */ 1808c2ecf20Sopenharmony_ci#define SLIC_REG_WRADDRBL 0x0098 1818c2ecf20Sopenharmony_ci/* Write rcv addr b high */ 1828c2ecf20Sopenharmony_ci#define SLIC_REG_WRADDRBH 0x00a0 1838c2ecf20Sopenharmony_ci/* Low bits of mcast mask */ 1848c2ecf20Sopenharmony_ci#define SLIC_REG_MCASTLOW 0x00a8 1858c2ecf20Sopenharmony_ci/* High bits of mcast mask */ 1868c2ecf20Sopenharmony_ci#define SLIC_REG_MCASTHIGH 0x00b0 1878c2ecf20Sopenharmony_ci/* Ping the card */ 1888c2ecf20Sopenharmony_ci#define SLIC_REG_PING 0x00b8 1898c2ecf20Sopenharmony_ci/* Dump command */ 1908c2ecf20Sopenharmony_ci#define SLIC_REG_DUMP_CMD 0x00c0 1918c2ecf20Sopenharmony_ci/* Dump data pointer */ 1928c2ecf20Sopenharmony_ci#define SLIC_REG_DUMP_DATA 0x00c8 1938c2ecf20Sopenharmony_ci/* Read card's pci_status register */ 1948c2ecf20Sopenharmony_ci#define SLIC_REG_PCISTATUS 0x00d0 1958c2ecf20Sopenharmony_ci/* Write hostid field */ 1968c2ecf20Sopenharmony_ci#define SLIC_REG_WRHOSTID 0x00d8 1978c2ecf20Sopenharmony_ci/* Put card in a low power state */ 1988c2ecf20Sopenharmony_ci#define SLIC_REG_LOW_POWER 0x00e0 1998c2ecf20Sopenharmony_ci/* Force slic into quiescent state before soft reset */ 2008c2ecf20Sopenharmony_ci#define SLIC_REG_QUIESCE 0x00e8 2018c2ecf20Sopenharmony_ci/* Reset interface queues */ 2028c2ecf20Sopenharmony_ci#define SLIC_REG_RESET_IFACE 0x00f0 2038c2ecf20Sopenharmony_ci/* Register is only written when it has changed. 2048c2ecf20Sopenharmony_ci * Bits 63-32 for host i/f addrs. 2058c2ecf20Sopenharmony_ci */ 2068c2ecf20Sopenharmony_ci#define SLIC_REG_ADDR_UPPER 0x00f8 2078c2ecf20Sopenharmony_ci/* 64 bit Header buffer address reg */ 2088c2ecf20Sopenharmony_ci#define SLIC_REG_HBAR64 0x0100 2098c2ecf20Sopenharmony_ci/* 64 bit Data buffer handle & address reg */ 2108c2ecf20Sopenharmony_ci#define SLIC_REG_DBAR64 0x0108 2118c2ecf20Sopenharmony_ci/* 64 bit Xmt Cmd buf addr regs. */ 2128c2ecf20Sopenharmony_ci#define SLIC_REG_CBAR64 0x0110 2138c2ecf20Sopenharmony_ci/* 64 bit Response buffer address reg.*/ 2148c2ecf20Sopenharmony_ci#define SLIC_REG_RBAR64 0x0118 2158c2ecf20Sopenharmony_ci/* 64 bit Rcv Cmd buf addr reg*/ 2168c2ecf20Sopenharmony_ci#define SLIC_REG_RCBAR64 0x0120 2178c2ecf20Sopenharmony_ci/* Read statistics (64 bit UPR) */ 2188c2ecf20Sopenharmony_ci#define SLIC_REG_RSTAT64 0x0128 2198c2ecf20Sopenharmony_ci/* Download Gigabit RCV sequencer ucode */ 2208c2ecf20Sopenharmony_ci#define SLIC_REG_RCV_WCS 0x0130 2218c2ecf20Sopenharmony_ci/* Write VlanId field */ 2228c2ecf20Sopenharmony_ci#define SLIC_REG_WRVLANID 0x0138 2238c2ecf20Sopenharmony_ci/* Read Transformer info */ 2248c2ecf20Sopenharmony_ci#define SLIC_REG_READ_XF_INFO 0x0140 2258c2ecf20Sopenharmony_ci/* Write Transformer info */ 2268c2ecf20Sopenharmony_ci#define SLIC_REG_WRITE_XF_INFO 0x0148 2278c2ecf20Sopenharmony_ci/* Write card ticks per second */ 2288c2ecf20Sopenharmony_ci#define SLIC_REG_TICKS_PER_SEC 0x0170 2298c2ecf20Sopenharmony_ci#define SLIC_REG_HOSTID 0x1554 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci#define PCI_VENDOR_ID_ALACRITECH 0x139A 2328c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ALACRITECH_MOJAVE 0x0005 2338c2ecf20Sopenharmony_ci#define PCI_SUBDEVICE_ID_ALACRITECH_1000X1 0x0005 2348c2ecf20Sopenharmony_ci#define PCI_SUBDEVICE_ID_ALACRITECH_1000X1_2 0x0006 2358c2ecf20Sopenharmony_ci#define PCI_SUBDEVICE_ID_ALACRITECH_1000X1F 0x0007 2368c2ecf20Sopenharmony_ci#define PCI_SUBDEVICE_ID_ALACRITECH_CICADA 0x0008 2378c2ecf20Sopenharmony_ci#define PCI_SUBDEVICE_ID_ALACRITECH_SES1001T 0x2006 2388c2ecf20Sopenharmony_ci#define PCI_SUBDEVICE_ID_ALACRITECH_SES1001F 0x2007 2398c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ALACRITECH_OASIS 0x0007 2408c2ecf20Sopenharmony_ci#define PCI_SUBDEVICE_ID_ALACRITECH_SEN2002XT 0x000B 2418c2ecf20Sopenharmony_ci#define PCI_SUBDEVICE_ID_ALACRITECH_SEN2002XF 0x000C 2428c2ecf20Sopenharmony_ci#define PCI_SUBDEVICE_ID_ALACRITECH_SEN2001XT 0x000D 2438c2ecf20Sopenharmony_ci#define PCI_SUBDEVICE_ID_ALACRITECH_SEN2001XF 0x000E 2448c2ecf20Sopenharmony_ci#define PCI_SUBDEVICE_ID_ALACRITECH_SEN2104EF 0x000F 2458c2ecf20Sopenharmony_ci#define PCI_SUBDEVICE_ID_ALACRITECH_SEN2104ET 0x0010 2468c2ecf20Sopenharmony_ci#define PCI_SUBDEVICE_ID_ALACRITECH_SEN2102EF 0x0011 2478c2ecf20Sopenharmony_ci#define PCI_SUBDEVICE_ID_ALACRITECH_SEN2102ET 0x0012 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_ci/* Note: power of two required for number descriptors */ 2508c2ecf20Sopenharmony_ci#define SLIC_NUM_RX_LES 256 2518c2ecf20Sopenharmony_ci#define SLIC_RX_BUFF_SIZE 2048 2528c2ecf20Sopenharmony_ci#define SLIC_RX_BUFF_ALIGN 256 2538c2ecf20Sopenharmony_ci#define SLIC_RX_BUFF_HDR_SIZE 34 2548c2ecf20Sopenharmony_ci#define SLIC_MAX_REQ_RX_DESCS 1 2558c2ecf20Sopenharmony_ci 2568c2ecf20Sopenharmony_ci#define SLIC_NUM_TX_DESCS 256 2578c2ecf20Sopenharmony_ci#define SLIC_TX_DESC_ALIGN 32 2588c2ecf20Sopenharmony_ci#define SLIC_MIN_TX_WAKEUP_DESCS 10 2598c2ecf20Sopenharmony_ci#define SLIC_MAX_REQ_TX_DESCS 1 2608c2ecf20Sopenharmony_ci#define SLIC_MAX_TX_COMPLETIONS 100 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_ci#define SLIC_NUM_STAT_DESCS 128 2638c2ecf20Sopenharmony_ci#define SLIC_STATS_DESC_ALIGN 256 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci#define SLIC_NUM_STAT_DESC_ARRAYS 4 2668c2ecf20Sopenharmony_ci#define SLIC_INVALID_STAT_DESC_IDX 0xffffffff 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci#define SLIC_NAPI_WEIGHT 64 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci#define SLIC_UPR_LSTAT 0 2718c2ecf20Sopenharmony_ci#define SLIC_UPR_CONFIG 1 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci#define SLIC_EEPROM_SIZE 128 2748c2ecf20Sopenharmony_ci#define SLIC_EEPROM_MAGIC 0xa5a5 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_ci#define SLIC_FIRMWARE_MOJAVE "slicoss/gbdownload.sys" 2778c2ecf20Sopenharmony_ci#define SLIC_FIRMWARE_OASIS "slicoss/oasisdownload.sys" 2788c2ecf20Sopenharmony_ci#define SLIC_RCV_FIRMWARE_MOJAVE "slicoss/gbrcvucode.sys" 2798c2ecf20Sopenharmony_ci#define SLIC_RCV_FIRMWARE_OASIS "slicoss/oasisrcvucode.sys" 2808c2ecf20Sopenharmony_ci#define SLIC_FIRMWARE_MIN_SIZE 64 2818c2ecf20Sopenharmony_ci#define SLIC_FIRMWARE_MAX_SECTIONS 3 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ci#define SLIC_MODEL_MOJAVE 0 2848c2ecf20Sopenharmony_ci#define SLIC_MODEL_OASIS 1 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci#define SLIC_INC_STATS_COUNTER(st, counter) \ 2878c2ecf20Sopenharmony_cido { \ 2888c2ecf20Sopenharmony_ci u64_stats_update_begin(&(st)->syncp); \ 2898c2ecf20Sopenharmony_ci (st)->counter++; \ 2908c2ecf20Sopenharmony_ci u64_stats_update_end(&(st)->syncp); \ 2918c2ecf20Sopenharmony_ci} while (0) 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ci#define SLIC_GET_STATS_COUNTER(newst, st, counter) \ 2948c2ecf20Sopenharmony_ci{ \ 2958c2ecf20Sopenharmony_ci unsigned int start; \ 2968c2ecf20Sopenharmony_ci do { \ 2978c2ecf20Sopenharmony_ci start = u64_stats_fetch_begin_irq(&(st)->syncp); \ 2988c2ecf20Sopenharmony_ci newst = (st)->counter; \ 2998c2ecf20Sopenharmony_ci } while (u64_stats_fetch_retry_irq(&(st)->syncp, start)); \ 3008c2ecf20Sopenharmony_ci} 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_cistruct slic_upr { 3038c2ecf20Sopenharmony_ci dma_addr_t paddr; 3048c2ecf20Sopenharmony_ci unsigned int type; 3058c2ecf20Sopenharmony_ci struct list_head list; 3068c2ecf20Sopenharmony_ci}; 3078c2ecf20Sopenharmony_ci 3088c2ecf20Sopenharmony_cistruct slic_upr_list { 3098c2ecf20Sopenharmony_ci bool pending; 3108c2ecf20Sopenharmony_ci struct list_head list; 3118c2ecf20Sopenharmony_ci /* upr list lock */ 3128c2ecf20Sopenharmony_ci spinlock_t lock; 3138c2ecf20Sopenharmony_ci}; 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_ci/* SLIC EEPROM structure for Mojave */ 3168c2ecf20Sopenharmony_cistruct slic_mojave_eeprom { 3178c2ecf20Sopenharmony_ci __le16 id; /* 00 EEPROM/FLASH Magic code 'A5A5'*/ 3188c2ecf20Sopenharmony_ci __le16 eeprom_code_size;/* 01 Size of EEPROM Codes (bytes * 4)*/ 3198c2ecf20Sopenharmony_ci __le16 flash_size; /* 02 Flash size */ 3208c2ecf20Sopenharmony_ci __le16 eeprom_size; /* 03 EEPROM Size */ 3218c2ecf20Sopenharmony_ci __le16 vendor_id; /* 04 Vendor ID */ 3228c2ecf20Sopenharmony_ci __le16 dev_id; /* 05 Device ID */ 3238c2ecf20Sopenharmony_ci u8 rev_id; /* 06 Revision ID */ 3248c2ecf20Sopenharmony_ci u8 class_code[3]; /* 07 Class Code */ 3258c2ecf20Sopenharmony_ci u8 irqpin_dbg; /* 08 Debug Interrupt pin */ 3268c2ecf20Sopenharmony_ci u8 irqpin; /* Network Interrupt Pin */ 3278c2ecf20Sopenharmony_ci u8 min_grant; /* 09 Minimum grant */ 3288c2ecf20Sopenharmony_ci u8 max_lat; /* Maximum Latency */ 3298c2ecf20Sopenharmony_ci __le16 pci_stat; /* 10 PCI Status */ 3308c2ecf20Sopenharmony_ci __le16 sub_vendor_id; /* 11 Subsystem Vendor Id */ 3318c2ecf20Sopenharmony_ci __le16 sub_id; /* 12 Subsystem ID */ 3328c2ecf20Sopenharmony_ci __le16 dev_id_dbg; /* 13 Debug Device Id */ 3338c2ecf20Sopenharmony_ci __le16 ramrom; /* 14 Dram/Rom function */ 3348c2ecf20Sopenharmony_ci __le16 dram_size2pci; /* 15 DRAM size to PCI (bytes * 64K) */ 3358c2ecf20Sopenharmony_ci __le16 rom_size2pci; /* 16 ROM extension size to PCI (bytes * 4k) */ 3368c2ecf20Sopenharmony_ci u8 pad[2]; /* 17 Padding */ 3378c2ecf20Sopenharmony_ci u8 freetime; /* 18 FreeTime setting */ 3388c2ecf20Sopenharmony_ci u8 ifctrl; /* 10-bit interface control (Mojave only) */ 3398c2ecf20Sopenharmony_ci __le16 dram_size; /* 19 DRAM size (bytes * 64k) */ 3408c2ecf20Sopenharmony_ci u8 mac[ETH_ALEN]; /* 20 MAC addresses */ 3418c2ecf20Sopenharmony_ci u8 mac2[ETH_ALEN]; 3428c2ecf20Sopenharmony_ci u8 pad2[6]; 3438c2ecf20Sopenharmony_ci u16 dev_id2; /* Device ID for 2nd PCI function */ 3448c2ecf20Sopenharmony_ci u8 irqpin2; /* Interrupt pin for 2nd PCI function */ 3458c2ecf20Sopenharmony_ci u8 class_code2[3]; /* Class Code for 2nd PCI function */ 3468c2ecf20Sopenharmony_ci u16 cfg_byte6; /* Config Byte 6 */ 3478c2ecf20Sopenharmony_ci u16 pme_cap; /* Power Mgment capabilities */ 3488c2ecf20Sopenharmony_ci u16 nwclk_ctrl; /* NetworkClockControls */ 3498c2ecf20Sopenharmony_ci u8 fru_format; /* Alacritech FRU format type */ 3508c2ecf20Sopenharmony_ci u8 fru_assembly[6]; /* Alacritech FRU information */ 3518c2ecf20Sopenharmony_ci u8 fru_rev[2]; 3528c2ecf20Sopenharmony_ci u8 fru_serial[14]; 3538c2ecf20Sopenharmony_ci u8 fru_pad[3]; 3548c2ecf20Sopenharmony_ci u8 oem_fru[28]; /* optional OEM FRU format type */ 3558c2ecf20Sopenharmony_ci u8 pad3[4]; /* Pad to 128 bytes - includes 2 cksum bytes 3568c2ecf20Sopenharmony_ci * (if OEM FRU info exists) and two unusable 3578c2ecf20Sopenharmony_ci * bytes at the end 3588c2ecf20Sopenharmony_ci */ 3598c2ecf20Sopenharmony_ci}; 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_ci/* SLIC EEPROM structure for Oasis */ 3628c2ecf20Sopenharmony_cistruct slic_oasis_eeprom { 3638c2ecf20Sopenharmony_ci __le16 id; /* 00 EEPROM/FLASH Magic code 'A5A5' */ 3648c2ecf20Sopenharmony_ci __le16 eeprom_code_size;/* 01 Size of EEPROM Codes (bytes * 4)*/ 3658c2ecf20Sopenharmony_ci __le16 spidev0_cfg; /* 02 Flash Config for SPI device 0 */ 3668c2ecf20Sopenharmony_ci __le16 spidev1_cfg; /* 03 Flash Config for SPI device 1 */ 3678c2ecf20Sopenharmony_ci __le16 vendor_id; /* 04 Vendor ID */ 3688c2ecf20Sopenharmony_ci __le16 dev_id; /* 05 Device ID (function 0) */ 3698c2ecf20Sopenharmony_ci u8 rev_id; /* 06 Revision ID */ 3708c2ecf20Sopenharmony_ci u8 class_code0[3]; /* 07 Class Code for PCI function 0 */ 3718c2ecf20Sopenharmony_ci u8 irqpin1; /* 08 Interrupt pin for PCI function 1*/ 3728c2ecf20Sopenharmony_ci u8 class_code1[3]; /* 09 Class Code for PCI function 1 */ 3738c2ecf20Sopenharmony_ci u8 irqpin2; /* 10 Interrupt pin for PCI function 2*/ 3748c2ecf20Sopenharmony_ci u8 irqpin0; /* Interrupt pin for PCI function 0*/ 3758c2ecf20Sopenharmony_ci u8 min_grant; /* 11 Minimum grant */ 3768c2ecf20Sopenharmony_ci u8 max_lat; /* Maximum Latency */ 3778c2ecf20Sopenharmony_ci __le16 sub_vendor_id; /* 12 Subsystem Vendor Id */ 3788c2ecf20Sopenharmony_ci __le16 sub_id; /* 13 Subsystem ID */ 3798c2ecf20Sopenharmony_ci __le16 flash_size; /* 14 Flash size (bytes / 4K) */ 3808c2ecf20Sopenharmony_ci __le16 dram_size2pci; /* 15 DRAM size to PCI (bytes / 64K) */ 3818c2ecf20Sopenharmony_ci __le16 rom_size2pci; /* 16 Flash (ROM extension) size to PCI 3828c2ecf20Sopenharmony_ci * (bytes / 4K) 3838c2ecf20Sopenharmony_ci */ 3848c2ecf20Sopenharmony_ci __le16 dev_id1; /* 17 Device Id (function 1) */ 3858c2ecf20Sopenharmony_ci __le16 dev_id2; /* 18 Device Id (function 2) */ 3868c2ecf20Sopenharmony_ci __le16 dev_stat_cfg; /* 19 Device Status Config Bytes 6-7 */ 3878c2ecf20Sopenharmony_ci __le16 pme_cap; /* 20 Power Mgment capabilities */ 3888c2ecf20Sopenharmony_ci u8 msi_cap; /* 21 MSI capabilities */ 3898c2ecf20Sopenharmony_ci u8 clock_div; /* Clock divider */ 3908c2ecf20Sopenharmony_ci __le16 pci_stat_lo; /* 22 PCI Status bits 15:0 */ 3918c2ecf20Sopenharmony_ci __le16 pci_stat_hi; /* 23 PCI Status bits 31:16 */ 3928c2ecf20Sopenharmony_ci __le16 dram_cfg_lo; /* 24 DRAM Configuration bits 15:0 */ 3938c2ecf20Sopenharmony_ci __le16 dram_cfg_hi; /* 25 DRAM Configuration bits 31:16 */ 3948c2ecf20Sopenharmony_ci __le16 dram_size; /* 26 DRAM size (bytes / 64K) */ 3958c2ecf20Sopenharmony_ci __le16 gpio_tbi_ctrl; /* 27 GPIO/TBI controls for functions 1/0 */ 3968c2ecf20Sopenharmony_ci __le16 eeprom_size; /* 28 EEPROM Size */ 3978c2ecf20Sopenharmony_ci u8 mac[ETH_ALEN]; /* 29 MAC addresses (2 ports) */ 3988c2ecf20Sopenharmony_ci u8 mac2[ETH_ALEN]; 3998c2ecf20Sopenharmony_ci u8 fru_format; /* 35 Alacritech FRU format type */ 4008c2ecf20Sopenharmony_ci u8 fru_assembly[6]; /* Alacritech FRU information */ 4018c2ecf20Sopenharmony_ci u8 fru_rev[2]; 4028c2ecf20Sopenharmony_ci u8 fru_serial[14]; 4038c2ecf20Sopenharmony_ci u8 fru_pad[3]; 4048c2ecf20Sopenharmony_ci u8 oem_fru[28]; /* optional OEM FRU information */ 4058c2ecf20Sopenharmony_ci u8 pad[4]; /* Pad to 128 bytes - includes 2 checksum bytes 4068c2ecf20Sopenharmony_ci * (if OEM FRU info exists) and two unusable 4078c2ecf20Sopenharmony_ci * bytes at the end 4088c2ecf20Sopenharmony_ci */ 4098c2ecf20Sopenharmony_ci}; 4108c2ecf20Sopenharmony_ci 4118c2ecf20Sopenharmony_cistruct slic_stats { 4128c2ecf20Sopenharmony_ci u64 rx_packets; 4138c2ecf20Sopenharmony_ci u64 rx_bytes; 4148c2ecf20Sopenharmony_ci u64 rx_mcasts; 4158c2ecf20Sopenharmony_ci u64 rx_errors; 4168c2ecf20Sopenharmony_ci u64 tx_packets; 4178c2ecf20Sopenharmony_ci u64 tx_bytes; 4188c2ecf20Sopenharmony_ci /* HW STATS */ 4198c2ecf20Sopenharmony_ci u64 rx_buff_miss; 4208c2ecf20Sopenharmony_ci u64 tx_dropped; 4218c2ecf20Sopenharmony_ci u64 irq_errs; 4228c2ecf20Sopenharmony_ci /* transport layer */ 4238c2ecf20Sopenharmony_ci u64 rx_tpcsum; 4248c2ecf20Sopenharmony_ci u64 rx_tpoflow; 4258c2ecf20Sopenharmony_ci u64 rx_tphlen; 4268c2ecf20Sopenharmony_ci /* ip layer */ 4278c2ecf20Sopenharmony_ci u64 rx_ipcsum; 4288c2ecf20Sopenharmony_ci u64 rx_iplen; 4298c2ecf20Sopenharmony_ci u64 rx_iphlen; 4308c2ecf20Sopenharmony_ci /* link layer */ 4318c2ecf20Sopenharmony_ci u64 rx_early; 4328c2ecf20Sopenharmony_ci u64 rx_buffoflow; 4338c2ecf20Sopenharmony_ci u64 rx_lcode; 4348c2ecf20Sopenharmony_ci u64 rx_drbl; 4358c2ecf20Sopenharmony_ci u64 rx_crc; 4368c2ecf20Sopenharmony_ci u64 rx_oflow802; 4378c2ecf20Sopenharmony_ci u64 rx_uflow802; 4388c2ecf20Sopenharmony_ci /* oasis only */ 4398c2ecf20Sopenharmony_ci u64 tx_carrier; 4408c2ecf20Sopenharmony_ci struct u64_stats_sync syncp; 4418c2ecf20Sopenharmony_ci}; 4428c2ecf20Sopenharmony_ci 4438c2ecf20Sopenharmony_cistruct slic_shmem_data { 4448c2ecf20Sopenharmony_ci __le32 isr; 4458c2ecf20Sopenharmony_ci __le32 link; 4468c2ecf20Sopenharmony_ci}; 4478c2ecf20Sopenharmony_ci 4488c2ecf20Sopenharmony_cistruct slic_shmem { 4498c2ecf20Sopenharmony_ci dma_addr_t isr_paddr; 4508c2ecf20Sopenharmony_ci dma_addr_t link_paddr; 4518c2ecf20Sopenharmony_ci struct slic_shmem_data *shmem_data; 4528c2ecf20Sopenharmony_ci}; 4538c2ecf20Sopenharmony_ci 4548c2ecf20Sopenharmony_cistruct slic_rx_info_oasis { 4558c2ecf20Sopenharmony_ci __le32 frame_status; 4568c2ecf20Sopenharmony_ci __le32 frame_status_b; 4578c2ecf20Sopenharmony_ci __le32 time_stamp; 4588c2ecf20Sopenharmony_ci __le32 checksum; 4598c2ecf20Sopenharmony_ci}; 4608c2ecf20Sopenharmony_ci 4618c2ecf20Sopenharmony_cistruct slic_rx_info_mojave { 4628c2ecf20Sopenharmony_ci __le32 frame_status; 4638c2ecf20Sopenharmony_ci __le16 byte_cnt; 4648c2ecf20Sopenharmony_ci __le16 tp_chksum; 4658c2ecf20Sopenharmony_ci __le16 ctx_hash; 4668c2ecf20Sopenharmony_ci __le16 mac_hash; 4678c2ecf20Sopenharmony_ci __le16 buff_lnk; 4688c2ecf20Sopenharmony_ci}; 4698c2ecf20Sopenharmony_ci 4708c2ecf20Sopenharmony_cistruct slic_stat_desc { 4718c2ecf20Sopenharmony_ci __le32 hnd; 4728c2ecf20Sopenharmony_ci __u8 pad[8]; 4738c2ecf20Sopenharmony_ci __le32 status; 4748c2ecf20Sopenharmony_ci __u8 pad2[16]; 4758c2ecf20Sopenharmony_ci}; 4768c2ecf20Sopenharmony_ci 4778c2ecf20Sopenharmony_cistruct slic_stat_queue { 4788c2ecf20Sopenharmony_ci struct slic_stat_desc *descs[SLIC_NUM_STAT_DESC_ARRAYS]; 4798c2ecf20Sopenharmony_ci dma_addr_t paddr[SLIC_NUM_STAT_DESC_ARRAYS]; 4808c2ecf20Sopenharmony_ci unsigned int addr_offset[SLIC_NUM_STAT_DESC_ARRAYS]; 4818c2ecf20Sopenharmony_ci unsigned int active_array; 4828c2ecf20Sopenharmony_ci unsigned int len; 4838c2ecf20Sopenharmony_ci unsigned int done_idx; 4848c2ecf20Sopenharmony_ci size_t mem_size; 4858c2ecf20Sopenharmony_ci}; 4868c2ecf20Sopenharmony_ci 4878c2ecf20Sopenharmony_cistruct slic_tx_desc { 4888c2ecf20Sopenharmony_ci __le32 hnd; 4898c2ecf20Sopenharmony_ci __le32 rsvd; 4908c2ecf20Sopenharmony_ci u8 cmd; 4918c2ecf20Sopenharmony_ci u8 flags; 4928c2ecf20Sopenharmony_ci __le16 rsvd2; 4938c2ecf20Sopenharmony_ci __le32 totlen; 4948c2ecf20Sopenharmony_ci __le32 paddrl; 4958c2ecf20Sopenharmony_ci __le32 paddrh; 4968c2ecf20Sopenharmony_ci __le32 len; 4978c2ecf20Sopenharmony_ci __le32 type; 4988c2ecf20Sopenharmony_ci}; 4998c2ecf20Sopenharmony_ci 5008c2ecf20Sopenharmony_cistruct slic_tx_buffer { 5018c2ecf20Sopenharmony_ci struct sk_buff *skb; 5028c2ecf20Sopenharmony_ci DEFINE_DMA_UNMAP_ADDR(map_addr); 5038c2ecf20Sopenharmony_ci DEFINE_DMA_UNMAP_LEN(map_len); 5048c2ecf20Sopenharmony_ci struct slic_tx_desc *desc; 5058c2ecf20Sopenharmony_ci dma_addr_t desc_paddr; 5068c2ecf20Sopenharmony_ci}; 5078c2ecf20Sopenharmony_ci 5088c2ecf20Sopenharmony_cistruct slic_tx_queue { 5098c2ecf20Sopenharmony_ci struct dma_pool *dma_pool; 5108c2ecf20Sopenharmony_ci struct slic_tx_buffer *txbuffs; 5118c2ecf20Sopenharmony_ci unsigned int len; 5128c2ecf20Sopenharmony_ci unsigned int put_idx; 5138c2ecf20Sopenharmony_ci unsigned int done_idx; 5148c2ecf20Sopenharmony_ci}; 5158c2ecf20Sopenharmony_ci 5168c2ecf20Sopenharmony_cistruct slic_rx_desc { 5178c2ecf20Sopenharmony_ci u8 pad[16]; 5188c2ecf20Sopenharmony_ci __le32 buffer; 5198c2ecf20Sopenharmony_ci __le32 length; 5208c2ecf20Sopenharmony_ci __le32 status; 5218c2ecf20Sopenharmony_ci}; 5228c2ecf20Sopenharmony_ci 5238c2ecf20Sopenharmony_cistruct slic_rx_buffer { 5248c2ecf20Sopenharmony_ci struct sk_buff *skb; 5258c2ecf20Sopenharmony_ci DEFINE_DMA_UNMAP_ADDR(map_addr); 5268c2ecf20Sopenharmony_ci DEFINE_DMA_UNMAP_LEN(map_len); 5278c2ecf20Sopenharmony_ci unsigned int addr_offset; 5288c2ecf20Sopenharmony_ci}; 5298c2ecf20Sopenharmony_ci 5308c2ecf20Sopenharmony_cistruct slic_rx_queue { 5318c2ecf20Sopenharmony_ci struct slic_rx_buffer *rxbuffs; 5328c2ecf20Sopenharmony_ci unsigned int len; 5338c2ecf20Sopenharmony_ci unsigned int done_idx; 5348c2ecf20Sopenharmony_ci unsigned int put_idx; 5358c2ecf20Sopenharmony_ci}; 5368c2ecf20Sopenharmony_ci 5378c2ecf20Sopenharmony_cistruct slic_device { 5388c2ecf20Sopenharmony_ci struct pci_dev *pdev; 5398c2ecf20Sopenharmony_ci struct net_device *netdev; 5408c2ecf20Sopenharmony_ci void __iomem *regs; 5418c2ecf20Sopenharmony_ci /* upper address setting lock */ 5428c2ecf20Sopenharmony_ci spinlock_t upper_lock; 5438c2ecf20Sopenharmony_ci struct slic_shmem shmem; 5448c2ecf20Sopenharmony_ci struct napi_struct napi; 5458c2ecf20Sopenharmony_ci struct slic_rx_queue rxq; 5468c2ecf20Sopenharmony_ci struct slic_tx_queue txq; 5478c2ecf20Sopenharmony_ci struct slic_stat_queue stq; 5488c2ecf20Sopenharmony_ci struct slic_stats stats; 5498c2ecf20Sopenharmony_ci struct slic_upr_list upr_list; 5508c2ecf20Sopenharmony_ci /* link configuration lock */ 5518c2ecf20Sopenharmony_ci spinlock_t link_lock; 5528c2ecf20Sopenharmony_ci bool promisc; 5538c2ecf20Sopenharmony_ci int speed; 5548c2ecf20Sopenharmony_ci unsigned int duplex; 5558c2ecf20Sopenharmony_ci bool is_fiber; 5568c2ecf20Sopenharmony_ci unsigned char model; 5578c2ecf20Sopenharmony_ci}; 5588c2ecf20Sopenharmony_ci 5598c2ecf20Sopenharmony_cistatic inline u32 slic_read(struct slic_device *sdev, unsigned int reg) 5608c2ecf20Sopenharmony_ci{ 5618c2ecf20Sopenharmony_ci return ioread32(sdev->regs + reg); 5628c2ecf20Sopenharmony_ci} 5638c2ecf20Sopenharmony_ci 5648c2ecf20Sopenharmony_cistatic inline void slic_write(struct slic_device *sdev, unsigned int reg, 5658c2ecf20Sopenharmony_ci u32 val) 5668c2ecf20Sopenharmony_ci{ 5678c2ecf20Sopenharmony_ci iowrite32(val, sdev->regs + reg); 5688c2ecf20Sopenharmony_ci} 5698c2ecf20Sopenharmony_ci 5708c2ecf20Sopenharmony_cistatic inline void slic_flush_write(struct slic_device *sdev) 5718c2ecf20Sopenharmony_ci{ 5728c2ecf20Sopenharmony_ci (void)ioread32(sdev->regs + SLIC_REG_HOSTID); 5738c2ecf20Sopenharmony_ci} 5748c2ecf20Sopenharmony_ci 5758c2ecf20Sopenharmony_ci#endif /* _SLIC_H */ 576