1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 280105befSFlorian Fainelli /* 380105befSFlorian Fainelli * Broadcom BCM7xxx System Port Ethernet MAC driver 480105befSFlorian Fainelli * 580105befSFlorian Fainelli * Copyright (C) 2014 Broadcom Corporation 680105befSFlorian Fainelli */ 780105befSFlorian Fainelli 880105befSFlorian Fainelli #ifndef __BCM_SYSPORT_H 980105befSFlorian Fainelli #define __BCM_SYSPORT_H 1080105befSFlorian Fainelli 11bb9051a2SFlorian Fainelli #include <linux/bitmap.h> 128dfb8d2cSFlorian Fainelli #include <linux/ethtool.h> 1380105befSFlorian Fainelli #include <linux/if_vlan.h> 144f75da36STal Gilboa #include <linux/dim.h> 1580105befSFlorian Fainelli 1628e303daSRafał Miłecki #include "unimac.h" 1728e303daSRafał Miłecki 1880105befSFlorian Fainelli /* Receive/transmit descriptor format */ 1980105befSFlorian Fainelli #define DESC_ADDR_HI_STATUS_LEN 0x00 2080105befSFlorian Fainelli #define DESC_ADDR_HI_SHIFT 0 2180105befSFlorian Fainelli #define DESC_ADDR_HI_MASK 0xff 2280105befSFlorian Fainelli #define DESC_STATUS_SHIFT 8 2380105befSFlorian Fainelli #define DESC_STATUS_MASK 0x3ff 2480105befSFlorian Fainelli #define DESC_LEN_SHIFT 18 2580105befSFlorian Fainelli #define DESC_LEN_MASK 0x7fff 2680105befSFlorian Fainelli #define DESC_ADDR_LO 0x04 2780105befSFlorian Fainelli 2880105befSFlorian Fainelli /* HW supports 40-bit addressing hence the */ 2980105befSFlorian Fainelli #define DESC_SIZE (WORDS_PER_DESC * sizeof(u32)) 3080105befSFlorian Fainelli 3180105befSFlorian Fainelli /* Default RX buffer allocation size */ 3280105befSFlorian Fainelli #define RX_BUF_LENGTH 2048 3380105befSFlorian Fainelli 34dab531b4SFlorian Fainelli /* Body(1500) + EH_SIZE(14) + VLANTAG(4) + BRCMTAG(4) + FCS(4) = 1526. 3580105befSFlorian Fainelli * 1536 is multiple of 256 bytes 3680105befSFlorian Fainelli */ 37dab531b4SFlorian Fainelli #define ENET_BRCM_TAG_LEN 4 38dab531b4SFlorian Fainelli #define ENET_PAD 10 3980105befSFlorian Fainelli #define UMAC_MAX_MTU_SIZE (ETH_DATA_LEN + ETH_HLEN + VLAN_HLEN + \ 4080105befSFlorian Fainelli ENET_BRCM_TAG_LEN + ETH_FCS_LEN + ENET_PAD) 4180105befSFlorian Fainelli 4280105befSFlorian Fainelli /* Transmit status block */ 433afc557dSPaul Gortmaker struct bcm_tsb { 4480105befSFlorian Fainelli u32 pcp_dei_vid; 4580105befSFlorian Fainelli #define PCP_DEI_MASK 0xf 4680105befSFlorian Fainelli #define VID_SHIFT 4 4780105befSFlorian Fainelli #define VID_MASK 0xfff 4880105befSFlorian Fainelli u32 l4_ptr_dest_map; 4980105befSFlorian Fainelli #define L4_CSUM_PTR_MASK 0x1ff 5080105befSFlorian Fainelli #define L4_PTR_SHIFT 9 5180105befSFlorian Fainelli #define L4_PTR_MASK 0x1ff 5280105befSFlorian Fainelli #define L4_UDP (1 << 18) 5380105befSFlorian Fainelli #define L4_LENGTH_VALID (1 << 19) 5480105befSFlorian Fainelli #define DEST_MAP_SHIFT 20 5580105befSFlorian Fainelli #define DEST_MAP_MASK 0x1ff 5680105befSFlorian Fainelli }; 5780105befSFlorian Fainelli 5880105befSFlorian Fainelli /* Receive status block uses the same 5980105befSFlorian Fainelli * definitions as the DMA descriptor 6080105befSFlorian Fainelli */ 613afc557dSPaul Gortmaker struct bcm_rsb { 6280105befSFlorian Fainelli u32 rx_status_len; 6380105befSFlorian Fainelli u32 brcm_egress_tag; 6480105befSFlorian Fainelli }; 6580105befSFlorian Fainelli 6680105befSFlorian Fainelli /* Common Receive/Transmit status bits */ 6780105befSFlorian Fainelli #define DESC_L4_CSUM (1 << 7) 6880105befSFlorian Fainelli #define DESC_SOP (1 << 8) 6980105befSFlorian Fainelli #define DESC_EOP (1 << 9) 7080105befSFlorian Fainelli 7180105befSFlorian Fainelli /* Receive Status bits */ 7280105befSFlorian Fainelli #define RX_STATUS_UCAST 0 7380105befSFlorian Fainelli #define RX_STATUS_BCAST 0x04 7480105befSFlorian Fainelli #define RX_STATUS_MCAST 0x08 7580105befSFlorian Fainelli #define RX_STATUS_L2_MCAST 0x0c 7680105befSFlorian Fainelli #define RX_STATUS_ERR (1 << 4) 7780105befSFlorian Fainelli #define RX_STATUS_OVFLOW (1 << 5) 7880105befSFlorian Fainelli #define RX_STATUS_PARSE_FAIL (1 << 6) 7980105befSFlorian Fainelli 8080105befSFlorian Fainelli /* Transmit Status bits */ 8180105befSFlorian Fainelli #define TX_STATUS_VLAN_NO_ACT 0x00 8280105befSFlorian Fainelli #define TX_STATUS_VLAN_PCP_TSB 0x01 8380105befSFlorian Fainelli #define TX_STATUS_VLAN_QUEUE 0x02 8480105befSFlorian Fainelli #define TX_STATUS_VLAN_VID_TSB 0x03 8580105befSFlorian Fainelli #define TX_STATUS_OWR_CRC (1 << 2) 8680105befSFlorian Fainelli #define TX_STATUS_APP_CRC (1 << 3) 8780105befSFlorian Fainelli #define TX_STATUS_BRCM_TAG_NO_ACT 0 8880105befSFlorian Fainelli #define TX_STATUS_BRCM_TAG_ZERO 0x10 8980105befSFlorian Fainelli #define TX_STATUS_BRCM_TAG_ONE_QUEUE 0x20 9080105befSFlorian Fainelli #define TX_STATUS_BRCM_TAG_ONE_TSB 0x30 9180105befSFlorian Fainelli #define TX_STATUS_SKIP_BYTES (1 << 6) 9280105befSFlorian Fainelli 9380105befSFlorian Fainelli /* Specific register definitions */ 9480105befSFlorian Fainelli #define SYS_PORT_TOPCTRL_OFFSET 0 9580105befSFlorian Fainelli #define REV_CNTL 0x00 9680105befSFlorian Fainelli #define REV_MASK 0xffff 9780105befSFlorian Fainelli 9880105befSFlorian Fainelli #define RX_FLUSH_CNTL 0x04 9980105befSFlorian Fainelli #define RX_FLUSH (1 << 0) 10080105befSFlorian Fainelli 10180105befSFlorian Fainelli #define TX_FLUSH_CNTL 0x08 10280105befSFlorian Fainelli #define TX_FLUSH (1 << 0) 10380105befSFlorian Fainelli 10480105befSFlorian Fainelli #define MISC_CNTL 0x0c 10580105befSFlorian Fainelli #define SYS_CLK_SEL (1 << 0) 10680105befSFlorian Fainelli #define TDMA_EOP_SEL (1 << 1) 10780105befSFlorian Fainelli 10880105befSFlorian Fainelli /* Level-2 Interrupt controller offsets and defines */ 10980105befSFlorian Fainelli #define SYS_PORT_INTRL2_0_OFFSET 0x200 11080105befSFlorian Fainelli #define SYS_PORT_INTRL2_1_OFFSET 0x240 11180105befSFlorian Fainelli #define INTRL2_CPU_STATUS 0x00 11280105befSFlorian Fainelli #define INTRL2_CPU_SET 0x04 11380105befSFlorian Fainelli #define INTRL2_CPU_CLEAR 0x08 11480105befSFlorian Fainelli #define INTRL2_CPU_MASK_STATUS 0x0c 11580105befSFlorian Fainelli #define INTRL2_CPU_MASK_SET 0x10 11680105befSFlorian Fainelli #define INTRL2_CPU_MASK_CLEAR 0x14 11780105befSFlorian Fainelli 11880105befSFlorian Fainelli /* Level-2 instance 0 interrupt bits */ 11980105befSFlorian Fainelli #define INTRL2_0_GISB_ERR (1 << 0) 12080105befSFlorian Fainelli #define INTRL2_0_RBUF_OVFLOW (1 << 1) 12180105befSFlorian Fainelli #define INTRL2_0_TBUF_UNDFLOW (1 << 2) 12280105befSFlorian Fainelli #define INTRL2_0_MPD (1 << 3) 12380105befSFlorian Fainelli #define INTRL2_0_BRCM_MATCH_TAG (1 << 4) 12480105befSFlorian Fainelli #define INTRL2_0_RDMA_MBDONE (1 << 5) 12580105befSFlorian Fainelli #define INTRL2_0_OVER_MAX_THRESH (1 << 6) 12680105befSFlorian Fainelli #define INTRL2_0_BELOW_HYST_THRESH (1 << 7) 12780105befSFlorian Fainelli #define INTRL2_0_FREE_LIST_EMPTY (1 << 8) 12880105befSFlorian Fainelli #define INTRL2_0_TX_RING_FULL (1 << 9) 12980105befSFlorian Fainelli #define INTRL2_0_DESC_ALLOC_ERR (1 << 10) 13080105befSFlorian Fainelli #define INTRL2_0_UNEXP_PKTSIZE_ACK (1 << 11) 13180105befSFlorian Fainelli 13244a4524cSFlorian Fainelli /* SYSTEMPORT Lite groups the TX queues interrupts on instance 0 */ 13344a4524cSFlorian Fainelli #define INTRL2_0_TDMA_MBDONE_SHIFT 12 13444a4524cSFlorian Fainelli #define INTRL2_0_TDMA_MBDONE_MASK (0xffff << INTRL2_0_TDMA_MBDONE_SHIFT) 13544a4524cSFlorian Fainelli 13680105befSFlorian Fainelli /* RXCHK offset and defines */ 13780105befSFlorian Fainelli #define SYS_PORT_RXCHK_OFFSET 0x300 13880105befSFlorian Fainelli 13980105befSFlorian Fainelli #define RXCHK_CONTROL 0x00 14080105befSFlorian Fainelli #define RXCHK_EN (1 << 0) 14180105befSFlorian Fainelli #define RXCHK_SKIP_FCS (1 << 1) 14280105befSFlorian Fainelli #define RXCHK_BAD_CSUM_DIS (1 << 2) 14380105befSFlorian Fainelli #define RXCHK_BRCM_TAG_EN (1 << 3) 14480105befSFlorian Fainelli #define RXCHK_BRCM_TAG_MATCH_SHIFT 4 14580105befSFlorian Fainelli #define RXCHK_BRCM_TAG_MATCH_MASK 0xff 14680105befSFlorian Fainelli #define RXCHK_PARSE_TNL (1 << 12) 14780105befSFlorian Fainelli #define RXCHK_VIOL_EN (1 << 13) 14880105befSFlorian Fainelli #define RXCHK_VIOL_DIS (1 << 14) 14980105befSFlorian Fainelli #define RXCHK_INCOM_PKT (1 << 15) 15080105befSFlorian Fainelli #define RXCHK_V6_DUPEXT_EN (1 << 16) 15180105befSFlorian Fainelli #define RXCHK_V6_DUPEXT_DIS (1 << 17) 15280105befSFlorian Fainelli #define RXCHK_ETHERTYPE_DIS (1 << 18) 15380105befSFlorian Fainelli #define RXCHK_L2_HDR_DIS (1 << 19) 15480105befSFlorian Fainelli #define RXCHK_L3_HDR_DIS (1 << 20) 15580105befSFlorian Fainelli #define RXCHK_MAC_RX_ERR_DIS (1 << 21) 15680105befSFlorian Fainelli #define RXCHK_PARSE_AUTH (1 << 22) 15780105befSFlorian Fainelli 15880105befSFlorian Fainelli #define RXCHK_BRCM_TAG0 0x04 159bb9051a2SFlorian Fainelli #define RXCHK_BRCM_TAG(i) ((i) * 0x4 + RXCHK_BRCM_TAG0) 16080105befSFlorian Fainelli #define RXCHK_BRCM_TAG0_MASK 0x24 161bb9051a2SFlorian Fainelli #define RXCHK_BRCM_TAG_MASK(i) ((i) * 0x4 + RXCHK_BRCM_TAG0_MASK) 16280105befSFlorian Fainelli #define RXCHK_BRCM_TAG_MATCH_STATUS 0x44 16380105befSFlorian Fainelli #define RXCHK_ETHERTYPE 0x48 16480105befSFlorian Fainelli #define RXCHK_BAD_CSUM_CNTR 0x4C 16580105befSFlorian Fainelli #define RXCHK_OTHER_DISC_CNTR 0x50 16680105befSFlorian Fainelli 167bb9051a2SFlorian Fainelli #define RXCHK_BRCM_TAG_MAX 8 168bb9051a2SFlorian Fainelli #define RXCHK_BRCM_TAG_CID_SHIFT 16 169bb9051a2SFlorian Fainelli #define RXCHK_BRCM_TAG_CID_MASK 0xff 170bb9051a2SFlorian Fainelli 17180105befSFlorian Fainelli /* TXCHCK offsets and defines */ 17280105befSFlorian Fainelli #define SYS_PORT_TXCHK_OFFSET 0x380 17380105befSFlorian Fainelli #define TXCHK_PKT_RDY_THRESH 0x00 17480105befSFlorian Fainelli 17580105befSFlorian Fainelli /* Receive buffer offset and defines */ 17680105befSFlorian Fainelli #define SYS_PORT_RBUF_OFFSET 0x400 17780105befSFlorian Fainelli 17880105befSFlorian Fainelli #define RBUF_CONTROL 0x00 17980105befSFlorian Fainelli #define RBUF_RSB_EN (1 << 0) 18080105befSFlorian Fainelli #define RBUF_4B_ALGN (1 << 1) 18180105befSFlorian Fainelli #define RBUF_BRCM_TAG_STRIP (1 << 2) 18280105befSFlorian Fainelli #define RBUF_BAD_PKT_DISC (1 << 3) 18380105befSFlorian Fainelli #define RBUF_RESUME_THRESH_SHIFT 4 18480105befSFlorian Fainelli #define RBUF_RESUME_THRESH_MASK 0xff 18580105befSFlorian Fainelli #define RBUF_OK_TO_SEND_SHIFT 12 18680105befSFlorian Fainelli #define RBUF_OK_TO_SEND_MASK 0xff 18780105befSFlorian Fainelli #define RBUF_CRC_REPLACE (1 << 20) 18880105befSFlorian Fainelli #define RBUF_OK_TO_SEND_MODE (1 << 21) 18944a4524cSFlorian Fainelli /* SYSTEMPORT Lite uses two bits here */ 19044a4524cSFlorian Fainelli #define RBUF_RSB_SWAP0 (1 << 22) 19144a4524cSFlorian Fainelli #define RBUF_RSB_SWAP1 (1 << 23) 19280105befSFlorian Fainelli #define RBUF_ACPI_EN (1 << 23) 193bb9051a2SFlorian Fainelli #define RBUF_ACPI_EN_LITE (1 << 24) 19480105befSFlorian Fainelli 19580105befSFlorian Fainelli #define RBUF_PKT_RDY_THRESH 0x04 19680105befSFlorian Fainelli 19780105befSFlorian Fainelli #define RBUF_STATUS 0x08 19880105befSFlorian Fainelli #define RBUF_WOL_MODE (1 << 0) 19980105befSFlorian Fainelli #define RBUF_MPD (1 << 1) 20080105befSFlorian Fainelli #define RBUF_ACPI (1 << 2) 20180105befSFlorian Fainelli 20280105befSFlorian Fainelli #define RBUF_OVFL_DISC_CNTR 0x0c 20380105befSFlorian Fainelli #define RBUF_ERR_PKT_CNTR 0x10 20480105befSFlorian Fainelli 20580105befSFlorian Fainelli /* Transmit buffer offset and defines */ 20680105befSFlorian Fainelli #define SYS_PORT_TBUF_OFFSET 0x600 20780105befSFlorian Fainelli 20880105befSFlorian Fainelli #define TBUF_CONTROL 0x00 20980105befSFlorian Fainelli #define TBUF_BP_EN (1 << 0) 21080105befSFlorian Fainelli #define TBUF_MAX_PKT_THRESH_SHIFT 1 21180105befSFlorian Fainelli #define TBUF_MAX_PKT_THRESH_MASK 0x1f 21280105befSFlorian Fainelli #define TBUF_FULL_THRESH_SHIFT 8 21380105befSFlorian Fainelli #define TBUF_FULL_THRESH_MASK 0x1f 21480105befSFlorian Fainelli 21580105befSFlorian Fainelli /* UniMAC offset and defines */ 21680105befSFlorian Fainelli #define SYS_PORT_UMAC_OFFSET 0x800 21780105befSFlorian Fainelli 21880105befSFlorian Fainelli #define UMAC_MIB_START 0x400 21980105befSFlorian Fainelli 22080105befSFlorian Fainelli /* There is a 0xC gap between the end of RX and beginning of TX stats and then 22180105befSFlorian Fainelli * between the end of TX stats and the beginning of the RX RUNT 22280105befSFlorian Fainelli */ 22380105befSFlorian Fainelli #define UMAC_MIB_STAT_OFFSET 0xc 22480105befSFlorian Fainelli 22580105befSFlorian Fainelli #define UMAC_MIB_CTRL 0x580 22680105befSFlorian Fainelli #define MIB_RX_CNT_RST (1 << 0) 22780105befSFlorian Fainelli #define MIB_RUNT_CNT_RST (1 << 1) 22880105befSFlorian Fainelli #define MIB_TX_CNT_RST (1 << 2) 22983e82f4cSFlorian Fainelli 23044a4524cSFlorian Fainelli /* These offsets are valid for SYSTEMPORT and SYSTEMPORT Lite */ 23183e82f4cSFlorian Fainelli #define UMAC_MPD_CTRL 0x620 23283e82f4cSFlorian Fainelli #define MPD_EN (1 << 0) 23383e82f4cSFlorian Fainelli #define MSEQ_LEN_SHIFT 16 23483e82f4cSFlorian Fainelli #define MSEQ_LEN_MASK 0xff 23583e82f4cSFlorian Fainelli #define PSW_EN (1 << 27) 23683e82f4cSFlorian Fainelli 23783e82f4cSFlorian Fainelli #define UMAC_PSW_MS 0x624 23883e82f4cSFlorian Fainelli #define UMAC_PSW_LS 0x628 23980105befSFlorian Fainelli #define UMAC_MDF_CTRL 0x650 24080105befSFlorian Fainelli #define UMAC_MDF_ADDR 0x654 24180105befSFlorian Fainelli 24244a4524cSFlorian Fainelli /* Only valid on SYSTEMPORT Lite */ 24344a4524cSFlorian Fainelli #define SYS_PORT_GIB_OFFSET 0x1000 24444a4524cSFlorian Fainelli 24544a4524cSFlorian Fainelli #define GIB_CONTROL 0x00 24644a4524cSFlorian Fainelli #define GIB_TX_EN (1 << 0) 24744a4524cSFlorian Fainelli #define GIB_RX_EN (1 << 1) 24844a4524cSFlorian Fainelli #define GIB_TX_FLUSH (1 << 2) 24944a4524cSFlorian Fainelli #define GIB_RX_FLUSH (1 << 3) 25044a4524cSFlorian Fainelli #define GIB_GTX_CLK_SEL_SHIFT 4 25144a4524cSFlorian Fainelli #define GIB_GTX_CLK_EXT_CLK (0 << GIB_GTX_CLK_SEL_SHIFT) 25244a4524cSFlorian Fainelli #define GIB_GTX_CLK_125MHZ (1 << GIB_GTX_CLK_SEL_SHIFT) 25344a4524cSFlorian Fainelli #define GIB_GTX_CLK_250MHZ (2 << GIB_GTX_CLK_SEL_SHIFT) 2549e3bff92SFlorian Fainelli #define GIB_FCS_STRIP_SHIFT 6 2559e3bff92SFlorian Fainelli #define GIB_FCS_STRIP (1 << GIB_FCS_STRIP_SHIFT) 25644a4524cSFlorian Fainelli #define GIB_LCL_LOOP_EN (1 << 7) 25744a4524cSFlorian Fainelli #define GIB_LCL_LOOP_TXEN (1 << 8) 25844a4524cSFlorian Fainelli #define GIB_RMT_LOOP_EN (1 << 9) 25944a4524cSFlorian Fainelli #define GIB_RMT_LOOP_RXEN (1 << 10) 26044a4524cSFlorian Fainelli #define GIB_RX_PAUSE_EN (1 << 11) 26144a4524cSFlorian Fainelli #define GIB_PREAMBLE_LEN_SHIFT 12 26244a4524cSFlorian Fainelli #define GIB_PREAMBLE_LEN_MASK 0xf 26344a4524cSFlorian Fainelli #define GIB_IPG_LEN_SHIFT 16 26444a4524cSFlorian Fainelli #define GIB_IPG_LEN_MASK 0x3f 26544a4524cSFlorian Fainelli #define GIB_PAD_EXTENSION_SHIFT 22 26644a4524cSFlorian Fainelli #define GIB_PAD_EXTENSION_MASK 0x3f 26744a4524cSFlorian Fainelli 26844a4524cSFlorian Fainelli #define GIB_MAC1 0x08 26944a4524cSFlorian Fainelli #define GIB_MAC0 0x0c 27044a4524cSFlorian Fainelli 27180105befSFlorian Fainelli /* Receive DMA offset and defines */ 27280105befSFlorian Fainelli #define SYS_PORT_RDMA_OFFSET 0x2000 27380105befSFlorian Fainelli 27480105befSFlorian Fainelli #define RDMA_CONTROL 0x1000 27580105befSFlorian Fainelli #define RDMA_EN (1 << 0) 27680105befSFlorian Fainelli #define RDMA_RING_CFG (1 << 1) 27780105befSFlorian Fainelli #define RDMA_DISC_EN (1 << 2) 27880105befSFlorian Fainelli #define RDMA_BUF_DATA_OFFSET_SHIFT 4 27980105befSFlorian Fainelli #define RDMA_BUF_DATA_OFFSET_MASK 0x3ff 28080105befSFlorian Fainelli 28180105befSFlorian Fainelli #define RDMA_STATUS 0x1004 28280105befSFlorian Fainelli #define RDMA_DISABLED (1 << 0) 28380105befSFlorian Fainelli #define RDMA_DESC_RAM_INIT_BUSY (1 << 1) 28480105befSFlorian Fainelli #define RDMA_BP_STATUS (1 << 2) 28580105befSFlorian Fainelli 28680105befSFlorian Fainelli #define RDMA_SCB_BURST_SIZE 0x1008 28780105befSFlorian Fainelli 28880105befSFlorian Fainelli #define RDMA_RING_BUF_SIZE 0x100c 28980105befSFlorian Fainelli #define RDMA_RING_SIZE_SHIFT 16 29080105befSFlorian Fainelli 29180105befSFlorian Fainelli #define RDMA_WRITE_PTR_HI 0x1010 29280105befSFlorian Fainelli #define RDMA_WRITE_PTR_LO 0x1014 293*b98deb2fSFlorian Fainelli #define RDMA_OVFL_DISC_CNTR 0x1018 29480105befSFlorian Fainelli #define RDMA_PROD_INDEX 0x1018 29580105befSFlorian Fainelli #define RDMA_PROD_INDEX_MASK 0xffff 29680105befSFlorian Fainelli 29780105befSFlorian Fainelli #define RDMA_CONS_INDEX 0x101c 29880105befSFlorian Fainelli #define RDMA_CONS_INDEX_MASK 0xffff 29980105befSFlorian Fainelli 30080105befSFlorian Fainelli #define RDMA_START_ADDR_HI 0x1020 30180105befSFlorian Fainelli #define RDMA_START_ADDR_LO 0x1024 30280105befSFlorian Fainelli #define RDMA_END_ADDR_HI 0x1028 30380105befSFlorian Fainelli #define RDMA_END_ADDR_LO 0x102c 30480105befSFlorian Fainelli 30580105befSFlorian Fainelli #define RDMA_MBDONE_INTR 0x1030 306d0634868SFlorian Fainelli #define RDMA_INTR_THRESH_MASK 0x1ff 30780105befSFlorian Fainelli #define RDMA_TIMEOUT_SHIFT 16 30880105befSFlorian Fainelli #define RDMA_TIMEOUT_MASK 0xffff 30980105befSFlorian Fainelli 31080105befSFlorian Fainelli #define RDMA_XON_XOFF_THRESH 0x1034 31180105befSFlorian Fainelli #define RDMA_XON_XOFF_THRESH_MASK 0xffff 31280105befSFlorian Fainelli #define RDMA_XOFF_THRESH_SHIFT 16 31380105befSFlorian Fainelli 31480105befSFlorian Fainelli #define RDMA_READ_PTR_HI 0x1038 31580105befSFlorian Fainelli #define RDMA_READ_PTR_LO 0x103c 31680105befSFlorian Fainelli 31780105befSFlorian Fainelli #define RDMA_OVERRIDE 0x1040 31880105befSFlorian Fainelli #define RDMA_LE_MODE (1 << 0) 31980105befSFlorian Fainelli #define RDMA_REG_MODE (1 << 1) 32080105befSFlorian Fainelli 32180105befSFlorian Fainelli #define RDMA_TEST 0x1044 32280105befSFlorian Fainelli #define RDMA_TP_OUT_SEL (1 << 0) 32380105befSFlorian Fainelli #define RDMA_MEM_SEL (1 << 1) 32480105befSFlorian Fainelli 32580105befSFlorian Fainelli #define RDMA_DEBUG 0x1048 32680105befSFlorian Fainelli 32780105befSFlorian Fainelli /* Transmit DMA offset and defines */ 32880105befSFlorian Fainelli #define TDMA_NUM_RINGS 32 /* rings = queues */ 32980105befSFlorian Fainelli #define TDMA_PORT_SIZE DESC_SIZE /* two 32-bits words */ 33080105befSFlorian Fainelli 33180105befSFlorian Fainelli #define SYS_PORT_TDMA_OFFSET 0x4000 33280105befSFlorian Fainelli #define TDMA_WRITE_PORT_OFFSET 0x0000 33380105befSFlorian Fainelli #define TDMA_WRITE_PORT_HI(i) (TDMA_WRITE_PORT_OFFSET + \ 33480105befSFlorian Fainelli (i) * TDMA_PORT_SIZE) 33580105befSFlorian Fainelli #define TDMA_WRITE_PORT_LO(i) (TDMA_WRITE_PORT_OFFSET + \ 33680105befSFlorian Fainelli sizeof(u32) + (i) * TDMA_PORT_SIZE) 33780105befSFlorian Fainelli 33880105befSFlorian Fainelli #define TDMA_READ_PORT_OFFSET (TDMA_WRITE_PORT_OFFSET + \ 33980105befSFlorian Fainelli (TDMA_NUM_RINGS * TDMA_PORT_SIZE)) 34080105befSFlorian Fainelli #define TDMA_READ_PORT_HI(i) (TDMA_READ_PORT_OFFSET + \ 34180105befSFlorian Fainelli (i) * TDMA_PORT_SIZE) 34280105befSFlorian Fainelli #define TDMA_READ_PORT_LO(i) (TDMA_READ_PORT_OFFSET + \ 34380105befSFlorian Fainelli sizeof(u32) + (i) * TDMA_PORT_SIZE) 34480105befSFlorian Fainelli 34580105befSFlorian Fainelli #define TDMA_READ_PORT_CMD_OFFSET (TDMA_READ_PORT_OFFSET + \ 34680105befSFlorian Fainelli (TDMA_NUM_RINGS * TDMA_PORT_SIZE)) 34780105befSFlorian Fainelli #define TDMA_READ_PORT_CMD(i) (TDMA_READ_PORT_CMD_OFFSET + \ 34880105befSFlorian Fainelli (i) * sizeof(u32)) 34980105befSFlorian Fainelli 35080105befSFlorian Fainelli #define TDMA_DESC_RING_00_BASE (TDMA_READ_PORT_CMD_OFFSET + \ 35180105befSFlorian Fainelli (TDMA_NUM_RINGS * sizeof(u32))) 35280105befSFlorian Fainelli 35380105befSFlorian Fainelli /* Register offsets and defines relatives to a specific ring number */ 35480105befSFlorian Fainelli #define RING_HEAD_TAIL_PTR 0x00 35580105befSFlorian Fainelli #define RING_HEAD_MASK 0x7ff 35680105befSFlorian Fainelli #define RING_TAIL_SHIFT 11 35780105befSFlorian Fainelli #define RING_TAIL_MASK 0x7ff 35880105befSFlorian Fainelli #define RING_FLUSH (1 << 24) 35980105befSFlorian Fainelli #define RING_EN (1 << 25) 36080105befSFlorian Fainelli 36180105befSFlorian Fainelli #define RING_COUNT 0x04 36280105befSFlorian Fainelli #define RING_COUNT_MASK 0x7ff 36380105befSFlorian Fainelli #define RING_BUFF_DONE_SHIFT 11 36480105befSFlorian Fainelli #define RING_BUFF_DONE_MASK 0x7ff 36580105befSFlorian Fainelli 36680105befSFlorian Fainelli #define RING_MAX_HYST 0x08 36780105befSFlorian Fainelli #define RING_MAX_THRESH_MASK 0x7ff 36880105befSFlorian Fainelli #define RING_HYST_THRESH_SHIFT 11 36980105befSFlorian Fainelli #define RING_HYST_THRESH_MASK 0x7ff 37080105befSFlorian Fainelli 37180105befSFlorian Fainelli #define RING_INTR_CONTROL 0x0c 37280105befSFlorian Fainelli #define RING_INTR_THRESH_MASK 0x7ff 37380105befSFlorian Fainelli #define RING_EMPTY_INTR_EN (1 << 15) 37480105befSFlorian Fainelli #define RING_TIMEOUT_SHIFT 16 37580105befSFlorian Fainelli #define RING_TIMEOUT_MASK 0xffff 37680105befSFlorian Fainelli 37780105befSFlorian Fainelli #define RING_PROD_CONS_INDEX 0x10 37880105befSFlorian Fainelli #define RING_PROD_INDEX_MASK 0xffff 37980105befSFlorian Fainelli #define RING_CONS_INDEX_SHIFT 16 38080105befSFlorian Fainelli #define RING_CONS_INDEX_MASK 0xffff 38180105befSFlorian Fainelli 38280105befSFlorian Fainelli #define RING_MAPPING 0x14 383d1565763SFlorian Fainelli #define RING_QID_MASK 0x7 38480105befSFlorian Fainelli #define RING_PORT_ID_SHIFT 3 38580105befSFlorian Fainelli #define RING_PORT_ID_MASK 0x7 38680105befSFlorian Fainelli #define RING_IGNORE_STATUS (1 << 6) 38780105befSFlorian Fainelli #define RING_FAILOVER_EN (1 << 7) 38880105befSFlorian Fainelli #define RING_CREDIT_SHIFT 8 38980105befSFlorian Fainelli #define RING_CREDIT_MASK 0xffff 39080105befSFlorian Fainelli 39180105befSFlorian Fainelli #define RING_PCP_DEI_VID 0x18 39280105befSFlorian Fainelli #define RING_VID_MASK 0x7ff 39380105befSFlorian Fainelli #define RING_DEI (1 << 12) 39480105befSFlorian Fainelli #define RING_PCP_SHIFT 13 39580105befSFlorian Fainelli #define RING_PCP_MASK 0x7 39680105befSFlorian Fainelli #define RING_PKT_SIZE_ADJ_SHIFT 16 39780105befSFlorian Fainelli #define RING_PKT_SIZE_ADJ_MASK 0xf 39880105befSFlorian Fainelli 39980105befSFlorian Fainelli #define TDMA_DESC_RING_SIZE 28 40080105befSFlorian Fainelli 40180105befSFlorian Fainelli /* Defininition for a given TX ring base address */ 40280105befSFlorian Fainelli #define TDMA_DESC_RING_BASE(i) (TDMA_DESC_RING_00_BASE + \ 40380105befSFlorian Fainelli ((i) * TDMA_DESC_RING_SIZE)) 40480105befSFlorian Fainelli 40580105befSFlorian Fainelli /* Ring indexed register addreses */ 40680105befSFlorian Fainelli #define TDMA_DESC_RING_HEAD_TAIL_PTR(i) (TDMA_DESC_RING_BASE(i) + \ 40780105befSFlorian Fainelli RING_HEAD_TAIL_PTR) 40880105befSFlorian Fainelli #define TDMA_DESC_RING_COUNT(i) (TDMA_DESC_RING_BASE(i) + \ 40980105befSFlorian Fainelli RING_COUNT) 41080105befSFlorian Fainelli #define TDMA_DESC_RING_MAX_HYST(i) (TDMA_DESC_RING_BASE(i) + \ 41180105befSFlorian Fainelli RING_MAX_HYST) 41280105befSFlorian Fainelli #define TDMA_DESC_RING_INTR_CONTROL(i) (TDMA_DESC_RING_BASE(i) + \ 41380105befSFlorian Fainelli RING_INTR_CONTROL) 41480105befSFlorian Fainelli #define TDMA_DESC_RING_PROD_CONS_INDEX(i) \ 41580105befSFlorian Fainelli (TDMA_DESC_RING_BASE(i) + \ 41680105befSFlorian Fainelli RING_PROD_CONS_INDEX) 41780105befSFlorian Fainelli #define TDMA_DESC_RING_MAPPING(i) (TDMA_DESC_RING_BASE(i) + \ 41880105befSFlorian Fainelli RING_MAPPING) 41980105befSFlorian Fainelli #define TDMA_DESC_RING_PCP_DEI_VID(i) (TDMA_DESC_RING_BASE(i) + \ 42080105befSFlorian Fainelli RING_PCP_DEI_VID) 42180105befSFlorian Fainelli 42280105befSFlorian Fainelli #define TDMA_CONTROL 0x600 42344a4524cSFlorian Fainelli #define TDMA_EN 0 42444a4524cSFlorian Fainelli #define TSB_EN 1 42544a4524cSFlorian Fainelli /* Uses 2 bits on SYSTEMPORT Lite and shifts everything by 1 bit, we 42644a4524cSFlorian Fainelli * keep the SYSTEMPORT layout here and adjust with tdma_control_bit() 42744a4524cSFlorian Fainelli */ 428487234ccSFlorian Fainelli #define TSB_SWAP0 2 429487234ccSFlorian Fainelli #define TSB_SWAP1 3 43044a4524cSFlorian Fainelli #define ACB_ALGO 3 43180105befSFlorian Fainelli #define BUF_DATA_OFFSET_SHIFT 4 43280105befSFlorian Fainelli #define BUF_DATA_OFFSET_MASK 0x3ff 43344a4524cSFlorian Fainelli #define VLAN_EN 14 43444a4524cSFlorian Fainelli #define SW_BRCM_TAG 15 43544a4524cSFlorian Fainelli #define WNC_KPT_SIZE_UPDATE 16 43644a4524cSFlorian Fainelli #define SYNC_PKT_SIZE 17 43780105befSFlorian Fainelli #define ACH_TXDONE_DELAY_SHIFT 18 43880105befSFlorian Fainelli #define ACH_TXDONE_DELAY_MASK 0xff 43980105befSFlorian Fainelli 44080105befSFlorian Fainelli #define TDMA_STATUS 0x604 44180105befSFlorian Fainelli #define TDMA_DISABLED (1 << 0) 44280105befSFlorian Fainelli #define TDMA_LL_RAM_INIT_BUSY (1 << 1) 44380105befSFlorian Fainelli 44480105befSFlorian Fainelli #define TDMA_SCB_BURST_SIZE 0x608 44580105befSFlorian Fainelli #define TDMA_OVER_MAX_THRESH_STATUS 0x60c 44680105befSFlorian Fainelli #define TDMA_OVER_HYST_THRESH_STATUS 0x610 44780105befSFlorian Fainelli #define TDMA_TPID 0x614 44880105befSFlorian Fainelli 44980105befSFlorian Fainelli #define TDMA_FREE_LIST_HEAD_TAIL_PTR 0x618 45080105befSFlorian Fainelli #define TDMA_FREE_HEAD_MASK 0x7ff 45180105befSFlorian Fainelli #define TDMA_FREE_TAIL_SHIFT 11 45280105befSFlorian Fainelli #define TDMA_FREE_TAIL_MASK 0x7ff 45380105befSFlorian Fainelli 45480105befSFlorian Fainelli #define TDMA_FREE_LIST_COUNT 0x61c 45580105befSFlorian Fainelli #define TDMA_FREE_LIST_COUNT_MASK 0x7ff 45680105befSFlorian Fainelli 45780105befSFlorian Fainelli #define TDMA_TIER2_ARB_CTRL 0x620 45880105befSFlorian Fainelli #define TDMA_ARB_MODE_RR 0 45980105befSFlorian Fainelli #define TDMA_ARB_MODE_WEIGHT_RR 0x1 46080105befSFlorian Fainelli #define TDMA_ARB_MODE_STRICT 0x2 46180105befSFlorian Fainelli #define TDMA_ARB_MODE_DEFICIT_RR 0x3 46280105befSFlorian Fainelli #define TDMA_CREDIT_SHIFT 4 46380105befSFlorian Fainelli #define TDMA_CREDIT_MASK 0xffff 46480105befSFlorian Fainelli 46580105befSFlorian Fainelli #define TDMA_TIER1_ARB_0_CTRL 0x624 46680105befSFlorian Fainelli #define TDMA_ARB_EN (1 << 0) 46780105befSFlorian Fainelli 46880105befSFlorian Fainelli #define TDMA_TIER1_ARB_0_QUEUE_EN 0x628 46980105befSFlorian Fainelli #define TDMA_TIER1_ARB_1_CTRL 0x62c 47080105befSFlorian Fainelli #define TDMA_TIER1_ARB_1_QUEUE_EN 0x630 47180105befSFlorian Fainelli #define TDMA_TIER1_ARB_2_CTRL 0x634 47280105befSFlorian Fainelli #define TDMA_TIER1_ARB_2_QUEUE_EN 0x638 47380105befSFlorian Fainelli #define TDMA_TIER1_ARB_3_CTRL 0x63c 47480105befSFlorian Fainelli #define TDMA_TIER1_ARB_3_QUEUE_EN 0x640 47580105befSFlorian Fainelli 47680105befSFlorian Fainelli #define TDMA_SCB_ENDIAN_OVERRIDE 0x644 47780105befSFlorian Fainelli #define TDMA_LE_MODE (1 << 0) 47880105befSFlorian Fainelli #define TDMA_REG_MODE (1 << 1) 47980105befSFlorian Fainelli 48080105befSFlorian Fainelli #define TDMA_TEST 0x648 48180105befSFlorian Fainelli #define TDMA_TP_OUT_SEL (1 << 0) 48280105befSFlorian Fainelli #define TDMA_MEM_TM (1 << 1) 48380105befSFlorian Fainelli 48480105befSFlorian Fainelli #define TDMA_DEBUG 0x64c 48580105befSFlorian Fainelli 48680105befSFlorian Fainelli /* Number of Receive hardware descriptor words */ 48744a4524cSFlorian Fainelli #define SP_NUM_HW_RX_DESC_WORDS 1024 488a390e034SFlorian Fainelli #define SP_LT_NUM_HW_RX_DESC_WORDS 512 48980105befSFlorian Fainelli 49044a4524cSFlorian Fainelli /* Internal linked-list RAM size */ 49144a4524cSFlorian Fainelli #define SP_NUM_TX_DESC 1536 49244a4524cSFlorian Fainelli #define SP_LT_NUM_TX_DESC 256 49380105befSFlorian Fainelli 4947e6e185cSFlorian Fainelli #define WORDS_PER_DESC 2 49580105befSFlorian Fainelli 49680105befSFlorian Fainelli /* Rx/Tx common counter group.*/ 49780105befSFlorian Fainelli struct bcm_sysport_pkt_counters { 49880105befSFlorian Fainelli u32 cnt_64; /* RO Received/Transmited 64 bytes packet */ 49980105befSFlorian Fainelli u32 cnt_127; /* RO Rx/Tx 127 bytes packet */ 50080105befSFlorian Fainelli u32 cnt_255; /* RO Rx/Tx 65-255 bytes packet */ 50180105befSFlorian Fainelli u32 cnt_511; /* RO Rx/Tx 256-511 bytes packet */ 50280105befSFlorian Fainelli u32 cnt_1023; /* RO Rx/Tx 512-1023 bytes packet */ 50380105befSFlorian Fainelli u32 cnt_1518; /* RO Rx/Tx 1024-1518 bytes packet */ 50480105befSFlorian Fainelli u32 cnt_mgv; /* RO Rx/Tx 1519-1522 good VLAN packet */ 50580105befSFlorian Fainelli u32 cnt_2047; /* RO Rx/Tx 1522-2047 bytes packet*/ 50680105befSFlorian Fainelli u32 cnt_4095; /* RO Rx/Tx 2048-4095 bytes packet*/ 50780105befSFlorian Fainelli u32 cnt_9216; /* RO Rx/Tx 4096-9216 bytes packet*/ 50880105befSFlorian Fainelli }; 50980105befSFlorian Fainelli 51080105befSFlorian Fainelli /* RSV, Receive Status Vector */ 51180105befSFlorian Fainelli struct bcm_sysport_rx_counters { 51280105befSFlorian Fainelli struct bcm_sysport_pkt_counters pkt_cnt; 51380105befSFlorian Fainelli u32 pkt; /* RO (0x428) Received pkt count*/ 51480105befSFlorian Fainelli u32 bytes; /* RO Received byte count */ 51580105befSFlorian Fainelli u32 mca; /* RO # of Received multicast pkt */ 51680105befSFlorian Fainelli u32 bca; /* RO # of Receive broadcast pkt */ 51780105befSFlorian Fainelli u32 fcs; /* RO # of Received FCS error */ 51880105befSFlorian Fainelli u32 cf; /* RO # of Received control frame pkt*/ 51980105befSFlorian Fainelli u32 pf; /* RO # of Received pause frame pkt */ 52080105befSFlorian Fainelli u32 uo; /* RO # of unknown op code pkt */ 52180105befSFlorian Fainelli u32 aln; /* RO # of alignment error count */ 52280105befSFlorian Fainelli u32 flr; /* RO # of frame length out of range count */ 52380105befSFlorian Fainelli u32 cde; /* RO # of code error pkt */ 52480105befSFlorian Fainelli u32 fcr; /* RO # of carrier sense error pkt */ 52580105befSFlorian Fainelli u32 ovr; /* RO # of oversize pkt*/ 52680105befSFlorian Fainelli u32 jbr; /* RO # of jabber count */ 52780105befSFlorian Fainelli u32 mtue; /* RO # of MTU error pkt*/ 52880105befSFlorian Fainelli u32 pok; /* RO # of Received good pkt */ 52980105befSFlorian Fainelli u32 uc; /* RO # of unicast pkt */ 53080105befSFlorian Fainelli u32 ppp; /* RO # of PPP pkt */ 53180105befSFlorian Fainelli u32 rcrc; /* RO (0x470),# of CRC match pkt */ 53280105befSFlorian Fainelli }; 53380105befSFlorian Fainelli 53480105befSFlorian Fainelli /* TSV, Transmit Status Vector */ 53580105befSFlorian Fainelli struct bcm_sysport_tx_counters { 53680105befSFlorian Fainelli struct bcm_sysport_pkt_counters pkt_cnt; 53780105befSFlorian Fainelli u32 pkts; /* RO (0x4a8) Transmited pkt */ 53880105befSFlorian Fainelli u32 mca; /* RO # of xmited multicast pkt */ 53980105befSFlorian Fainelli u32 bca; /* RO # of xmited broadcast pkt */ 54080105befSFlorian Fainelli u32 pf; /* RO # of xmited pause frame count */ 54180105befSFlorian Fainelli u32 cf; /* RO # of xmited control frame count */ 54280105befSFlorian Fainelli u32 fcs; /* RO # of xmited FCS error count */ 54380105befSFlorian Fainelli u32 ovr; /* RO # of xmited oversize pkt */ 54480105befSFlorian Fainelli u32 drf; /* RO # of xmited deferral pkt */ 54580105befSFlorian Fainelli u32 edf; /* RO # of xmited Excessive deferral pkt*/ 54680105befSFlorian Fainelli u32 scl; /* RO # of xmited single collision pkt */ 54780105befSFlorian Fainelli u32 mcl; /* RO # of xmited multiple collision pkt*/ 54880105befSFlorian Fainelli u32 lcl; /* RO # of xmited late collision pkt */ 54980105befSFlorian Fainelli u32 ecl; /* RO # of xmited excessive collision pkt*/ 55080105befSFlorian Fainelli u32 frg; /* RO # of xmited fragments pkt*/ 55180105befSFlorian Fainelli u32 ncl; /* RO # of xmited total collision count */ 55280105befSFlorian Fainelli u32 jbr; /* RO # of xmited jabber count*/ 55380105befSFlorian Fainelli u32 bytes; /* RO # of xmited byte count */ 55480105befSFlorian Fainelli u32 pok; /* RO # of xmited good pkt */ 555165996bdSAntonio Ospite u32 uc; /* RO (0x4f0) # of xmited unicast pkt */ 55680105befSFlorian Fainelli }; 55780105befSFlorian Fainelli 55880105befSFlorian Fainelli struct bcm_sysport_mib { 55980105befSFlorian Fainelli struct bcm_sysport_rx_counters rx; 56080105befSFlorian Fainelli struct bcm_sysport_tx_counters tx; 56180105befSFlorian Fainelli u32 rx_runt_cnt; 56280105befSFlorian Fainelli u32 rx_runt_fcs; 56380105befSFlorian Fainelli u32 rx_runt_fcs_align; 56480105befSFlorian Fainelli u32 rx_runt_bytes; 56580105befSFlorian Fainelli u32 rxchk_bad_csum; 56680105befSFlorian Fainelli u32 rxchk_other_pkt_disc; 56780105befSFlorian Fainelli u32 rbuf_ovflow_cnt; 56880105befSFlorian Fainelli u32 rbuf_err_cnt; 569*b98deb2fSFlorian Fainelli u32 rdma_ovflow_cnt; 57060b4ea17SFlorian Fainelli u32 alloc_rx_buff_failed; 57160b4ea17SFlorian Fainelli u32 rx_dma_failed; 57260b4ea17SFlorian Fainelli u32 tx_dma_failed; 573a5d78ce7SFlorian Fainelli u32 tx_realloc_tsb; 574a5d78ce7SFlorian Fainelli u32 tx_realloc_tsb_failed; 57580105befSFlorian Fainelli }; 57680105befSFlorian Fainelli 57780105befSFlorian Fainelli /* HW maintains a large list of counters */ 57880105befSFlorian Fainelli enum bcm_sysport_stat_type { 57980105befSFlorian Fainelli BCM_SYSPORT_STAT_NETDEV = -1, 58010377ba7Skiki good BCM_SYSPORT_STAT_NETDEV64, 58180105befSFlorian Fainelli BCM_SYSPORT_STAT_MIB_RX, 58280105befSFlorian Fainelli BCM_SYSPORT_STAT_MIB_TX, 58380105befSFlorian Fainelli BCM_SYSPORT_STAT_RUNT, 58480105befSFlorian Fainelli BCM_SYSPORT_STAT_RXCHK, 58580105befSFlorian Fainelli BCM_SYSPORT_STAT_RBUF, 586*b98deb2fSFlorian Fainelli BCM_SYSPORT_STAT_RDMA, 58755ff4ea9SFlorian Fainelli BCM_SYSPORT_STAT_SOFT, 58880105befSFlorian Fainelli }; 58980105befSFlorian Fainelli 59080105befSFlorian Fainelli /* Macros to help define ethtool statistics */ 59180105befSFlorian Fainelli #define STAT_NETDEV(m) { \ 59280105befSFlorian Fainelli .stat_string = __stringify(m), \ 59380105befSFlorian Fainelli .stat_sizeof = sizeof(((struct net_device_stats *)0)->m), \ 59480105befSFlorian Fainelli .stat_offset = offsetof(struct net_device_stats, m), \ 59580105befSFlorian Fainelli .type = BCM_SYSPORT_STAT_NETDEV, \ 59680105befSFlorian Fainelli } 59780105befSFlorian Fainelli 59810377ba7Skiki good #define STAT_NETDEV64(m) { \ 59910377ba7Skiki good .stat_string = __stringify(m), \ 60010377ba7Skiki good .stat_sizeof = sizeof(((struct bcm_sysport_stats64 *)0)->m), \ 60110377ba7Skiki good .stat_offset = offsetof(struct bcm_sysport_stats64, m), \ 60210377ba7Skiki good .type = BCM_SYSPORT_STAT_NETDEV64, \ 60310377ba7Skiki good } 60410377ba7Skiki good 60580105befSFlorian Fainelli #define STAT_MIB(str, m, _type) { \ 60680105befSFlorian Fainelli .stat_string = str, \ 60780105befSFlorian Fainelli .stat_sizeof = sizeof(((struct bcm_sysport_priv *)0)->m), \ 60880105befSFlorian Fainelli .stat_offset = offsetof(struct bcm_sysport_priv, m), \ 60980105befSFlorian Fainelli .type = _type, \ 61080105befSFlorian Fainelli } 61180105befSFlorian Fainelli 61280105befSFlorian Fainelli #define STAT_MIB_RX(str, m) STAT_MIB(str, m, BCM_SYSPORT_STAT_MIB_RX) 61380105befSFlorian Fainelli #define STAT_MIB_TX(str, m) STAT_MIB(str, m, BCM_SYSPORT_STAT_MIB_TX) 61480105befSFlorian Fainelli #define STAT_RUNT(str, m) STAT_MIB(str, m, BCM_SYSPORT_STAT_RUNT) 61555ff4ea9SFlorian Fainelli #define STAT_MIB_SOFT(str, m) STAT_MIB(str, m, BCM_SYSPORT_STAT_SOFT) 61680105befSFlorian Fainelli 61780105befSFlorian Fainelli #define STAT_RXCHK(str, m, ofs) { \ 61880105befSFlorian Fainelli .stat_string = str, \ 61980105befSFlorian Fainelli .stat_sizeof = sizeof(((struct bcm_sysport_priv *)0)->m), \ 62080105befSFlorian Fainelli .stat_offset = offsetof(struct bcm_sysport_priv, m), \ 62180105befSFlorian Fainelli .type = BCM_SYSPORT_STAT_RXCHK, \ 62280105befSFlorian Fainelli .reg_offset = ofs, \ 62380105befSFlorian Fainelli } 62480105befSFlorian Fainelli 62580105befSFlorian Fainelli #define STAT_RBUF(str, m, ofs) { \ 62680105befSFlorian Fainelli .stat_string = str, \ 62780105befSFlorian Fainelli .stat_sizeof = sizeof(((struct bcm_sysport_priv *)0)->m), \ 62880105befSFlorian Fainelli .stat_offset = offsetof(struct bcm_sysport_priv, m), \ 62980105befSFlorian Fainelli .type = BCM_SYSPORT_STAT_RBUF, \ 63080105befSFlorian Fainelli .reg_offset = ofs, \ 63180105befSFlorian Fainelli } 63280105befSFlorian Fainelli 633*b98deb2fSFlorian Fainelli #define STAT_RDMA(str, m, ofs) { \ 634*b98deb2fSFlorian Fainelli .stat_string = str, \ 635*b98deb2fSFlorian Fainelli .stat_sizeof = sizeof(((struct bcm_sysport_priv *)0)->m), \ 636*b98deb2fSFlorian Fainelli .stat_offset = offsetof(struct bcm_sysport_priv, m), \ 637*b98deb2fSFlorian Fainelli .type = BCM_SYSPORT_STAT_RDMA, \ 638*b98deb2fSFlorian Fainelli .reg_offset = ofs, \ 639*b98deb2fSFlorian Fainelli } 640*b98deb2fSFlorian Fainelli 64130defeb2SFlorian Fainelli /* TX bytes and packets */ 64230defeb2SFlorian Fainelli #define NUM_SYSPORT_TXQ_STAT 2 64330defeb2SFlorian Fainelli 64480105befSFlorian Fainelli struct bcm_sysport_stats { 64580105befSFlorian Fainelli char stat_string[ETH_GSTRING_LEN]; 64680105befSFlorian Fainelli int stat_sizeof; 64780105befSFlorian Fainelli int stat_offset; 64880105befSFlorian Fainelli enum bcm_sysport_stat_type type; 64980105befSFlorian Fainelli /* reg offset from UMAC base for misc counters */ 65080105befSFlorian Fainelli u16 reg_offset; 65180105befSFlorian Fainelli }; 65280105befSFlorian Fainelli 65310377ba7Skiki good struct bcm_sysport_stats64 { 65410377ba7Skiki good /* 64bit stats on 32bit/64bit Machine */ 65510377ba7Skiki good u64 rx_packets; 65610377ba7Skiki good u64 rx_bytes; 65710377ba7Skiki good u64 tx_packets; 65810377ba7Skiki good u64 tx_bytes; 65910377ba7Skiki good }; 66010377ba7Skiki good 66180105befSFlorian Fainelli /* Software house keeping helper structure */ 66280105befSFlorian Fainelli struct bcm_sysport_cb { 66380105befSFlorian Fainelli struct sk_buff *skb; /* SKB for RX packets */ 66480105befSFlorian Fainelli void __iomem *bd_addr; /* Buffer descriptor PHYS addr */ 66580105befSFlorian Fainelli 66680105befSFlorian Fainelli DEFINE_DMA_UNMAP_ADDR(dma_addr); 66780105befSFlorian Fainelli DEFINE_DMA_UNMAP_LEN(dma_len); 66880105befSFlorian Fainelli }; 66980105befSFlorian Fainelli 67044a4524cSFlorian Fainelli enum bcm_sysport_type { 67144a4524cSFlorian Fainelli SYSTEMPORT = 0, 67244a4524cSFlorian Fainelli SYSTEMPORT_LITE, 67344a4524cSFlorian Fainelli }; 67444a4524cSFlorian Fainelli 67544a4524cSFlorian Fainelli struct bcm_sysport_hw_params { 67644a4524cSFlorian Fainelli bool is_lite; 67744a4524cSFlorian Fainelli unsigned int num_rx_desc_words; 67844a4524cSFlorian Fainelli }; 67944a4524cSFlorian Fainelli 680b6e0e875SFlorian Fainelli struct bcm_sysport_net_dim { 681b6e0e875SFlorian Fainelli u16 use_dim; 682b6e0e875SFlorian Fainelli u16 event_ctr; 683b6e0e875SFlorian Fainelli unsigned long packets; 684b6e0e875SFlorian Fainelli unsigned long bytes; 6858960b389STal Gilboa struct dim dim; 686b6e0e875SFlorian Fainelli }; 687b6e0e875SFlorian Fainelli 68880105befSFlorian Fainelli /* Software view of the TX ring */ 68980105befSFlorian Fainelli struct bcm_sysport_tx_ring { 69080105befSFlorian Fainelli spinlock_t lock; /* Ring lock for tx reclaim/xmit */ 69180105befSFlorian Fainelli struct napi_struct napi; /* NAPI per tx queue */ 69280105befSFlorian Fainelli unsigned int index; /* Ring index */ 69380105befSFlorian Fainelli unsigned int size; /* Ring current size */ 69480105befSFlorian Fainelli unsigned int alloc_size; /* Ring one-time allocated size */ 69580105befSFlorian Fainelli unsigned int desc_count; /* Number of descriptors */ 69680105befSFlorian Fainelli unsigned int curr_desc; /* Current descriptor */ 69780105befSFlorian Fainelli unsigned int c_index; /* Last consumer index */ 698484d802dSFlorian Fainelli unsigned int clean_index; /* Current clean index */ 69980105befSFlorian Fainelli struct bcm_sysport_cb *cbs; /* Transmit control blocks */ 70080105befSFlorian Fainelli struct bcm_sysport_priv *priv; /* private context backpointer */ 70130defeb2SFlorian Fainelli unsigned long packets; /* packets statistics */ 70230defeb2SFlorian Fainelli unsigned long bytes; /* bytes statistics */ 703d1565763SFlorian Fainelli unsigned int switch_queue; /* switch port queue number */ 704d1565763SFlorian Fainelli unsigned int switch_port; /* switch port queue number */ 7053ded76a8SFlorian Fainelli bool inspect; /* inspect switch port and queue */ 70680105befSFlorian Fainelli }; 70780105befSFlorian Fainelli 70880105befSFlorian Fainelli /* Driver private structure */ 70980105befSFlorian Fainelli struct bcm_sysport_priv { 71080105befSFlorian Fainelli void __iomem *base; 71180105befSFlorian Fainelli u32 irq0_stat; 71280105befSFlorian Fainelli u32 irq0_mask; 71380105befSFlorian Fainelli u32 irq1_stat; 71480105befSFlorian Fainelli u32 irq1_mask; 71544a4524cSFlorian Fainelli bool is_lite; 71644a4524cSFlorian Fainelli unsigned int num_rx_desc_words; 71780105befSFlorian Fainelli struct napi_struct napi ____cacheline_aligned; 71880105befSFlorian Fainelli struct net_device *netdev; 71980105befSFlorian Fainelli struct platform_device *pdev; 72080105befSFlorian Fainelli int irq0; 72180105befSFlorian Fainelli int irq1; 72283e82f4cSFlorian Fainelli int wol_irq; 72380105befSFlorian Fainelli 72480105befSFlorian Fainelli /* Transmit rings */ 7258b8e6e78SFlorian Fainelli spinlock_t desc_lock; 7267b78be48SFlorian Fainelli struct bcm_sysport_tx_ring *tx_rings; 72780105befSFlorian Fainelli 72880105befSFlorian Fainelli /* Receive queue */ 72980105befSFlorian Fainelli void __iomem *rx_bds; 73080105befSFlorian Fainelli struct bcm_sysport_cb *rx_cbs; 73180105befSFlorian Fainelli unsigned int num_rx_bds; 73280105befSFlorian Fainelli unsigned int rx_read_ptr; 73380105befSFlorian Fainelli unsigned int rx_c_index; 73480105befSFlorian Fainelli 735b6e0e875SFlorian Fainelli struct bcm_sysport_net_dim dim; 736a8cdfbdfSFlorian Fainelli u32 rx_max_coalesced_frames; 737a8cdfbdfSFlorian Fainelli u32 rx_coalesce_usecs; 738b6e0e875SFlorian Fainelli 73980105befSFlorian Fainelli /* PHY device */ 740186534a3SFlorian Fainelli struct device_node *phy_dn; 74180105befSFlorian Fainelli phy_interface_t phy_interface; 74280105befSFlorian Fainelli int old_pause; 74380105befSFlorian Fainelli int old_link; 74480105befSFlorian Fainelli int old_duplex; 74580105befSFlorian Fainelli 74680105befSFlorian Fainelli /* Misc fields */ 7479d34c1cbSFlorian Fainelli unsigned int rx_chk_en:1; 74880105befSFlorian Fainelli unsigned int tsb_en:1; 74980105befSFlorian Fainelli unsigned int crc_fwd:1; 75080105befSFlorian Fainelli u16 rev; 75183e82f4cSFlorian Fainelli u32 wolopts; 7528dfb8d2cSFlorian Fainelli u8 sopass[SOPASS_MAX]; 75383e82f4cSFlorian Fainelli unsigned int wol_irq_disabled:1; 75431bc72d9SFlorian Fainelli struct clk *clk; 7556328a126SFlorian Fainelli struct clk *wol_clk; 75680105befSFlorian Fainelli 75780105befSFlorian Fainelli /* MIB related fields */ 75880105befSFlorian Fainelli struct bcm_sysport_mib mib; 75980105befSFlorian Fainelli 76080105befSFlorian Fainelli /* Ethtool */ 76180105befSFlorian Fainelli u32 msg_enable; 762bb9051a2SFlorian Fainelli DECLARE_BITMAP(filters, RXCHK_BRCM_TAG_MAX); 76380f8dea8SFlorian Fainelli u32 filters_loc[RXCHK_BRCM_TAG_MAX]; 76410377ba7Skiki good 76510377ba7Skiki good struct bcm_sysport_stats64 stats64; 76610377ba7Skiki good 76710377ba7Skiki good /* For atomic update generic 64bit value on 32bit Machine */ 76810377ba7Skiki good struct u64_stats_sync syncp; 769d1565763SFlorian Fainelli 770d1565763SFlorian Fainelli /* map information between switch port queues and local queues */ 7711593cd40SVladimir Oltean struct notifier_block netdev_notifier; 772d1565763SFlorian Fainelli unsigned int per_port_num_tx_queues; 773d1565763SFlorian Fainelli struct bcm_sysport_tx_ring *ring_map[DSA_MAX_PORTS * 8]; 774d1565763SFlorian Fainelli 77580105befSFlorian Fainelli }; 77680105befSFlorian Fainelli #endif /* __BCM_SYSPORT_H */ 777