18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Broadcom BCM7xxx System Port Ethernet MAC driver 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2014 Broadcom Corporation 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef __BCM_SYSPORT_H 98c2ecf20Sopenharmony_ci#define __BCM_SYSPORT_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/bitmap.h> 128c2ecf20Sopenharmony_ci#include <linux/ethtool.h> 138c2ecf20Sopenharmony_ci#include <linux/if_vlan.h> 148c2ecf20Sopenharmony_ci#include <linux/dim.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci/* Receive/transmit descriptor format */ 178c2ecf20Sopenharmony_ci#define DESC_ADDR_HI_STATUS_LEN 0x00 188c2ecf20Sopenharmony_ci#define DESC_ADDR_HI_SHIFT 0 198c2ecf20Sopenharmony_ci#define DESC_ADDR_HI_MASK 0xff 208c2ecf20Sopenharmony_ci#define DESC_STATUS_SHIFT 8 218c2ecf20Sopenharmony_ci#define DESC_STATUS_MASK 0x3ff 228c2ecf20Sopenharmony_ci#define DESC_LEN_SHIFT 18 238c2ecf20Sopenharmony_ci#define DESC_LEN_MASK 0x7fff 248c2ecf20Sopenharmony_ci#define DESC_ADDR_LO 0x04 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci/* HW supports 40-bit addressing hence the */ 278c2ecf20Sopenharmony_ci#define DESC_SIZE (WORDS_PER_DESC * sizeof(u32)) 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci/* Default RX buffer allocation size */ 308c2ecf20Sopenharmony_ci#define RX_BUF_LENGTH 2048 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci/* Body(1500) + EH_SIZE(14) + VLANTAG(4) + BRCMTAG(4) + FCS(4) = 1526. 338c2ecf20Sopenharmony_ci * 1536 is multiple of 256 bytes 348c2ecf20Sopenharmony_ci */ 358c2ecf20Sopenharmony_ci#define ENET_BRCM_TAG_LEN 4 368c2ecf20Sopenharmony_ci#define ENET_PAD 10 378c2ecf20Sopenharmony_ci#define UMAC_MAX_MTU_SIZE (ETH_DATA_LEN + ETH_HLEN + VLAN_HLEN + \ 388c2ecf20Sopenharmony_ci ENET_BRCM_TAG_LEN + ETH_FCS_LEN + ENET_PAD) 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci/* Transmit status block */ 418c2ecf20Sopenharmony_cistruct bcm_tsb { 428c2ecf20Sopenharmony_ci u32 pcp_dei_vid; 438c2ecf20Sopenharmony_ci#define PCP_DEI_MASK 0xf 448c2ecf20Sopenharmony_ci#define VID_SHIFT 4 458c2ecf20Sopenharmony_ci#define VID_MASK 0xfff 468c2ecf20Sopenharmony_ci u32 l4_ptr_dest_map; 478c2ecf20Sopenharmony_ci#define L4_CSUM_PTR_MASK 0x1ff 488c2ecf20Sopenharmony_ci#define L4_PTR_SHIFT 9 498c2ecf20Sopenharmony_ci#define L4_PTR_MASK 0x1ff 508c2ecf20Sopenharmony_ci#define L4_UDP (1 << 18) 518c2ecf20Sopenharmony_ci#define L4_LENGTH_VALID (1 << 19) 528c2ecf20Sopenharmony_ci#define DEST_MAP_SHIFT 20 538c2ecf20Sopenharmony_ci#define DEST_MAP_MASK 0x1ff 548c2ecf20Sopenharmony_ci}; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci/* Receive status block uses the same 578c2ecf20Sopenharmony_ci * definitions as the DMA descriptor 588c2ecf20Sopenharmony_ci */ 598c2ecf20Sopenharmony_cistruct bcm_rsb { 608c2ecf20Sopenharmony_ci u32 rx_status_len; 618c2ecf20Sopenharmony_ci u32 brcm_egress_tag; 628c2ecf20Sopenharmony_ci}; 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci/* Common Receive/Transmit status bits */ 658c2ecf20Sopenharmony_ci#define DESC_L4_CSUM (1 << 7) 668c2ecf20Sopenharmony_ci#define DESC_SOP (1 << 8) 678c2ecf20Sopenharmony_ci#define DESC_EOP (1 << 9) 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci/* Receive Status bits */ 708c2ecf20Sopenharmony_ci#define RX_STATUS_UCAST 0 718c2ecf20Sopenharmony_ci#define RX_STATUS_BCAST 0x04 728c2ecf20Sopenharmony_ci#define RX_STATUS_MCAST 0x08 738c2ecf20Sopenharmony_ci#define RX_STATUS_L2_MCAST 0x0c 748c2ecf20Sopenharmony_ci#define RX_STATUS_ERR (1 << 4) 758c2ecf20Sopenharmony_ci#define RX_STATUS_OVFLOW (1 << 5) 768c2ecf20Sopenharmony_ci#define RX_STATUS_PARSE_FAIL (1 << 6) 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci/* Transmit Status bits */ 798c2ecf20Sopenharmony_ci#define TX_STATUS_VLAN_NO_ACT 0x00 808c2ecf20Sopenharmony_ci#define TX_STATUS_VLAN_PCP_TSB 0x01 818c2ecf20Sopenharmony_ci#define TX_STATUS_VLAN_QUEUE 0x02 828c2ecf20Sopenharmony_ci#define TX_STATUS_VLAN_VID_TSB 0x03 838c2ecf20Sopenharmony_ci#define TX_STATUS_OWR_CRC (1 << 2) 848c2ecf20Sopenharmony_ci#define TX_STATUS_APP_CRC (1 << 3) 858c2ecf20Sopenharmony_ci#define TX_STATUS_BRCM_TAG_NO_ACT 0 868c2ecf20Sopenharmony_ci#define TX_STATUS_BRCM_TAG_ZERO 0x10 878c2ecf20Sopenharmony_ci#define TX_STATUS_BRCM_TAG_ONE_QUEUE 0x20 888c2ecf20Sopenharmony_ci#define TX_STATUS_BRCM_TAG_ONE_TSB 0x30 898c2ecf20Sopenharmony_ci#define TX_STATUS_SKIP_BYTES (1 << 6) 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci/* Specific register definitions */ 928c2ecf20Sopenharmony_ci#define SYS_PORT_TOPCTRL_OFFSET 0 938c2ecf20Sopenharmony_ci#define REV_CNTL 0x00 948c2ecf20Sopenharmony_ci#define REV_MASK 0xffff 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci#define RX_FLUSH_CNTL 0x04 978c2ecf20Sopenharmony_ci#define RX_FLUSH (1 << 0) 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci#define TX_FLUSH_CNTL 0x08 1008c2ecf20Sopenharmony_ci#define TX_FLUSH (1 << 0) 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci#define MISC_CNTL 0x0c 1038c2ecf20Sopenharmony_ci#define SYS_CLK_SEL (1 << 0) 1048c2ecf20Sopenharmony_ci#define TDMA_EOP_SEL (1 << 1) 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci/* Level-2 Interrupt controller offsets and defines */ 1078c2ecf20Sopenharmony_ci#define SYS_PORT_INTRL2_0_OFFSET 0x200 1088c2ecf20Sopenharmony_ci#define SYS_PORT_INTRL2_1_OFFSET 0x240 1098c2ecf20Sopenharmony_ci#define INTRL2_CPU_STATUS 0x00 1108c2ecf20Sopenharmony_ci#define INTRL2_CPU_SET 0x04 1118c2ecf20Sopenharmony_ci#define INTRL2_CPU_CLEAR 0x08 1128c2ecf20Sopenharmony_ci#define INTRL2_CPU_MASK_STATUS 0x0c 1138c2ecf20Sopenharmony_ci#define INTRL2_CPU_MASK_SET 0x10 1148c2ecf20Sopenharmony_ci#define INTRL2_CPU_MASK_CLEAR 0x14 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci/* Level-2 instance 0 interrupt bits */ 1178c2ecf20Sopenharmony_ci#define INTRL2_0_GISB_ERR (1 << 0) 1188c2ecf20Sopenharmony_ci#define INTRL2_0_RBUF_OVFLOW (1 << 1) 1198c2ecf20Sopenharmony_ci#define INTRL2_0_TBUF_UNDFLOW (1 << 2) 1208c2ecf20Sopenharmony_ci#define INTRL2_0_MPD (1 << 3) 1218c2ecf20Sopenharmony_ci#define INTRL2_0_BRCM_MATCH_TAG (1 << 4) 1228c2ecf20Sopenharmony_ci#define INTRL2_0_RDMA_MBDONE (1 << 5) 1238c2ecf20Sopenharmony_ci#define INTRL2_0_OVER_MAX_THRESH (1 << 6) 1248c2ecf20Sopenharmony_ci#define INTRL2_0_BELOW_HYST_THRESH (1 << 7) 1258c2ecf20Sopenharmony_ci#define INTRL2_0_FREE_LIST_EMPTY (1 << 8) 1268c2ecf20Sopenharmony_ci#define INTRL2_0_TX_RING_FULL (1 << 9) 1278c2ecf20Sopenharmony_ci#define INTRL2_0_DESC_ALLOC_ERR (1 << 10) 1288c2ecf20Sopenharmony_ci#define INTRL2_0_UNEXP_PKTSIZE_ACK (1 << 11) 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci/* SYSTEMPORT Lite groups the TX queues interrupts on instance 0 */ 1318c2ecf20Sopenharmony_ci#define INTRL2_0_TDMA_MBDONE_SHIFT 12 1328c2ecf20Sopenharmony_ci#define INTRL2_0_TDMA_MBDONE_MASK (0xffff << INTRL2_0_TDMA_MBDONE_SHIFT) 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci/* RXCHK offset and defines */ 1358c2ecf20Sopenharmony_ci#define SYS_PORT_RXCHK_OFFSET 0x300 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci#define RXCHK_CONTROL 0x00 1388c2ecf20Sopenharmony_ci#define RXCHK_EN (1 << 0) 1398c2ecf20Sopenharmony_ci#define RXCHK_SKIP_FCS (1 << 1) 1408c2ecf20Sopenharmony_ci#define RXCHK_BAD_CSUM_DIS (1 << 2) 1418c2ecf20Sopenharmony_ci#define RXCHK_BRCM_TAG_EN (1 << 3) 1428c2ecf20Sopenharmony_ci#define RXCHK_BRCM_TAG_MATCH_SHIFT 4 1438c2ecf20Sopenharmony_ci#define RXCHK_BRCM_TAG_MATCH_MASK 0xff 1448c2ecf20Sopenharmony_ci#define RXCHK_PARSE_TNL (1 << 12) 1458c2ecf20Sopenharmony_ci#define RXCHK_VIOL_EN (1 << 13) 1468c2ecf20Sopenharmony_ci#define RXCHK_VIOL_DIS (1 << 14) 1478c2ecf20Sopenharmony_ci#define RXCHK_INCOM_PKT (1 << 15) 1488c2ecf20Sopenharmony_ci#define RXCHK_V6_DUPEXT_EN (1 << 16) 1498c2ecf20Sopenharmony_ci#define RXCHK_V6_DUPEXT_DIS (1 << 17) 1508c2ecf20Sopenharmony_ci#define RXCHK_ETHERTYPE_DIS (1 << 18) 1518c2ecf20Sopenharmony_ci#define RXCHK_L2_HDR_DIS (1 << 19) 1528c2ecf20Sopenharmony_ci#define RXCHK_L3_HDR_DIS (1 << 20) 1538c2ecf20Sopenharmony_ci#define RXCHK_MAC_RX_ERR_DIS (1 << 21) 1548c2ecf20Sopenharmony_ci#define RXCHK_PARSE_AUTH (1 << 22) 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ci#define RXCHK_BRCM_TAG0 0x04 1578c2ecf20Sopenharmony_ci#define RXCHK_BRCM_TAG(i) ((i) * 0x4 + RXCHK_BRCM_TAG0) 1588c2ecf20Sopenharmony_ci#define RXCHK_BRCM_TAG0_MASK 0x24 1598c2ecf20Sopenharmony_ci#define RXCHK_BRCM_TAG_MASK(i) ((i) * 0x4 + RXCHK_BRCM_TAG0_MASK) 1608c2ecf20Sopenharmony_ci#define RXCHK_BRCM_TAG_MATCH_STATUS 0x44 1618c2ecf20Sopenharmony_ci#define RXCHK_ETHERTYPE 0x48 1628c2ecf20Sopenharmony_ci#define RXCHK_BAD_CSUM_CNTR 0x4C 1638c2ecf20Sopenharmony_ci#define RXCHK_OTHER_DISC_CNTR 0x50 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci#define RXCHK_BRCM_TAG_MAX 8 1668c2ecf20Sopenharmony_ci#define RXCHK_BRCM_TAG_CID_SHIFT 16 1678c2ecf20Sopenharmony_ci#define RXCHK_BRCM_TAG_CID_MASK 0xff 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_ci/* TXCHCK offsets and defines */ 1708c2ecf20Sopenharmony_ci#define SYS_PORT_TXCHK_OFFSET 0x380 1718c2ecf20Sopenharmony_ci#define TXCHK_PKT_RDY_THRESH 0x00 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci/* Receive buffer offset and defines */ 1748c2ecf20Sopenharmony_ci#define SYS_PORT_RBUF_OFFSET 0x400 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci#define RBUF_CONTROL 0x00 1778c2ecf20Sopenharmony_ci#define RBUF_RSB_EN (1 << 0) 1788c2ecf20Sopenharmony_ci#define RBUF_4B_ALGN (1 << 1) 1798c2ecf20Sopenharmony_ci#define RBUF_BRCM_TAG_STRIP (1 << 2) 1808c2ecf20Sopenharmony_ci#define RBUF_BAD_PKT_DISC (1 << 3) 1818c2ecf20Sopenharmony_ci#define RBUF_RESUME_THRESH_SHIFT 4 1828c2ecf20Sopenharmony_ci#define RBUF_RESUME_THRESH_MASK 0xff 1838c2ecf20Sopenharmony_ci#define RBUF_OK_TO_SEND_SHIFT 12 1848c2ecf20Sopenharmony_ci#define RBUF_OK_TO_SEND_MASK 0xff 1858c2ecf20Sopenharmony_ci#define RBUF_CRC_REPLACE (1 << 20) 1868c2ecf20Sopenharmony_ci#define RBUF_OK_TO_SEND_MODE (1 << 21) 1878c2ecf20Sopenharmony_ci/* SYSTEMPORT Lite uses two bits here */ 1888c2ecf20Sopenharmony_ci#define RBUF_RSB_SWAP0 (1 << 22) 1898c2ecf20Sopenharmony_ci#define RBUF_RSB_SWAP1 (1 << 23) 1908c2ecf20Sopenharmony_ci#define RBUF_ACPI_EN (1 << 23) 1918c2ecf20Sopenharmony_ci#define RBUF_ACPI_EN_LITE (1 << 24) 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_ci#define RBUF_PKT_RDY_THRESH 0x04 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci#define RBUF_STATUS 0x08 1968c2ecf20Sopenharmony_ci#define RBUF_WOL_MODE (1 << 0) 1978c2ecf20Sopenharmony_ci#define RBUF_MPD (1 << 1) 1988c2ecf20Sopenharmony_ci#define RBUF_ACPI (1 << 2) 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci#define RBUF_OVFL_DISC_CNTR 0x0c 2018c2ecf20Sopenharmony_ci#define RBUF_ERR_PKT_CNTR 0x10 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_ci/* Transmit buffer offset and defines */ 2048c2ecf20Sopenharmony_ci#define SYS_PORT_TBUF_OFFSET 0x600 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ci#define TBUF_CONTROL 0x00 2078c2ecf20Sopenharmony_ci#define TBUF_BP_EN (1 << 0) 2088c2ecf20Sopenharmony_ci#define TBUF_MAX_PKT_THRESH_SHIFT 1 2098c2ecf20Sopenharmony_ci#define TBUF_MAX_PKT_THRESH_MASK 0x1f 2108c2ecf20Sopenharmony_ci#define TBUF_FULL_THRESH_SHIFT 8 2118c2ecf20Sopenharmony_ci#define TBUF_FULL_THRESH_MASK 0x1f 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci/* UniMAC offset and defines */ 2148c2ecf20Sopenharmony_ci#define SYS_PORT_UMAC_OFFSET 0x800 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci#define UMAC_CMD 0x008 2178c2ecf20Sopenharmony_ci#define CMD_TX_EN (1 << 0) 2188c2ecf20Sopenharmony_ci#define CMD_RX_EN (1 << 1) 2198c2ecf20Sopenharmony_ci#define CMD_SPEED_SHIFT 2 2208c2ecf20Sopenharmony_ci#define CMD_SPEED_10 0 2218c2ecf20Sopenharmony_ci#define CMD_SPEED_100 1 2228c2ecf20Sopenharmony_ci#define CMD_SPEED_1000 2 2238c2ecf20Sopenharmony_ci#define CMD_SPEED_2500 3 2248c2ecf20Sopenharmony_ci#define CMD_SPEED_MASK 3 2258c2ecf20Sopenharmony_ci#define CMD_PROMISC (1 << 4) 2268c2ecf20Sopenharmony_ci#define CMD_PAD_EN (1 << 5) 2278c2ecf20Sopenharmony_ci#define CMD_CRC_FWD (1 << 6) 2288c2ecf20Sopenharmony_ci#define CMD_PAUSE_FWD (1 << 7) 2298c2ecf20Sopenharmony_ci#define CMD_RX_PAUSE_IGNORE (1 << 8) 2308c2ecf20Sopenharmony_ci#define CMD_TX_ADDR_INS (1 << 9) 2318c2ecf20Sopenharmony_ci#define CMD_HD_EN (1 << 10) 2328c2ecf20Sopenharmony_ci#define CMD_SW_RESET (1 << 13) 2338c2ecf20Sopenharmony_ci#define CMD_LCL_LOOP_EN (1 << 15) 2348c2ecf20Sopenharmony_ci#define CMD_AUTO_CONFIG (1 << 22) 2358c2ecf20Sopenharmony_ci#define CMD_CNTL_FRM_EN (1 << 23) 2368c2ecf20Sopenharmony_ci#define CMD_NO_LEN_CHK (1 << 24) 2378c2ecf20Sopenharmony_ci#define CMD_RMT_LOOP_EN (1 << 25) 2388c2ecf20Sopenharmony_ci#define CMD_PRBL_EN (1 << 27) 2398c2ecf20Sopenharmony_ci#define CMD_TX_PAUSE_IGNORE (1 << 28) 2408c2ecf20Sopenharmony_ci#define CMD_TX_RX_EN (1 << 29) 2418c2ecf20Sopenharmony_ci#define CMD_RUNT_FILTER_DIS (1 << 30) 2428c2ecf20Sopenharmony_ci 2438c2ecf20Sopenharmony_ci#define UMAC_MAC0 0x00c 2448c2ecf20Sopenharmony_ci#define UMAC_MAC1 0x010 2458c2ecf20Sopenharmony_ci#define UMAC_MAX_FRAME_LEN 0x014 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci#define UMAC_TX_FLUSH 0x334 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_ci#define UMAC_MIB_START 0x400 2508c2ecf20Sopenharmony_ci 2518c2ecf20Sopenharmony_ci/* There is a 0xC gap between the end of RX and beginning of TX stats and then 2528c2ecf20Sopenharmony_ci * between the end of TX stats and the beginning of the RX RUNT 2538c2ecf20Sopenharmony_ci */ 2548c2ecf20Sopenharmony_ci#define UMAC_MIB_STAT_OFFSET 0xc 2558c2ecf20Sopenharmony_ci 2568c2ecf20Sopenharmony_ci#define UMAC_MIB_CTRL 0x580 2578c2ecf20Sopenharmony_ci#define MIB_RX_CNT_RST (1 << 0) 2588c2ecf20Sopenharmony_ci#define MIB_RUNT_CNT_RST (1 << 1) 2598c2ecf20Sopenharmony_ci#define MIB_TX_CNT_RST (1 << 2) 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci/* These offsets are valid for SYSTEMPORT and SYSTEMPORT Lite */ 2628c2ecf20Sopenharmony_ci#define UMAC_MPD_CTRL 0x620 2638c2ecf20Sopenharmony_ci#define MPD_EN (1 << 0) 2648c2ecf20Sopenharmony_ci#define MSEQ_LEN_SHIFT 16 2658c2ecf20Sopenharmony_ci#define MSEQ_LEN_MASK 0xff 2668c2ecf20Sopenharmony_ci#define PSW_EN (1 << 27) 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci#define UMAC_PSW_MS 0x624 2698c2ecf20Sopenharmony_ci#define UMAC_PSW_LS 0x628 2708c2ecf20Sopenharmony_ci#define UMAC_MDF_CTRL 0x650 2718c2ecf20Sopenharmony_ci#define UMAC_MDF_ADDR 0x654 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci/* Only valid on SYSTEMPORT Lite */ 2748c2ecf20Sopenharmony_ci#define SYS_PORT_GIB_OFFSET 0x1000 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_ci#define GIB_CONTROL 0x00 2778c2ecf20Sopenharmony_ci#define GIB_TX_EN (1 << 0) 2788c2ecf20Sopenharmony_ci#define GIB_RX_EN (1 << 1) 2798c2ecf20Sopenharmony_ci#define GIB_TX_FLUSH (1 << 2) 2808c2ecf20Sopenharmony_ci#define GIB_RX_FLUSH (1 << 3) 2818c2ecf20Sopenharmony_ci#define GIB_GTX_CLK_SEL_SHIFT 4 2828c2ecf20Sopenharmony_ci#define GIB_GTX_CLK_EXT_CLK (0 << GIB_GTX_CLK_SEL_SHIFT) 2838c2ecf20Sopenharmony_ci#define GIB_GTX_CLK_125MHZ (1 << GIB_GTX_CLK_SEL_SHIFT) 2848c2ecf20Sopenharmony_ci#define GIB_GTX_CLK_250MHZ (2 << GIB_GTX_CLK_SEL_SHIFT) 2858c2ecf20Sopenharmony_ci#define GIB_FCS_STRIP_SHIFT 6 2868c2ecf20Sopenharmony_ci#define GIB_FCS_STRIP (1 << GIB_FCS_STRIP_SHIFT) 2878c2ecf20Sopenharmony_ci#define GIB_LCL_LOOP_EN (1 << 7) 2888c2ecf20Sopenharmony_ci#define GIB_LCL_LOOP_TXEN (1 << 8) 2898c2ecf20Sopenharmony_ci#define GIB_RMT_LOOP_EN (1 << 9) 2908c2ecf20Sopenharmony_ci#define GIB_RMT_LOOP_RXEN (1 << 10) 2918c2ecf20Sopenharmony_ci#define GIB_RX_PAUSE_EN (1 << 11) 2928c2ecf20Sopenharmony_ci#define GIB_PREAMBLE_LEN_SHIFT 12 2938c2ecf20Sopenharmony_ci#define GIB_PREAMBLE_LEN_MASK 0xf 2948c2ecf20Sopenharmony_ci#define GIB_IPG_LEN_SHIFT 16 2958c2ecf20Sopenharmony_ci#define GIB_IPG_LEN_MASK 0x3f 2968c2ecf20Sopenharmony_ci#define GIB_PAD_EXTENSION_SHIFT 22 2978c2ecf20Sopenharmony_ci#define GIB_PAD_EXTENSION_MASK 0x3f 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_ci#define GIB_MAC1 0x08 3008c2ecf20Sopenharmony_ci#define GIB_MAC0 0x0c 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_ci/* Receive DMA offset and defines */ 3038c2ecf20Sopenharmony_ci#define SYS_PORT_RDMA_OFFSET 0x2000 3048c2ecf20Sopenharmony_ci 3058c2ecf20Sopenharmony_ci#define RDMA_CONTROL 0x1000 3068c2ecf20Sopenharmony_ci#define RDMA_EN (1 << 0) 3078c2ecf20Sopenharmony_ci#define RDMA_RING_CFG (1 << 1) 3088c2ecf20Sopenharmony_ci#define RDMA_DISC_EN (1 << 2) 3098c2ecf20Sopenharmony_ci#define RDMA_BUF_DATA_OFFSET_SHIFT 4 3108c2ecf20Sopenharmony_ci#define RDMA_BUF_DATA_OFFSET_MASK 0x3ff 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_ci#define RDMA_STATUS 0x1004 3138c2ecf20Sopenharmony_ci#define RDMA_DISABLED (1 << 0) 3148c2ecf20Sopenharmony_ci#define RDMA_DESC_RAM_INIT_BUSY (1 << 1) 3158c2ecf20Sopenharmony_ci#define RDMA_BP_STATUS (1 << 2) 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_ci#define RDMA_SCB_BURST_SIZE 0x1008 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_ci#define RDMA_RING_BUF_SIZE 0x100c 3208c2ecf20Sopenharmony_ci#define RDMA_RING_SIZE_SHIFT 16 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_ci#define RDMA_WRITE_PTR_HI 0x1010 3238c2ecf20Sopenharmony_ci#define RDMA_WRITE_PTR_LO 0x1014 3248c2ecf20Sopenharmony_ci#define RDMA_PROD_INDEX 0x1018 3258c2ecf20Sopenharmony_ci#define RDMA_PROD_INDEX_MASK 0xffff 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ci#define RDMA_CONS_INDEX 0x101c 3288c2ecf20Sopenharmony_ci#define RDMA_CONS_INDEX_MASK 0xffff 3298c2ecf20Sopenharmony_ci 3308c2ecf20Sopenharmony_ci#define RDMA_START_ADDR_HI 0x1020 3318c2ecf20Sopenharmony_ci#define RDMA_START_ADDR_LO 0x1024 3328c2ecf20Sopenharmony_ci#define RDMA_END_ADDR_HI 0x1028 3338c2ecf20Sopenharmony_ci#define RDMA_END_ADDR_LO 0x102c 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_ci#define RDMA_MBDONE_INTR 0x1030 3368c2ecf20Sopenharmony_ci#define RDMA_INTR_THRESH_MASK 0x1ff 3378c2ecf20Sopenharmony_ci#define RDMA_TIMEOUT_SHIFT 16 3388c2ecf20Sopenharmony_ci#define RDMA_TIMEOUT_MASK 0xffff 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ci#define RDMA_XON_XOFF_THRESH 0x1034 3418c2ecf20Sopenharmony_ci#define RDMA_XON_XOFF_THRESH_MASK 0xffff 3428c2ecf20Sopenharmony_ci#define RDMA_XOFF_THRESH_SHIFT 16 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_ci#define RDMA_READ_PTR_HI 0x1038 3458c2ecf20Sopenharmony_ci#define RDMA_READ_PTR_LO 0x103c 3468c2ecf20Sopenharmony_ci 3478c2ecf20Sopenharmony_ci#define RDMA_OVERRIDE 0x1040 3488c2ecf20Sopenharmony_ci#define RDMA_LE_MODE (1 << 0) 3498c2ecf20Sopenharmony_ci#define RDMA_REG_MODE (1 << 1) 3508c2ecf20Sopenharmony_ci 3518c2ecf20Sopenharmony_ci#define RDMA_TEST 0x1044 3528c2ecf20Sopenharmony_ci#define RDMA_TP_OUT_SEL (1 << 0) 3538c2ecf20Sopenharmony_ci#define RDMA_MEM_SEL (1 << 1) 3548c2ecf20Sopenharmony_ci 3558c2ecf20Sopenharmony_ci#define RDMA_DEBUG 0x1048 3568c2ecf20Sopenharmony_ci 3578c2ecf20Sopenharmony_ci/* Transmit DMA offset and defines */ 3588c2ecf20Sopenharmony_ci#define TDMA_NUM_RINGS 32 /* rings = queues */ 3598c2ecf20Sopenharmony_ci#define TDMA_PORT_SIZE DESC_SIZE /* two 32-bits words */ 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_ci#define SYS_PORT_TDMA_OFFSET 0x4000 3628c2ecf20Sopenharmony_ci#define TDMA_WRITE_PORT_OFFSET 0x0000 3638c2ecf20Sopenharmony_ci#define TDMA_WRITE_PORT_HI(i) (TDMA_WRITE_PORT_OFFSET + \ 3648c2ecf20Sopenharmony_ci (i) * TDMA_PORT_SIZE) 3658c2ecf20Sopenharmony_ci#define TDMA_WRITE_PORT_LO(i) (TDMA_WRITE_PORT_OFFSET + \ 3668c2ecf20Sopenharmony_ci sizeof(u32) + (i) * TDMA_PORT_SIZE) 3678c2ecf20Sopenharmony_ci 3688c2ecf20Sopenharmony_ci#define TDMA_READ_PORT_OFFSET (TDMA_WRITE_PORT_OFFSET + \ 3698c2ecf20Sopenharmony_ci (TDMA_NUM_RINGS * TDMA_PORT_SIZE)) 3708c2ecf20Sopenharmony_ci#define TDMA_READ_PORT_HI(i) (TDMA_READ_PORT_OFFSET + \ 3718c2ecf20Sopenharmony_ci (i) * TDMA_PORT_SIZE) 3728c2ecf20Sopenharmony_ci#define TDMA_READ_PORT_LO(i) (TDMA_READ_PORT_OFFSET + \ 3738c2ecf20Sopenharmony_ci sizeof(u32) + (i) * TDMA_PORT_SIZE) 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_ci#define TDMA_READ_PORT_CMD_OFFSET (TDMA_READ_PORT_OFFSET + \ 3768c2ecf20Sopenharmony_ci (TDMA_NUM_RINGS * TDMA_PORT_SIZE)) 3778c2ecf20Sopenharmony_ci#define TDMA_READ_PORT_CMD(i) (TDMA_READ_PORT_CMD_OFFSET + \ 3788c2ecf20Sopenharmony_ci (i) * sizeof(u32)) 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_ci#define TDMA_DESC_RING_00_BASE (TDMA_READ_PORT_CMD_OFFSET + \ 3818c2ecf20Sopenharmony_ci (TDMA_NUM_RINGS * sizeof(u32))) 3828c2ecf20Sopenharmony_ci 3838c2ecf20Sopenharmony_ci/* Register offsets and defines relatives to a specific ring number */ 3848c2ecf20Sopenharmony_ci#define RING_HEAD_TAIL_PTR 0x00 3858c2ecf20Sopenharmony_ci#define RING_HEAD_MASK 0x7ff 3868c2ecf20Sopenharmony_ci#define RING_TAIL_SHIFT 11 3878c2ecf20Sopenharmony_ci#define RING_TAIL_MASK 0x7ff 3888c2ecf20Sopenharmony_ci#define RING_FLUSH (1 << 24) 3898c2ecf20Sopenharmony_ci#define RING_EN (1 << 25) 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_ci#define RING_COUNT 0x04 3928c2ecf20Sopenharmony_ci#define RING_COUNT_MASK 0x7ff 3938c2ecf20Sopenharmony_ci#define RING_BUFF_DONE_SHIFT 11 3948c2ecf20Sopenharmony_ci#define RING_BUFF_DONE_MASK 0x7ff 3958c2ecf20Sopenharmony_ci 3968c2ecf20Sopenharmony_ci#define RING_MAX_HYST 0x08 3978c2ecf20Sopenharmony_ci#define RING_MAX_THRESH_MASK 0x7ff 3988c2ecf20Sopenharmony_ci#define RING_HYST_THRESH_SHIFT 11 3998c2ecf20Sopenharmony_ci#define RING_HYST_THRESH_MASK 0x7ff 4008c2ecf20Sopenharmony_ci 4018c2ecf20Sopenharmony_ci#define RING_INTR_CONTROL 0x0c 4028c2ecf20Sopenharmony_ci#define RING_INTR_THRESH_MASK 0x7ff 4038c2ecf20Sopenharmony_ci#define RING_EMPTY_INTR_EN (1 << 15) 4048c2ecf20Sopenharmony_ci#define RING_TIMEOUT_SHIFT 16 4058c2ecf20Sopenharmony_ci#define RING_TIMEOUT_MASK 0xffff 4068c2ecf20Sopenharmony_ci 4078c2ecf20Sopenharmony_ci#define RING_PROD_CONS_INDEX 0x10 4088c2ecf20Sopenharmony_ci#define RING_PROD_INDEX_MASK 0xffff 4098c2ecf20Sopenharmony_ci#define RING_CONS_INDEX_SHIFT 16 4108c2ecf20Sopenharmony_ci#define RING_CONS_INDEX_MASK 0xffff 4118c2ecf20Sopenharmony_ci 4128c2ecf20Sopenharmony_ci#define RING_MAPPING 0x14 4138c2ecf20Sopenharmony_ci#define RING_QID_MASK 0x7 4148c2ecf20Sopenharmony_ci#define RING_PORT_ID_SHIFT 3 4158c2ecf20Sopenharmony_ci#define RING_PORT_ID_MASK 0x7 4168c2ecf20Sopenharmony_ci#define RING_IGNORE_STATUS (1 << 6) 4178c2ecf20Sopenharmony_ci#define RING_FAILOVER_EN (1 << 7) 4188c2ecf20Sopenharmony_ci#define RING_CREDIT_SHIFT 8 4198c2ecf20Sopenharmony_ci#define RING_CREDIT_MASK 0xffff 4208c2ecf20Sopenharmony_ci 4218c2ecf20Sopenharmony_ci#define RING_PCP_DEI_VID 0x18 4228c2ecf20Sopenharmony_ci#define RING_VID_MASK 0x7ff 4238c2ecf20Sopenharmony_ci#define RING_DEI (1 << 12) 4248c2ecf20Sopenharmony_ci#define RING_PCP_SHIFT 13 4258c2ecf20Sopenharmony_ci#define RING_PCP_MASK 0x7 4268c2ecf20Sopenharmony_ci#define RING_PKT_SIZE_ADJ_SHIFT 16 4278c2ecf20Sopenharmony_ci#define RING_PKT_SIZE_ADJ_MASK 0xf 4288c2ecf20Sopenharmony_ci 4298c2ecf20Sopenharmony_ci#define TDMA_DESC_RING_SIZE 28 4308c2ecf20Sopenharmony_ci 4318c2ecf20Sopenharmony_ci/* Defininition for a given TX ring base address */ 4328c2ecf20Sopenharmony_ci#define TDMA_DESC_RING_BASE(i) (TDMA_DESC_RING_00_BASE + \ 4338c2ecf20Sopenharmony_ci ((i) * TDMA_DESC_RING_SIZE)) 4348c2ecf20Sopenharmony_ci 4358c2ecf20Sopenharmony_ci/* Ring indexed register addreses */ 4368c2ecf20Sopenharmony_ci#define TDMA_DESC_RING_HEAD_TAIL_PTR(i) (TDMA_DESC_RING_BASE(i) + \ 4378c2ecf20Sopenharmony_ci RING_HEAD_TAIL_PTR) 4388c2ecf20Sopenharmony_ci#define TDMA_DESC_RING_COUNT(i) (TDMA_DESC_RING_BASE(i) + \ 4398c2ecf20Sopenharmony_ci RING_COUNT) 4408c2ecf20Sopenharmony_ci#define TDMA_DESC_RING_MAX_HYST(i) (TDMA_DESC_RING_BASE(i) + \ 4418c2ecf20Sopenharmony_ci RING_MAX_HYST) 4428c2ecf20Sopenharmony_ci#define TDMA_DESC_RING_INTR_CONTROL(i) (TDMA_DESC_RING_BASE(i) + \ 4438c2ecf20Sopenharmony_ci RING_INTR_CONTROL) 4448c2ecf20Sopenharmony_ci#define TDMA_DESC_RING_PROD_CONS_INDEX(i) \ 4458c2ecf20Sopenharmony_ci (TDMA_DESC_RING_BASE(i) + \ 4468c2ecf20Sopenharmony_ci RING_PROD_CONS_INDEX) 4478c2ecf20Sopenharmony_ci#define TDMA_DESC_RING_MAPPING(i) (TDMA_DESC_RING_BASE(i) + \ 4488c2ecf20Sopenharmony_ci RING_MAPPING) 4498c2ecf20Sopenharmony_ci#define TDMA_DESC_RING_PCP_DEI_VID(i) (TDMA_DESC_RING_BASE(i) + \ 4508c2ecf20Sopenharmony_ci RING_PCP_DEI_VID) 4518c2ecf20Sopenharmony_ci 4528c2ecf20Sopenharmony_ci#define TDMA_CONTROL 0x600 4538c2ecf20Sopenharmony_ci#define TDMA_EN 0 4548c2ecf20Sopenharmony_ci#define TSB_EN 1 4558c2ecf20Sopenharmony_ci/* Uses 2 bits on SYSTEMPORT Lite and shifts everything by 1 bit, we 4568c2ecf20Sopenharmony_ci * keep the SYSTEMPORT layout here and adjust with tdma_control_bit() 4578c2ecf20Sopenharmony_ci */ 4588c2ecf20Sopenharmony_ci#define TSB_SWAP0 2 4598c2ecf20Sopenharmony_ci#define TSB_SWAP1 3 4608c2ecf20Sopenharmony_ci#define ACB_ALGO 3 4618c2ecf20Sopenharmony_ci#define BUF_DATA_OFFSET_SHIFT 4 4628c2ecf20Sopenharmony_ci#define BUF_DATA_OFFSET_MASK 0x3ff 4638c2ecf20Sopenharmony_ci#define VLAN_EN 14 4648c2ecf20Sopenharmony_ci#define SW_BRCM_TAG 15 4658c2ecf20Sopenharmony_ci#define WNC_KPT_SIZE_UPDATE 16 4668c2ecf20Sopenharmony_ci#define SYNC_PKT_SIZE 17 4678c2ecf20Sopenharmony_ci#define ACH_TXDONE_DELAY_SHIFT 18 4688c2ecf20Sopenharmony_ci#define ACH_TXDONE_DELAY_MASK 0xff 4698c2ecf20Sopenharmony_ci 4708c2ecf20Sopenharmony_ci#define TDMA_STATUS 0x604 4718c2ecf20Sopenharmony_ci#define TDMA_DISABLED (1 << 0) 4728c2ecf20Sopenharmony_ci#define TDMA_LL_RAM_INIT_BUSY (1 << 1) 4738c2ecf20Sopenharmony_ci 4748c2ecf20Sopenharmony_ci#define TDMA_SCB_BURST_SIZE 0x608 4758c2ecf20Sopenharmony_ci#define TDMA_OVER_MAX_THRESH_STATUS 0x60c 4768c2ecf20Sopenharmony_ci#define TDMA_OVER_HYST_THRESH_STATUS 0x610 4778c2ecf20Sopenharmony_ci#define TDMA_TPID 0x614 4788c2ecf20Sopenharmony_ci 4798c2ecf20Sopenharmony_ci#define TDMA_FREE_LIST_HEAD_TAIL_PTR 0x618 4808c2ecf20Sopenharmony_ci#define TDMA_FREE_HEAD_MASK 0x7ff 4818c2ecf20Sopenharmony_ci#define TDMA_FREE_TAIL_SHIFT 11 4828c2ecf20Sopenharmony_ci#define TDMA_FREE_TAIL_MASK 0x7ff 4838c2ecf20Sopenharmony_ci 4848c2ecf20Sopenharmony_ci#define TDMA_FREE_LIST_COUNT 0x61c 4858c2ecf20Sopenharmony_ci#define TDMA_FREE_LIST_COUNT_MASK 0x7ff 4868c2ecf20Sopenharmony_ci 4878c2ecf20Sopenharmony_ci#define TDMA_TIER2_ARB_CTRL 0x620 4888c2ecf20Sopenharmony_ci#define TDMA_ARB_MODE_RR 0 4898c2ecf20Sopenharmony_ci#define TDMA_ARB_MODE_WEIGHT_RR 0x1 4908c2ecf20Sopenharmony_ci#define TDMA_ARB_MODE_STRICT 0x2 4918c2ecf20Sopenharmony_ci#define TDMA_ARB_MODE_DEFICIT_RR 0x3 4928c2ecf20Sopenharmony_ci#define TDMA_CREDIT_SHIFT 4 4938c2ecf20Sopenharmony_ci#define TDMA_CREDIT_MASK 0xffff 4948c2ecf20Sopenharmony_ci 4958c2ecf20Sopenharmony_ci#define TDMA_TIER1_ARB_0_CTRL 0x624 4968c2ecf20Sopenharmony_ci#define TDMA_ARB_EN (1 << 0) 4978c2ecf20Sopenharmony_ci 4988c2ecf20Sopenharmony_ci#define TDMA_TIER1_ARB_0_QUEUE_EN 0x628 4998c2ecf20Sopenharmony_ci#define TDMA_TIER1_ARB_1_CTRL 0x62c 5008c2ecf20Sopenharmony_ci#define TDMA_TIER1_ARB_1_QUEUE_EN 0x630 5018c2ecf20Sopenharmony_ci#define TDMA_TIER1_ARB_2_CTRL 0x634 5028c2ecf20Sopenharmony_ci#define TDMA_TIER1_ARB_2_QUEUE_EN 0x638 5038c2ecf20Sopenharmony_ci#define TDMA_TIER1_ARB_3_CTRL 0x63c 5048c2ecf20Sopenharmony_ci#define TDMA_TIER1_ARB_3_QUEUE_EN 0x640 5058c2ecf20Sopenharmony_ci 5068c2ecf20Sopenharmony_ci#define TDMA_SCB_ENDIAN_OVERRIDE 0x644 5078c2ecf20Sopenharmony_ci#define TDMA_LE_MODE (1 << 0) 5088c2ecf20Sopenharmony_ci#define TDMA_REG_MODE (1 << 1) 5098c2ecf20Sopenharmony_ci 5108c2ecf20Sopenharmony_ci#define TDMA_TEST 0x648 5118c2ecf20Sopenharmony_ci#define TDMA_TP_OUT_SEL (1 << 0) 5128c2ecf20Sopenharmony_ci#define TDMA_MEM_TM (1 << 1) 5138c2ecf20Sopenharmony_ci 5148c2ecf20Sopenharmony_ci#define TDMA_DEBUG 0x64c 5158c2ecf20Sopenharmony_ci 5168c2ecf20Sopenharmony_ci/* Number of Receive hardware descriptor words */ 5178c2ecf20Sopenharmony_ci#define SP_NUM_HW_RX_DESC_WORDS 1024 5188c2ecf20Sopenharmony_ci#define SP_LT_NUM_HW_RX_DESC_WORDS 256 5198c2ecf20Sopenharmony_ci 5208c2ecf20Sopenharmony_ci/* Internal linked-list RAM size */ 5218c2ecf20Sopenharmony_ci#define SP_NUM_TX_DESC 1536 5228c2ecf20Sopenharmony_ci#define SP_LT_NUM_TX_DESC 256 5238c2ecf20Sopenharmony_ci 5248c2ecf20Sopenharmony_ci#define WORDS_PER_DESC 2 5258c2ecf20Sopenharmony_ci 5268c2ecf20Sopenharmony_ci/* Rx/Tx common counter group.*/ 5278c2ecf20Sopenharmony_cistruct bcm_sysport_pkt_counters { 5288c2ecf20Sopenharmony_ci u32 cnt_64; /* RO Received/Transmited 64 bytes packet */ 5298c2ecf20Sopenharmony_ci u32 cnt_127; /* RO Rx/Tx 127 bytes packet */ 5308c2ecf20Sopenharmony_ci u32 cnt_255; /* RO Rx/Tx 65-255 bytes packet */ 5318c2ecf20Sopenharmony_ci u32 cnt_511; /* RO Rx/Tx 256-511 bytes packet */ 5328c2ecf20Sopenharmony_ci u32 cnt_1023; /* RO Rx/Tx 512-1023 bytes packet */ 5338c2ecf20Sopenharmony_ci u32 cnt_1518; /* RO Rx/Tx 1024-1518 bytes packet */ 5348c2ecf20Sopenharmony_ci u32 cnt_mgv; /* RO Rx/Tx 1519-1522 good VLAN packet */ 5358c2ecf20Sopenharmony_ci u32 cnt_2047; /* RO Rx/Tx 1522-2047 bytes packet*/ 5368c2ecf20Sopenharmony_ci u32 cnt_4095; /* RO Rx/Tx 2048-4095 bytes packet*/ 5378c2ecf20Sopenharmony_ci u32 cnt_9216; /* RO Rx/Tx 4096-9216 bytes packet*/ 5388c2ecf20Sopenharmony_ci}; 5398c2ecf20Sopenharmony_ci 5408c2ecf20Sopenharmony_ci/* RSV, Receive Status Vector */ 5418c2ecf20Sopenharmony_cistruct bcm_sysport_rx_counters { 5428c2ecf20Sopenharmony_ci struct bcm_sysport_pkt_counters pkt_cnt; 5438c2ecf20Sopenharmony_ci u32 pkt; /* RO (0x428) Received pkt count*/ 5448c2ecf20Sopenharmony_ci u32 bytes; /* RO Received byte count */ 5458c2ecf20Sopenharmony_ci u32 mca; /* RO # of Received multicast pkt */ 5468c2ecf20Sopenharmony_ci u32 bca; /* RO # of Receive broadcast pkt */ 5478c2ecf20Sopenharmony_ci u32 fcs; /* RO # of Received FCS error */ 5488c2ecf20Sopenharmony_ci u32 cf; /* RO # of Received control frame pkt*/ 5498c2ecf20Sopenharmony_ci u32 pf; /* RO # of Received pause frame pkt */ 5508c2ecf20Sopenharmony_ci u32 uo; /* RO # of unknown op code pkt */ 5518c2ecf20Sopenharmony_ci u32 aln; /* RO # of alignment error count */ 5528c2ecf20Sopenharmony_ci u32 flr; /* RO # of frame length out of range count */ 5538c2ecf20Sopenharmony_ci u32 cde; /* RO # of code error pkt */ 5548c2ecf20Sopenharmony_ci u32 fcr; /* RO # of carrier sense error pkt */ 5558c2ecf20Sopenharmony_ci u32 ovr; /* RO # of oversize pkt*/ 5568c2ecf20Sopenharmony_ci u32 jbr; /* RO # of jabber count */ 5578c2ecf20Sopenharmony_ci u32 mtue; /* RO # of MTU error pkt*/ 5588c2ecf20Sopenharmony_ci u32 pok; /* RO # of Received good pkt */ 5598c2ecf20Sopenharmony_ci u32 uc; /* RO # of unicast pkt */ 5608c2ecf20Sopenharmony_ci u32 ppp; /* RO # of PPP pkt */ 5618c2ecf20Sopenharmony_ci u32 rcrc; /* RO (0x470),# of CRC match pkt */ 5628c2ecf20Sopenharmony_ci}; 5638c2ecf20Sopenharmony_ci 5648c2ecf20Sopenharmony_ci/* TSV, Transmit Status Vector */ 5658c2ecf20Sopenharmony_cistruct bcm_sysport_tx_counters { 5668c2ecf20Sopenharmony_ci struct bcm_sysport_pkt_counters pkt_cnt; 5678c2ecf20Sopenharmony_ci u32 pkts; /* RO (0x4a8) Transmited pkt */ 5688c2ecf20Sopenharmony_ci u32 mca; /* RO # of xmited multicast pkt */ 5698c2ecf20Sopenharmony_ci u32 bca; /* RO # of xmited broadcast pkt */ 5708c2ecf20Sopenharmony_ci u32 pf; /* RO # of xmited pause frame count */ 5718c2ecf20Sopenharmony_ci u32 cf; /* RO # of xmited control frame count */ 5728c2ecf20Sopenharmony_ci u32 fcs; /* RO # of xmited FCS error count */ 5738c2ecf20Sopenharmony_ci u32 ovr; /* RO # of xmited oversize pkt */ 5748c2ecf20Sopenharmony_ci u32 drf; /* RO # of xmited deferral pkt */ 5758c2ecf20Sopenharmony_ci u32 edf; /* RO # of xmited Excessive deferral pkt*/ 5768c2ecf20Sopenharmony_ci u32 scl; /* RO # of xmited single collision pkt */ 5778c2ecf20Sopenharmony_ci u32 mcl; /* RO # of xmited multiple collision pkt*/ 5788c2ecf20Sopenharmony_ci u32 lcl; /* RO # of xmited late collision pkt */ 5798c2ecf20Sopenharmony_ci u32 ecl; /* RO # of xmited excessive collision pkt*/ 5808c2ecf20Sopenharmony_ci u32 frg; /* RO # of xmited fragments pkt*/ 5818c2ecf20Sopenharmony_ci u32 ncl; /* RO # of xmited total collision count */ 5828c2ecf20Sopenharmony_ci u32 jbr; /* RO # of xmited jabber count*/ 5838c2ecf20Sopenharmony_ci u32 bytes; /* RO # of xmited byte count */ 5848c2ecf20Sopenharmony_ci u32 pok; /* RO # of xmited good pkt */ 5858c2ecf20Sopenharmony_ci u32 uc; /* RO (0x4f0) # of xmited unicast pkt */ 5868c2ecf20Sopenharmony_ci}; 5878c2ecf20Sopenharmony_ci 5888c2ecf20Sopenharmony_cistruct bcm_sysport_mib { 5898c2ecf20Sopenharmony_ci struct bcm_sysport_rx_counters rx; 5908c2ecf20Sopenharmony_ci struct bcm_sysport_tx_counters tx; 5918c2ecf20Sopenharmony_ci u32 rx_runt_cnt; 5928c2ecf20Sopenharmony_ci u32 rx_runt_fcs; 5938c2ecf20Sopenharmony_ci u32 rx_runt_fcs_align; 5948c2ecf20Sopenharmony_ci u32 rx_runt_bytes; 5958c2ecf20Sopenharmony_ci u32 rxchk_bad_csum; 5968c2ecf20Sopenharmony_ci u32 rxchk_other_pkt_disc; 5978c2ecf20Sopenharmony_ci u32 rbuf_ovflow_cnt; 5988c2ecf20Sopenharmony_ci u32 rbuf_err_cnt; 5998c2ecf20Sopenharmony_ci u32 alloc_rx_buff_failed; 6008c2ecf20Sopenharmony_ci u32 rx_dma_failed; 6018c2ecf20Sopenharmony_ci u32 tx_dma_failed; 6028c2ecf20Sopenharmony_ci u32 tx_realloc_tsb; 6038c2ecf20Sopenharmony_ci u32 tx_realloc_tsb_failed; 6048c2ecf20Sopenharmony_ci}; 6058c2ecf20Sopenharmony_ci 6068c2ecf20Sopenharmony_ci/* HW maintains a large list of counters */ 6078c2ecf20Sopenharmony_cienum bcm_sysport_stat_type { 6088c2ecf20Sopenharmony_ci BCM_SYSPORT_STAT_NETDEV = -1, 6098c2ecf20Sopenharmony_ci BCM_SYSPORT_STAT_NETDEV64, 6108c2ecf20Sopenharmony_ci BCM_SYSPORT_STAT_MIB_RX, 6118c2ecf20Sopenharmony_ci BCM_SYSPORT_STAT_MIB_TX, 6128c2ecf20Sopenharmony_ci BCM_SYSPORT_STAT_RUNT, 6138c2ecf20Sopenharmony_ci BCM_SYSPORT_STAT_RXCHK, 6148c2ecf20Sopenharmony_ci BCM_SYSPORT_STAT_RBUF, 6158c2ecf20Sopenharmony_ci BCM_SYSPORT_STAT_SOFT, 6168c2ecf20Sopenharmony_ci}; 6178c2ecf20Sopenharmony_ci 6188c2ecf20Sopenharmony_ci/* Macros to help define ethtool statistics */ 6198c2ecf20Sopenharmony_ci#define STAT_NETDEV(m) { \ 6208c2ecf20Sopenharmony_ci .stat_string = __stringify(m), \ 6218c2ecf20Sopenharmony_ci .stat_sizeof = sizeof(((struct net_device_stats *)0)->m), \ 6228c2ecf20Sopenharmony_ci .stat_offset = offsetof(struct net_device_stats, m), \ 6238c2ecf20Sopenharmony_ci .type = BCM_SYSPORT_STAT_NETDEV, \ 6248c2ecf20Sopenharmony_ci} 6258c2ecf20Sopenharmony_ci 6268c2ecf20Sopenharmony_ci#define STAT_NETDEV64(m) { \ 6278c2ecf20Sopenharmony_ci .stat_string = __stringify(m), \ 6288c2ecf20Sopenharmony_ci .stat_sizeof = sizeof(((struct bcm_sysport_stats64 *)0)->m), \ 6298c2ecf20Sopenharmony_ci .stat_offset = offsetof(struct bcm_sysport_stats64, m), \ 6308c2ecf20Sopenharmony_ci .type = BCM_SYSPORT_STAT_NETDEV64, \ 6318c2ecf20Sopenharmony_ci} 6328c2ecf20Sopenharmony_ci 6338c2ecf20Sopenharmony_ci#define STAT_MIB(str, m, _type) { \ 6348c2ecf20Sopenharmony_ci .stat_string = str, \ 6358c2ecf20Sopenharmony_ci .stat_sizeof = sizeof(((struct bcm_sysport_priv *)0)->m), \ 6368c2ecf20Sopenharmony_ci .stat_offset = offsetof(struct bcm_sysport_priv, m), \ 6378c2ecf20Sopenharmony_ci .type = _type, \ 6388c2ecf20Sopenharmony_ci} 6398c2ecf20Sopenharmony_ci 6408c2ecf20Sopenharmony_ci#define STAT_MIB_RX(str, m) STAT_MIB(str, m, BCM_SYSPORT_STAT_MIB_RX) 6418c2ecf20Sopenharmony_ci#define STAT_MIB_TX(str, m) STAT_MIB(str, m, BCM_SYSPORT_STAT_MIB_TX) 6428c2ecf20Sopenharmony_ci#define STAT_RUNT(str, m) STAT_MIB(str, m, BCM_SYSPORT_STAT_RUNT) 6438c2ecf20Sopenharmony_ci#define STAT_MIB_SOFT(str, m) STAT_MIB(str, m, BCM_SYSPORT_STAT_SOFT) 6448c2ecf20Sopenharmony_ci 6458c2ecf20Sopenharmony_ci#define STAT_RXCHK(str, m, ofs) { \ 6468c2ecf20Sopenharmony_ci .stat_string = str, \ 6478c2ecf20Sopenharmony_ci .stat_sizeof = sizeof(((struct bcm_sysport_priv *)0)->m), \ 6488c2ecf20Sopenharmony_ci .stat_offset = offsetof(struct bcm_sysport_priv, m), \ 6498c2ecf20Sopenharmony_ci .type = BCM_SYSPORT_STAT_RXCHK, \ 6508c2ecf20Sopenharmony_ci .reg_offset = ofs, \ 6518c2ecf20Sopenharmony_ci} 6528c2ecf20Sopenharmony_ci 6538c2ecf20Sopenharmony_ci#define STAT_RBUF(str, m, ofs) { \ 6548c2ecf20Sopenharmony_ci .stat_string = str, \ 6558c2ecf20Sopenharmony_ci .stat_sizeof = sizeof(((struct bcm_sysport_priv *)0)->m), \ 6568c2ecf20Sopenharmony_ci .stat_offset = offsetof(struct bcm_sysport_priv, m), \ 6578c2ecf20Sopenharmony_ci .type = BCM_SYSPORT_STAT_RBUF, \ 6588c2ecf20Sopenharmony_ci .reg_offset = ofs, \ 6598c2ecf20Sopenharmony_ci} 6608c2ecf20Sopenharmony_ci 6618c2ecf20Sopenharmony_ci/* TX bytes and packets */ 6628c2ecf20Sopenharmony_ci#define NUM_SYSPORT_TXQ_STAT 2 6638c2ecf20Sopenharmony_ci 6648c2ecf20Sopenharmony_cistruct bcm_sysport_stats { 6658c2ecf20Sopenharmony_ci char stat_string[ETH_GSTRING_LEN]; 6668c2ecf20Sopenharmony_ci int stat_sizeof; 6678c2ecf20Sopenharmony_ci int stat_offset; 6688c2ecf20Sopenharmony_ci enum bcm_sysport_stat_type type; 6698c2ecf20Sopenharmony_ci /* reg offset from UMAC base for misc counters */ 6708c2ecf20Sopenharmony_ci u16 reg_offset; 6718c2ecf20Sopenharmony_ci}; 6728c2ecf20Sopenharmony_ci 6738c2ecf20Sopenharmony_cistruct bcm_sysport_stats64 { 6748c2ecf20Sopenharmony_ci /* 64bit stats on 32bit/64bit Machine */ 6758c2ecf20Sopenharmony_ci u64 rx_packets; 6768c2ecf20Sopenharmony_ci u64 rx_bytes; 6778c2ecf20Sopenharmony_ci u64 tx_packets; 6788c2ecf20Sopenharmony_ci u64 tx_bytes; 6798c2ecf20Sopenharmony_ci}; 6808c2ecf20Sopenharmony_ci 6818c2ecf20Sopenharmony_ci/* Software house keeping helper structure */ 6828c2ecf20Sopenharmony_cistruct bcm_sysport_cb { 6838c2ecf20Sopenharmony_ci struct sk_buff *skb; /* SKB for RX packets */ 6848c2ecf20Sopenharmony_ci void __iomem *bd_addr; /* Buffer descriptor PHYS addr */ 6858c2ecf20Sopenharmony_ci 6868c2ecf20Sopenharmony_ci DEFINE_DMA_UNMAP_ADDR(dma_addr); 6878c2ecf20Sopenharmony_ci DEFINE_DMA_UNMAP_LEN(dma_len); 6888c2ecf20Sopenharmony_ci}; 6898c2ecf20Sopenharmony_ci 6908c2ecf20Sopenharmony_cienum bcm_sysport_type { 6918c2ecf20Sopenharmony_ci SYSTEMPORT = 0, 6928c2ecf20Sopenharmony_ci SYSTEMPORT_LITE, 6938c2ecf20Sopenharmony_ci}; 6948c2ecf20Sopenharmony_ci 6958c2ecf20Sopenharmony_cistruct bcm_sysport_hw_params { 6968c2ecf20Sopenharmony_ci bool is_lite; 6978c2ecf20Sopenharmony_ci unsigned int num_rx_desc_words; 6988c2ecf20Sopenharmony_ci}; 6998c2ecf20Sopenharmony_ci 7008c2ecf20Sopenharmony_cistruct bcm_sysport_net_dim { 7018c2ecf20Sopenharmony_ci u16 use_dim; 7028c2ecf20Sopenharmony_ci u16 event_ctr; 7038c2ecf20Sopenharmony_ci unsigned long packets; 7048c2ecf20Sopenharmony_ci unsigned long bytes; 7058c2ecf20Sopenharmony_ci struct dim dim; 7068c2ecf20Sopenharmony_ci}; 7078c2ecf20Sopenharmony_ci 7088c2ecf20Sopenharmony_ci/* Software view of the TX ring */ 7098c2ecf20Sopenharmony_cistruct bcm_sysport_tx_ring { 7108c2ecf20Sopenharmony_ci spinlock_t lock; /* Ring lock for tx reclaim/xmit */ 7118c2ecf20Sopenharmony_ci struct napi_struct napi; /* NAPI per tx queue */ 7128c2ecf20Sopenharmony_ci unsigned int index; /* Ring index */ 7138c2ecf20Sopenharmony_ci unsigned int size; /* Ring current size */ 7148c2ecf20Sopenharmony_ci unsigned int alloc_size; /* Ring one-time allocated size */ 7158c2ecf20Sopenharmony_ci unsigned int desc_count; /* Number of descriptors */ 7168c2ecf20Sopenharmony_ci unsigned int curr_desc; /* Current descriptor */ 7178c2ecf20Sopenharmony_ci unsigned int c_index; /* Last consumer index */ 7188c2ecf20Sopenharmony_ci unsigned int clean_index; /* Current clean index */ 7198c2ecf20Sopenharmony_ci struct bcm_sysport_cb *cbs; /* Transmit control blocks */ 7208c2ecf20Sopenharmony_ci struct bcm_sysport_priv *priv; /* private context backpointer */ 7218c2ecf20Sopenharmony_ci unsigned long packets; /* packets statistics */ 7228c2ecf20Sopenharmony_ci unsigned long bytes; /* bytes statistics */ 7238c2ecf20Sopenharmony_ci unsigned int switch_queue; /* switch port queue number */ 7248c2ecf20Sopenharmony_ci unsigned int switch_port; /* switch port queue number */ 7258c2ecf20Sopenharmony_ci bool inspect; /* inspect switch port and queue */ 7268c2ecf20Sopenharmony_ci}; 7278c2ecf20Sopenharmony_ci 7288c2ecf20Sopenharmony_ci/* Driver private structure */ 7298c2ecf20Sopenharmony_cistruct bcm_sysport_priv { 7308c2ecf20Sopenharmony_ci void __iomem *base; 7318c2ecf20Sopenharmony_ci u32 irq0_stat; 7328c2ecf20Sopenharmony_ci u32 irq0_mask; 7338c2ecf20Sopenharmony_ci u32 irq1_stat; 7348c2ecf20Sopenharmony_ci u32 irq1_mask; 7358c2ecf20Sopenharmony_ci bool is_lite; 7368c2ecf20Sopenharmony_ci unsigned int num_rx_desc_words; 7378c2ecf20Sopenharmony_ci struct napi_struct napi ____cacheline_aligned; 7388c2ecf20Sopenharmony_ci struct net_device *netdev; 7398c2ecf20Sopenharmony_ci struct platform_device *pdev; 7408c2ecf20Sopenharmony_ci int irq0; 7418c2ecf20Sopenharmony_ci int irq1; 7428c2ecf20Sopenharmony_ci int wol_irq; 7438c2ecf20Sopenharmony_ci 7448c2ecf20Sopenharmony_ci /* Transmit rings */ 7458c2ecf20Sopenharmony_ci spinlock_t desc_lock; 7468c2ecf20Sopenharmony_ci struct bcm_sysport_tx_ring *tx_rings; 7478c2ecf20Sopenharmony_ci 7488c2ecf20Sopenharmony_ci /* Receive queue */ 7498c2ecf20Sopenharmony_ci void __iomem *rx_bds; 7508c2ecf20Sopenharmony_ci struct bcm_sysport_cb *rx_cbs; 7518c2ecf20Sopenharmony_ci unsigned int num_rx_bds; 7528c2ecf20Sopenharmony_ci unsigned int rx_read_ptr; 7538c2ecf20Sopenharmony_ci unsigned int rx_c_index; 7548c2ecf20Sopenharmony_ci 7558c2ecf20Sopenharmony_ci struct bcm_sysport_net_dim dim; 7568c2ecf20Sopenharmony_ci u32 rx_max_coalesced_frames; 7578c2ecf20Sopenharmony_ci u32 rx_coalesce_usecs; 7588c2ecf20Sopenharmony_ci 7598c2ecf20Sopenharmony_ci /* PHY device */ 7608c2ecf20Sopenharmony_ci struct device_node *phy_dn; 7618c2ecf20Sopenharmony_ci phy_interface_t phy_interface; 7628c2ecf20Sopenharmony_ci int old_pause; 7638c2ecf20Sopenharmony_ci int old_link; 7648c2ecf20Sopenharmony_ci int old_duplex; 7658c2ecf20Sopenharmony_ci 7668c2ecf20Sopenharmony_ci /* Misc fields */ 7678c2ecf20Sopenharmony_ci unsigned int rx_chk_en:1; 7688c2ecf20Sopenharmony_ci unsigned int tsb_en:1; 7698c2ecf20Sopenharmony_ci unsigned int crc_fwd:1; 7708c2ecf20Sopenharmony_ci u16 rev; 7718c2ecf20Sopenharmony_ci u32 wolopts; 7728c2ecf20Sopenharmony_ci u8 sopass[SOPASS_MAX]; 7738c2ecf20Sopenharmony_ci unsigned int wol_irq_disabled:1; 7748c2ecf20Sopenharmony_ci struct clk *clk; 7758c2ecf20Sopenharmony_ci struct clk *wol_clk; 7768c2ecf20Sopenharmony_ci 7778c2ecf20Sopenharmony_ci /* MIB related fields */ 7788c2ecf20Sopenharmony_ci struct bcm_sysport_mib mib; 7798c2ecf20Sopenharmony_ci 7808c2ecf20Sopenharmony_ci /* Ethtool */ 7818c2ecf20Sopenharmony_ci u32 msg_enable; 7828c2ecf20Sopenharmony_ci DECLARE_BITMAP(filters, RXCHK_BRCM_TAG_MAX); 7838c2ecf20Sopenharmony_ci u32 filters_loc[RXCHK_BRCM_TAG_MAX]; 7848c2ecf20Sopenharmony_ci 7858c2ecf20Sopenharmony_ci struct bcm_sysport_stats64 stats64; 7868c2ecf20Sopenharmony_ci 7878c2ecf20Sopenharmony_ci /* For atomic update generic 64bit value on 32bit Machine */ 7888c2ecf20Sopenharmony_ci struct u64_stats_sync syncp; 7898c2ecf20Sopenharmony_ci 7908c2ecf20Sopenharmony_ci /* map information between switch port queues and local queues */ 7918c2ecf20Sopenharmony_ci struct notifier_block dsa_notifier; 7928c2ecf20Sopenharmony_ci unsigned int per_port_num_tx_queues; 7938c2ecf20Sopenharmony_ci struct bcm_sysport_tx_ring *ring_map[DSA_MAX_PORTS * 8]; 7948c2ecf20Sopenharmony_ci 7958c2ecf20Sopenharmony_ci}; 7968c2ecf20Sopenharmony_ci#endif /* __BCM_SYSPORT_H */ 797