#ifndef _ATGE_L1C_REG_H
#define _ATGE_L1C_REG_H
#ifdef __cplusplus
extern "C" {
#endif
#pragma pack(1)
typedef struct l1c_cmb {
uint32_t intr_status;
uint32_t rx_prod_cons;
uint32_t tx_prod_cons;
} l1c_cmb_t;
typedef struct l1c_rx_desc {
uint64_t addr;
} l1c_rx_desc_t;
typedef struct l1c_rx_rdesc {
uint32_t rdinfo;
uint32_t rss;
uint32_t vtag;
uint32_t status;
} l1c_rx_rdesc_t;
typedef struct l1c_smb {
uint32_t rx_frames;
uint32_t rx_bcast_frames;
uint32_t rx_mcast_frames;
uint32_t rx_pause_frames;
uint32_t rx_control_frames;
uint32_t rx_crcerrs;
uint32_t rx_lenerrs;
uint32_t rx_bytes;
uint32_t rx_runts;
uint32_t rx_fragments;
uint32_t rx_pkts_64;
uint32_t rx_pkts_65_127;
uint32_t rx_pkts_128_255;
uint32_t rx_pkts_256_511;
uint32_t rx_pkts_512_1023;
uint32_t rx_pkts_1024_1518;
uint32_t rx_pkts_1519_max;
uint32_t rx_pkts_truncated;
uint32_t rx_fifo_oflows;
uint32_t rx_desc_oflows;
uint32_t rx_alignerrs;
uint32_t rx_bcast_bytes;
uint32_t rx_mcast_bytes;
uint32_t rx_pkts_filtered;
uint32_t tx_frames;
uint32_t tx_bcast_frames;
uint32_t tx_mcast_frames;
uint32_t tx_pause_frames;
uint32_t tx_excess_defer;
uint32_t tx_control_frames;
uint32_t tx_deferred;
uint32_t tx_bytes;
uint32_t tx_pkts_64;
uint32_t tx_pkts_65_127;
uint32_t tx_pkts_128_255;
uint32_t tx_pkts_256_511;
uint32_t tx_pkts_512_1023;
uint32_t tx_pkts_1024_1518;
uint32_t tx_pkts_1519_max;
uint32_t tx_single_colls;
uint32_t tx_multi_colls;
uint32_t tx_late_colls;
uint32_t tx_excess_colls;
uint32_t tx_underrun;
uint32_t tx_desc_underrun;
uint32_t tx_lenerrs;
uint32_t tx_pkts_truncated;
uint32_t tx_bcast_bytes;
uint32_t tx_mcast_bytes;
uint32_t updated;
} atge_l1c_smb_t;
#pragma pack()
#define L1C_RX_RING_CNT 256
#define L1C_RR_RING_CNT L1C_RX_RING_CNT
#define L1C_HEADROOM 6
#define L1C_RING_ALIGN 16
#define L1C_TX_RING_ALIGN 16
#define L1C_RX_RING_ALIGN 16
#define L1C_RR_RING_ALIGN 16
#define L1C_CMB_ALIGN 16
#define L1C_SMB_ALIGN 16
#define L1C_CMB_BLOCK_SZ sizeof (struct l1c_cmb)
#define L1C_SMB_BLOCK_SZ sizeof (struct l1c_smb)
#define L1C_RX_RING_SZ \
(sizeof (struct l1c_rx_desc) * L1C_RX_RING_CNT)
#define L1C_RR_RING_SZ \
(sizeof (struct l1c_rx_rdesc) * L1C_RR_RING_CNT)
#define L1C_RRD_CSUM_MASK 0x0000FFFF
#define L1C_RRD_RD_CNT_MASK 0x000F0000
#define L1C_RRD_RD_IDX_MASK 0xFFF00000
#define L1C_RRD_CSUM_SHIFT 0
#define L1C_RRD_RD_CNT_SHIFT 16
#define L1C_RRD_RD_IDX_SHIFT 20
#define L1C_RRD_CSUM(x) \
(((x) & L1C_RRD_CSUM_MASK) >> L1C_RRD_CSUM_SHIFT)
#define L1C_RRD_RD_CNT(x) \
(((x) & L1C_RRD_RD_CNT_MASK) >> L1C_RRD_RD_CNT_SHIFT)
#define L1C_RRD_RD_IDX(x) \
(((x) & L1C_RRD_RD_IDX_MASK) >> L1C_RRD_RD_IDX_SHIFT)
#define L1C_RRD_VLAN_MASK 0x0000FFFF
#define L1C_RRD_HEAD_LEN_MASK 0x00FF0000
#define L1C_RRD_HDS_MASK 0x03000000
#define L1C_RRD_HDS_NONE 0x00000000
#define L1C_RRD_HDS_HEAD 0x01000000
#define L1C_RRD_HDS_DATA 0x02000000
#define L1C_RRD_CPU_MASK 0x0C000000
#define L1C_RRD_HASH_FLAG_MASK 0xF0000000
#define L1C_RRD_VLAN_SHIFT 0
#define L1C_RRD_HEAD_LEN_SHIFT 16
#define L1C_RRD_HDS_SHIFT 24
#define L1C_RRD_CPU_SHIFT 26
#define L1C_RRD_HASH_FLAG_SHIFT 28
#define L1C_RRD_VLAN(x) \
(((x) & L1C_RRD_VLAN_MASK) >> L1C_RRD_VLAN_SHIFT)
#define L1C_RRD_HEAD_LEN(x) \
(((x) & L1C_RRD_HEAD_LEN_MASK) >> L1C_RRD_HEAD_LEN_SHIFT)
#define L1C_RRD_CPU(x) \
(((x) & L1C_RRD_CPU_MASK) >> L1C_RRD_CPU_SHIFT)
#define L1C_RRD_LEN_MASK 0x00003FFF
#define L1C_RRD_LEN_SHIFT 0
#define L1C_RRD_TCP_UDPCSUM_NOK 0x00004000
#define L1C_RRD_IPCSUM_NOK 0x00008000
#define L1C_RRD_VLAN_TAG 0x00010000
#define L1C_RRD_PROTO_MASK 0x000E0000
#define L1C_RRD_PROTO_IPV4 0x00020000
#define L1C_RRD_PROTO_IPV6 0x000C0000
#define L1C_RRD_ERR_SUM 0x00100000
#define L1C_RRD_ERR_CRC 0x00200000
#define L1C_RRD_ERR_ALIGN 0x00400000
#define L1C_RRD_ERR_TRUNC 0x00800000
#define L1C_RRD_ERR_RUNT 0x01000000
#define L1C_RRD_ERR_ICMP 0x02000000
#define L1C_RRD_BCAST 0x04000000
#define L1C_RRD_MCAST 0x08000000
#define L1C_RRD_SNAP_LLC 0x10000000
#define L1C_RRD_ETHER 0x00000000
#define L1C_RRD_FIFO_FULL 0x20000000
#define L1C_RRD_ERR_LENGTH 0x40000000
#define L1C_RRD_VALID 0x80000000
#define L1C_RRD_BYTES(x) \
(((x) & L1C_RRD_LEN_MASK) >> L1C_RRD_LEN_SHIFT)
#define L1C_RRD_IPV4(x) \
(((x) & L1C_RRD_PROTO_MASK) == L1C_RRD_PROTO_IPV4)
#define RRD_PROD_MASK 0x0000FFFF
#define TPD_CONS_MASK 0xFFFF0000
#define TPD_CONS_SHIFT 16
#define CMB_UPDATED 0x00000001
#define RRD_PROD_SHIFT 0
#pragma pack(1)
typedef struct l1c_tx_desc {
uint32_t len;
#define L1C_TD_BUFLEN_MASK 0x00003FFF
#define L1C_TD_VLAN_MASK 0xFFFF0000
#define L1C_TD_BUFLEN_SHIFT 0
#define L1C_TX_BYTES(x) \
(((x) << L1C_TD_BUFLEN_SHIFT) & L1C_TD_BUFLEN_MASK)
#define L1C_TD_VLAN_SHIFT 16
uint32_t flags;
#define L1C_TD_L4HDR_OFFSET_MASK 0x000000FF
#define L1C_TD_TCPHDR_OFFSET_MASK 0x000000FF
#define L1C_TD_PLOAD_OFFSET_MASK 0x000000FF
#define L1C_TD_CUSTOM_CSUM 0x00000100
#define L1C_TD_IPCSUM 0x00000200
#define L1C_TD_TCPCSUM 0x00000400
#define L1C_TD_UDPCSUM 0x00000800
#define L1C_TD_TSO 0x00001000
#define L1C_TD_TSO_DESCV1 0x00000000
#define L1C_TD_TSO_DESCV2 0x00002000
#define L1C_TD_CON_VLAN_TAG 0x00004000
#define L1C_TD_INS_VLAN_TAG 0x00008000
#define L1C_TD_IPV4_DESCV2 0x00010000
#define L1C_TD_LLC_SNAP 0x00020000
#define L1C_TD_ETHERNET 0x00000000
#define L1C_TD_CUSTOM_CSUM_OFFSET_MASK 0x03FC0000
#define L1C_TD_CUSTOM_CSUM_EVEN_PAD 0x40000000
#define L1C_TD_MSS_MASK 0x7FFC0000
#define L1C_TD_EOP 0x80000000
#define L1C_TD_L4HDR_OFFSET_SHIFT 0
#define L1C_TD_TCPHDR_OFFSET_SHIFT 0
#define L1C_TD_PLOAD_OFFSET_SHIFT 0
#define L1C_TD_CUSTOM_CSUM_OFFSET_SHIFT 18
#define L1C_TD_MSS_SHIFT 18
uint64_t addr;
} l1c_tx_desc_t;
#pragma pack()
#define L1C_RSS_IDT_TABLE0 0x14E0
#define L1C_RX_BASE_ADDR_HI 0x1540
#define L1C_TX_BASE_ADDR_HI 0x1544
#define L1C_SMB_BASE_ADDR_HI 0x1548
#define L1C_SMB_BASE_ADDR_LO 0x154C
#define L1C_RD0_HEAD_ADDR_LO 0x1550
#define L1C_RD1_HEAD_ADDR_LO 0x1554
#define L1C_RD2_HEAD_ADDR_LO 0x1558
#define L1C_RD3_HEAD_ADDR_LO 0x155C
#define L1C_RD_RING_CNT 0x1560
#define RD_RING_CNT_MASK 0x00000FFF
#define RD_RING_CNT_SHIFT 0
#define L1C_RX_BUF_SIZE 0x1564
#define RX_BUF_SIZE_MASK 0x0000FFFF
#define RX_BUF_SIZE_MAX 1536
#define L1C_RRD0_HEAD_ADDR_LO 0x1568
#define L1C_RRD1_HEAD_ADDR_LO 0x156C
#define L1C_RRD2_HEAD_ADDR_LO 0x1570
#define L1C_RRD3_HEAD_ADDR_LO 0x1574
#define L1C_RRD_RING_CNT 0x1578
#define RRD_RING_CNT_MASK 0x00000FFF
#define RRD_RING_CNT_SHIFT 0
#define L1C_TDH_HEAD_ADDR_LO 0x157C
#define L1C_TDL_HEAD_ADDR_LO 0x1580
#define L1C_TD_RING_CNT 0x1584
#define TD_RING_CNT_MASK 0x0000FFFF
#define TD_RING_CNT_SHIFT 0
#define L1C_CMB_BASE_ADDR_LO 0x1588
#define L1C_RXQ_CFG 0x15A0
#define RXQ_CFG_ASPM_THROUGHPUT_LIMIT_MASK 0x00000003
#define RXQ_CFG_ASPM_THROUGHPUT_LIMIT_NONE 0x00000000
#define RXQ_CFG_ASPM_THROUGHPUT_LIMIT_1M 0x00000001
#define RXQ_CFG_ASPM_THROUGHPUT_LIMIT_10M 0x00000002
#define RXQ_CFG_ASPM_THROUGHPUT_LIMIT_100M 0x00000003
#define L1C_RSS_CPU 0x15B8
#define PHY_CDTS_STAT_OK 0x0000
#define PHY_CDTS_STAT_SHORT 0x0100
#define PHY_CDTS_STAT_OPEN 0x0200
#define PHY_CDTS_STAT_INVAL 0x0300
#define PHY_CDTS_STAT_MASK 0x0300
#define L1C_CFG_SINGLE_PAUSE_ENB 0x10000000
#define DMA_CFG_RD_ENB 0x00000400
#define DMA_CFG_WR_ENB 0x00000800
#define DMA_CFG_RD_BURST_MASK 0x07
#define DMA_CFG_RD_BURST_SHIFT 4
#define DMA_CFG_WR_BURST_MASK 0x07
#define DMA_CFG_WR_BURST_SHIFT 7
#define DMA_CFG_SMB_DIS 0x01000000
#define L1C_RD_LEN_MASK 0x0000FFFF
#define L1C_RD_LEN_SHIFT 0
#define L1C_SRAM_RD_ADDR 0x1500
#define L1C_SRAM_RD_LEN 0x1504
#define L1C_SRAM_RRD_ADDR 0x1508
#define L1C_SRAM_RRD_LEN 0x150C
#define L1C_SRAM_TPD_ADDR 0x1510
#define L1C_SRAM_TPD_LEN 0x1514
#define L1C_SRAM_TRD_ADDR 0x1518
#define L1C_SRAM_TRD_LEN 0x151C
#define L1C_SRAM_RX_FIFO_ADDR 0x1520
#define L1C_SRAM_RX_FIFO_LEN 0x1524
#define L1C_SRAM_TX_FIFO_ADDR 0x1528
#define L1C_SRAM_TX_FIFO_LEN 0x152C
#define L1C_RXQ_CFG_RD_BURST_MASK 0x03f00000
#define L1C_RXQ_CFG_RD_BURST_SHIFT 20
#define L1C_TXQ_CFG 0x1590
#define TXQ_CFG_TPD_FETCH_THRESH_MASK 0x00003F00
#define L1C_TXQ_CFG_TPD_BURST_DEFAULT 5
#define TXQ_CFG_TPD_FETCH_THRESH_SHIFT 8
#define TXQ_CFG_TPD_FETCH_DEFAULT 16
#define L1C_TXF_WATER_MARK 0x1598
#define TXF_WATER_MARK_HI_MASK 0x00000FFF
#define TXF_WATER_MARK_LO_MASK 0x0FFF0000
#define TXF_WATER_MARK_BURST_ENB 0x80000000
#define TXF_WATER_MARK_LO_SHIFT 0
#define TXF_WATER_MARK_HI_SHIFT 16
#define L1C_RD_DMA_CFG 0x15AC
#define RD_DMA_CFG_THRESH_MASK 0x00000FFF
#define RD_DMA_CFG_TIMER_MASK 0xFFFF0000
#define RD_DMA_CFG_THRESH_SHIFT 0
#define RD_DMA_CFG_TIMER_SHIFT 16
#define RD_DMA_CFG_THRESH_DEFAULT 0x100
#define RD_DMA_CFG_TIMER_DEFAULT 0
#define RD_DMA_CFG_TICK_USECS 8
#define L1C_RD_DMA_CFG_USECS(x) ((x) / RD_DMA_CFG_TICK_USECS)
#define L1C_CMB_WR_THRESH 0x15D4
#define CMB_WR_THRESH_RRD_MASK 0x000007FF
#define CMB_WR_THRESH_TPD_MASK 0x07FF0000
#define CMB_WR_THRESH_RRD_SHIFT 0
#define CMB_WR_THRESH_RRD_DEFAULT 4
#define CMB_WR_THRESH_TPD_SHIFT 16
#define CMB_WR_THRESH_TPD_DEFAULT 4
#define L1C_SMB_TIMER 0x15E4
#define L1C_CSMB_CTRL 0x15D0
#define CSMB_CTRL_CMB_KICK 0x00000001
#define CSMB_CTRL_SMB_KICK 0x00000002
#define CSMB_CTRL_CMB_ENB 0x00000004
#define CSMB_CTRL_SMB_ENB 0x00000008
#define L1C_INTR_SMB 0x00000001
#define L1C_INTR_TIMER 0x00000002
#define L1C_INTR_MANUAL_TIMER 0x00000004
#define L1C_INTR_RX_FIFO_OFLOW 0x00000008
#define L1C_INTR_RD0_UNDERRUN 0x00000010
#define L1C_INTR_RD1_UNDERRUN 0x00000020
#define L1C_INTR_RD2_UNDERRUN 0x00000040
#define L1C_INTR_RD3_UNDERRUN 0x00000080
#define L1C_INTR_TX_FIFO_UNDERRUN 0x00000100
#define L1C_INTR_DMA_RD_TO_RST 0x00000200
#define L1C_INTR_DMA_WR_TO_RST 0x00000400
#define L1C_INTR_TX_CREDIT 0x00000800
#define L1C_INTR_GPHY 0x00001000
#define L1C_INTR_GPHY_LOW_PW 0x00002000
#define L1C_INTR_TXQ_TO_RST 0x00004000
#define L1C_INTR_TX_PKT 0x00008000
#define L1C_INTR_RX_PKT0 0x00010000
#define L1C_INTR_RX_PKT1 0x00020000
#define L1C_INTR_RX_PKT2 0x00040000
#define L1C_INTR_RX_PKT3 0x00080000
#define L1C_INTR_MAC_RX 0x00100000
#define L1C_INTR_MAC_TX 0x00200000
#define L1C_INTR_UNDERRUN 0x00400000
#define L1C_INTR_FRAME_ERROR 0x00800000
#define L1C_INTR_FRAME_OK 0x01000000
#define L1C_INTR_CSUM_ERROR 0x02000000
#define L1C_INTR_PHY_LINK_DOWN 0x04000000
#define L1C_INTR_DIS_INT 0x80000000
#define L1C_INTR_RX_PKT L1C_INTR_RX_PKT0
#define L1C_INTR_RD_UNDERRUN L1C_INTR_RD0_UNDERRUN
#define L1C_INTRS \
(L1C_INTR_DMA_RD_TO_RST | L1C_INTR_DMA_WR_TO_RST | \
L1C_INTR_TXQ_TO_RST| L1C_INTR_RX_PKT | L1C_INTR_TX_PKT | \
L1C_INTR_RX_FIFO_OFLOW | L1C_INTR_RD_UNDERRUN | \
L1C_INTR_TX_FIFO_UNDERRUN)
#define L1C_RXQ_RRD_PAUSE_THRESH 0x15AC
#define RXQ_RRD_PAUSE_THRESH_HI_MASK 0x00000FFF
#define RXQ_RRD_PAUSE_THRESH_LO_MASK 0x0FFF0000
#define RXQ_RRD_PAUSE_THRESH_HI_SHIFT 0
#define RXQ_RRD_PAUSE_THRESH_LO_SHIFT 16
#define L1C_CMB_WR_TIMER 0x15D8
#define CMB_WR_TIMER_RX_MASK 0x0000FFFF
#define CMB_WR_TIMER_TX_MASK 0xFFFF0000
#define CMB_WR_TIMER_RX_SHIFT 0
#define CMB_WR_TIMER_TX_SHIFT 16
#define L1C_RX_NSEGS(x) \
(((x) & L1C_RRD_NSEGS_MASK) >> L1C_RRD_NSEGS_SHIFT)
#define L1C_RX_CONS(x) \
(((x) & L1C_RRD_CONS_MASK) >> L1C_RRD_CONS_SHIFT)
#define L1C_RX_CSUM(x) \
(((x) & L1C_RRD_CSUM_MASK) >> L1C_RRD_CSUM_SHIFT)
#define L1C_RX_BYTES(x) \
(((x) & L1C_RRD_LEN_MASK) >> L1C_RRD_LEN_SHIFT)
#ifdef __cplusplus
}
#endif
#endif