162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Definitions for Marvell PPv2 network controller for Armada 375 SoC. 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (C) 2014 Marvell 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * Marcin Wojtas <mw@semihalf.com> 862306a36Sopenharmony_ci */ 962306a36Sopenharmony_ci#ifndef _MVPP2_H_ 1062306a36Sopenharmony_ci#define _MVPP2_H_ 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#include <linux/interrupt.h> 1362306a36Sopenharmony_ci#include <linux/kernel.h> 1462306a36Sopenharmony_ci#include <linux/netdevice.h> 1562306a36Sopenharmony_ci#include <linux/net_tstamp.h> 1662306a36Sopenharmony_ci#include <linux/phy.h> 1762306a36Sopenharmony_ci#include <linux/phylink.h> 1862306a36Sopenharmony_ci#include <net/flow_offload.h> 1962306a36Sopenharmony_ci#include <net/page_pool/types.h> 2062306a36Sopenharmony_ci#include <linux/bpf.h> 2162306a36Sopenharmony_ci#include <net/xdp.h> 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci/* The PacketOffset field is measured in units of 32 bytes and is 3 bits wide, 2462306a36Sopenharmony_ci * so the maximum offset is 7 * 32 = 224 2562306a36Sopenharmony_ci */ 2662306a36Sopenharmony_ci#define MVPP2_SKB_HEADROOM min(max(XDP_PACKET_HEADROOM, NET_SKB_PAD), 224) 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci#define MVPP2_XDP_PASS 0 2962306a36Sopenharmony_ci#define MVPP2_XDP_DROPPED BIT(0) 3062306a36Sopenharmony_ci#define MVPP2_XDP_TX BIT(1) 3162306a36Sopenharmony_ci#define MVPP2_XDP_REDIR BIT(2) 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci/* Fifo Registers */ 3462306a36Sopenharmony_ci#define MVPP2_RX_DATA_FIFO_SIZE_REG(port) (0x00 + 4 * (port)) 3562306a36Sopenharmony_ci#define MVPP2_RX_ATTR_FIFO_SIZE_REG(port) (0x20 + 4 * (port)) 3662306a36Sopenharmony_ci#define MVPP2_RX_MIN_PKT_SIZE_REG 0x60 3762306a36Sopenharmony_ci#define MVPP2_RX_FIFO_INIT_REG 0x64 3862306a36Sopenharmony_ci#define MVPP22_TX_FIFO_THRESH_REG(port) (0x8840 + 4 * (port)) 3962306a36Sopenharmony_ci#define MVPP22_TX_FIFO_SIZE_REG(port) (0x8860 + 4 * (port)) 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci/* RX DMA Top Registers */ 4262306a36Sopenharmony_ci#define MVPP2_RX_CTRL_REG(port) (0x140 + 4 * (port)) 4362306a36Sopenharmony_ci#define MVPP2_RX_LOW_LATENCY_PKT_SIZE(s) (((s) & 0xfff) << 16) 4462306a36Sopenharmony_ci#define MVPP2_RX_USE_PSEUDO_FOR_CSUM_MASK BIT(31) 4562306a36Sopenharmony_ci#define MVPP2_POOL_BUF_SIZE_REG(pool) (0x180 + 4 * (pool)) 4662306a36Sopenharmony_ci#define MVPP2_POOL_BUF_SIZE_OFFSET 5 4762306a36Sopenharmony_ci#define MVPP2_RXQ_CONFIG_REG(rxq) (0x800 + 4 * (rxq)) 4862306a36Sopenharmony_ci#define MVPP2_SNOOP_PKT_SIZE_MASK 0x1ff 4962306a36Sopenharmony_ci#define MVPP2_SNOOP_BUF_HDR_MASK BIT(9) 5062306a36Sopenharmony_ci#define MVPP2_RXQ_POOL_SHORT_OFFS 20 5162306a36Sopenharmony_ci#define MVPP21_RXQ_POOL_SHORT_MASK 0x700000 5262306a36Sopenharmony_ci#define MVPP22_RXQ_POOL_SHORT_MASK 0xf00000 5362306a36Sopenharmony_ci#define MVPP2_RXQ_POOL_LONG_OFFS 24 5462306a36Sopenharmony_ci#define MVPP21_RXQ_POOL_LONG_MASK 0x7000000 5562306a36Sopenharmony_ci#define MVPP22_RXQ_POOL_LONG_MASK 0xf000000 5662306a36Sopenharmony_ci#define MVPP2_RXQ_PACKET_OFFSET_OFFS 28 5762306a36Sopenharmony_ci#define MVPP2_RXQ_PACKET_OFFSET_MASK 0x70000000 5862306a36Sopenharmony_ci#define MVPP2_RXQ_DISABLE_MASK BIT(31) 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci/* Top Registers */ 6162306a36Sopenharmony_ci#define MVPP2_MH_REG(port) (0x5040 + 4 * (port)) 6262306a36Sopenharmony_ci#define MVPP2_DSA_EXTENDED BIT(5) 6362306a36Sopenharmony_ci#define MVPP2_VER_ID_REG 0x50b0 6462306a36Sopenharmony_ci#define MVPP2_VER_PP22 0x10 6562306a36Sopenharmony_ci#define MVPP2_VER_PP23 0x11 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci/* Parser Registers */ 6862306a36Sopenharmony_ci#define MVPP2_PRS_INIT_LOOKUP_REG 0x1000 6962306a36Sopenharmony_ci#define MVPP2_PRS_PORT_LU_MAX 0xf 7062306a36Sopenharmony_ci#define MVPP2_PRS_PORT_LU_MASK(port) (0xff << ((port) * 4)) 7162306a36Sopenharmony_ci#define MVPP2_PRS_PORT_LU_VAL(port, val) ((val) << ((port) * 4)) 7262306a36Sopenharmony_ci#define MVPP2_PRS_INIT_OFFS_REG(port) (0x1004 + ((port) & 4)) 7362306a36Sopenharmony_ci#define MVPP2_PRS_INIT_OFF_MASK(port) (0x3f << (((port) % 4) * 8)) 7462306a36Sopenharmony_ci#define MVPP2_PRS_INIT_OFF_VAL(port, val) ((val) << (((port) % 4) * 8)) 7562306a36Sopenharmony_ci#define MVPP2_PRS_MAX_LOOP_REG(port) (0x100c + ((port) & 4)) 7662306a36Sopenharmony_ci#define MVPP2_PRS_MAX_LOOP_MASK(port) (0xff << (((port) % 4) * 8)) 7762306a36Sopenharmony_ci#define MVPP2_PRS_MAX_LOOP_VAL(port, val) ((val) << (((port) % 4) * 8)) 7862306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_IDX_REG 0x1100 7962306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_DATA_REG(idx) (0x1104 + (idx) * 4) 8062306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_INV_MASK BIT(31) 8162306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_IDX_REG 0x1200 8262306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_DATA_REG(idx) (0x1204 + (idx) * 4) 8362306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_CTRL_REG 0x1230 8462306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_EN_MASK BIT(0) 8562306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_HIT_IDX_REG 0x1240 8662306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_HIT_CNT_REG 0x1244 8762306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_HIT_CNT_MASK GENMASK(15, 0) 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci/* RSS Registers */ 9062306a36Sopenharmony_ci#define MVPP22_RSS_INDEX 0x1500 9162306a36Sopenharmony_ci#define MVPP22_RSS_INDEX_TABLE_ENTRY(idx) (idx) 9262306a36Sopenharmony_ci#define MVPP22_RSS_INDEX_TABLE(idx) ((idx) << 8) 9362306a36Sopenharmony_ci#define MVPP22_RSS_INDEX_QUEUE(idx) ((idx) << 16) 9462306a36Sopenharmony_ci#define MVPP22_RXQ2RSS_TABLE 0x1504 9562306a36Sopenharmony_ci#define MVPP22_RSS_TABLE_POINTER(p) (p) 9662306a36Sopenharmony_ci#define MVPP22_RSS_TABLE_ENTRY 0x1508 9762306a36Sopenharmony_ci#define MVPP22_RSS_WIDTH 0x150c 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_ci/* Classifier Registers */ 10062306a36Sopenharmony_ci#define MVPP2_CLS_MODE_REG 0x1800 10162306a36Sopenharmony_ci#define MVPP2_CLS_MODE_ACTIVE_MASK BIT(0) 10262306a36Sopenharmony_ci#define MVPP2_CLS_PORT_WAY_REG 0x1810 10362306a36Sopenharmony_ci#define MVPP2_CLS_PORT_WAY_MASK(port) (1 << (port)) 10462306a36Sopenharmony_ci#define MVPP2_CLS_LKP_INDEX_REG 0x1814 10562306a36Sopenharmony_ci#define MVPP2_CLS_LKP_INDEX_WAY_OFFS 6 10662306a36Sopenharmony_ci#define MVPP2_CLS_LKP_TBL_REG 0x1818 10762306a36Sopenharmony_ci#define MVPP2_CLS_LKP_TBL_RXQ_MASK 0xff 10862306a36Sopenharmony_ci#define MVPP2_CLS_LKP_FLOW_PTR(flow) ((flow) << 16) 10962306a36Sopenharmony_ci#define MVPP2_CLS_LKP_TBL_LOOKUP_EN_MASK BIT(25) 11062306a36Sopenharmony_ci#define MVPP2_CLS_FLOW_INDEX_REG 0x1820 11162306a36Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL0_REG 0x1824 11262306a36Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL0_LAST BIT(0) 11362306a36Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL0_ENG_MASK 0x7 11462306a36Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL0_OFFS 1 11562306a36Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL0_ENG(x) ((x) << 1) 11662306a36Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL0_PORT_ID_MASK 0xff 11762306a36Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL0_PORT_ID(port) ((port) << 4) 11862306a36Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL0_PORT_ID_SEL BIT(23) 11962306a36Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL1_REG 0x1828 12062306a36Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL1_N_FIELDS_MASK 0x7 12162306a36Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL1_N_FIELDS(x) (x) 12262306a36Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL1_LU_TYPE(lu) (((lu) & 0x3f) << 3) 12362306a36Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL1_PRIO_MASK 0x3f 12462306a36Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL1_PRIO(x) ((x) << 9) 12562306a36Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL1_SEQ_MASK 0x7 12662306a36Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL1_SEQ(x) ((x) << 15) 12762306a36Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL2_REG 0x182c 12862306a36Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL2_FLD_MASK 0x3f 12962306a36Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL2_FLD_OFFS(n) ((n) * 6) 13062306a36Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL2_FLD(n, x) ((x) << ((n) * 6)) 13162306a36Sopenharmony_ci#define MVPP2_CLS_OVERSIZE_RXQ_LOW_REG(port) (0x1980 + ((port) * 4)) 13262306a36Sopenharmony_ci#define MVPP2_CLS_OVERSIZE_RXQ_LOW_BITS 3 13362306a36Sopenharmony_ci#define MVPP2_CLS_OVERSIZE_RXQ_LOW_MASK 0x7 13462306a36Sopenharmony_ci#define MVPP2_CLS_SWFWD_P2HQ_REG(port) (0x19b0 + ((port) * 4)) 13562306a36Sopenharmony_ci#define MVPP2_CLS_SWFWD_PCTRL_REG 0x19d0 13662306a36Sopenharmony_ci#define MVPP2_CLS_SWFWD_PCTRL_MASK(port) (1 << (port)) 13762306a36Sopenharmony_ci 13862306a36Sopenharmony_ci/* Classifier C2 engine Registers */ 13962306a36Sopenharmony_ci#define MVPP22_CLS_C2_TCAM_IDX 0x1b00 14062306a36Sopenharmony_ci#define MVPP22_CLS_C2_TCAM_DATA0 0x1b10 14162306a36Sopenharmony_ci#define MVPP22_CLS_C2_TCAM_DATA1 0x1b14 14262306a36Sopenharmony_ci#define MVPP22_CLS_C2_TCAM_DATA2 0x1b18 14362306a36Sopenharmony_ci#define MVPP22_CLS_C2_TCAM_DATA3 0x1b1c 14462306a36Sopenharmony_ci#define MVPP22_CLS_C2_TCAM_DATA4 0x1b20 14562306a36Sopenharmony_ci#define MVPP22_CLS_C2_LU_TYPE(lu) ((lu) & 0x3f) 14662306a36Sopenharmony_ci#define MVPP22_CLS_C2_PORT_ID(port) ((port) << 8) 14762306a36Sopenharmony_ci#define MVPP22_CLS_C2_PORT_MASK (0xff << 8) 14862306a36Sopenharmony_ci#define MVPP22_CLS_C2_TCAM_INV 0x1b24 14962306a36Sopenharmony_ci#define MVPP22_CLS_C2_TCAM_INV_BIT BIT(31) 15062306a36Sopenharmony_ci#define MVPP22_CLS_C2_HIT_CTR 0x1b50 15162306a36Sopenharmony_ci#define MVPP22_CLS_C2_ACT 0x1b60 15262306a36Sopenharmony_ci#define MVPP22_CLS_C2_ACT_RSS_EN(act) (((act) & 0x3) << 19) 15362306a36Sopenharmony_ci#define MVPP22_CLS_C2_ACT_FWD(act) (((act) & 0x7) << 13) 15462306a36Sopenharmony_ci#define MVPP22_CLS_C2_ACT_QHIGH(act) (((act) & 0x3) << 11) 15562306a36Sopenharmony_ci#define MVPP22_CLS_C2_ACT_QLOW(act) (((act) & 0x3) << 9) 15662306a36Sopenharmony_ci#define MVPP22_CLS_C2_ACT_COLOR(act) ((act) & 0x7) 15762306a36Sopenharmony_ci#define MVPP22_CLS_C2_ATTR0 0x1b64 15862306a36Sopenharmony_ci#define MVPP22_CLS_C2_ATTR0_QHIGH(qh) (((qh) & 0x1f) << 24) 15962306a36Sopenharmony_ci#define MVPP22_CLS_C2_ATTR0_QHIGH_MASK 0x1f 16062306a36Sopenharmony_ci#define MVPP22_CLS_C2_ATTR0_QHIGH_OFFS 24 16162306a36Sopenharmony_ci#define MVPP22_CLS_C2_ATTR0_QLOW(ql) (((ql) & 0x7) << 21) 16262306a36Sopenharmony_ci#define MVPP22_CLS_C2_ATTR0_QLOW_MASK 0x7 16362306a36Sopenharmony_ci#define MVPP22_CLS_C2_ATTR0_QLOW_OFFS 21 16462306a36Sopenharmony_ci#define MVPP22_CLS_C2_ATTR1 0x1b68 16562306a36Sopenharmony_ci#define MVPP22_CLS_C2_ATTR2 0x1b6c 16662306a36Sopenharmony_ci#define MVPP22_CLS_C2_ATTR2_RSS_EN BIT(30) 16762306a36Sopenharmony_ci#define MVPP22_CLS_C2_ATTR3 0x1b70 16862306a36Sopenharmony_ci#define MVPP22_CLS_C2_TCAM_CTRL 0x1b90 16962306a36Sopenharmony_ci#define MVPP22_CLS_C2_TCAM_BYPASS_FIFO BIT(0) 17062306a36Sopenharmony_ci 17162306a36Sopenharmony_ci/* Descriptor Manager Top Registers */ 17262306a36Sopenharmony_ci#define MVPP2_RXQ_NUM_REG 0x2040 17362306a36Sopenharmony_ci#define MVPP2_RXQ_DESC_ADDR_REG 0x2044 17462306a36Sopenharmony_ci#define MVPP22_DESC_ADDR_OFFS 8 17562306a36Sopenharmony_ci#define MVPP2_RXQ_DESC_SIZE_REG 0x2048 17662306a36Sopenharmony_ci#define MVPP2_RXQ_DESC_SIZE_MASK 0x3ff0 17762306a36Sopenharmony_ci#define MVPP2_RXQ_STATUS_UPDATE_REG(rxq) (0x3000 + 4 * (rxq)) 17862306a36Sopenharmony_ci#define MVPP2_RXQ_NUM_PROCESSED_OFFSET 0 17962306a36Sopenharmony_ci#define MVPP2_RXQ_NUM_NEW_OFFSET 16 18062306a36Sopenharmony_ci#define MVPP2_RXQ_STATUS_REG(rxq) (0x3400 + 4 * (rxq)) 18162306a36Sopenharmony_ci#define MVPP2_RXQ_OCCUPIED_MASK 0x3fff 18262306a36Sopenharmony_ci#define MVPP2_RXQ_NON_OCCUPIED_OFFSET 16 18362306a36Sopenharmony_ci#define MVPP2_RXQ_NON_OCCUPIED_MASK 0x3fff0000 18462306a36Sopenharmony_ci#define MVPP2_RXQ_THRESH_REG 0x204c 18562306a36Sopenharmony_ci#define MVPP2_OCCUPIED_THRESH_OFFSET 0 18662306a36Sopenharmony_ci#define MVPP2_OCCUPIED_THRESH_MASK 0x3fff 18762306a36Sopenharmony_ci#define MVPP2_RXQ_INDEX_REG 0x2050 18862306a36Sopenharmony_ci#define MVPP2_TXQ_NUM_REG 0x2080 18962306a36Sopenharmony_ci#define MVPP2_TXQ_DESC_ADDR_REG 0x2084 19062306a36Sopenharmony_ci#define MVPP2_TXQ_DESC_SIZE_REG 0x2088 19162306a36Sopenharmony_ci#define MVPP2_TXQ_DESC_SIZE_MASK 0x3ff0 19262306a36Sopenharmony_ci#define MVPP2_TXQ_THRESH_REG 0x2094 19362306a36Sopenharmony_ci#define MVPP2_TXQ_THRESH_OFFSET 16 19462306a36Sopenharmony_ci#define MVPP2_TXQ_THRESH_MASK 0x3fff 19562306a36Sopenharmony_ci#define MVPP2_AGGR_TXQ_UPDATE_REG 0x2090 19662306a36Sopenharmony_ci#define MVPP2_TXQ_INDEX_REG 0x2098 19762306a36Sopenharmony_ci#define MVPP2_TXQ_PREF_BUF_REG 0x209c 19862306a36Sopenharmony_ci#define MVPP2_PREF_BUF_PTR(desc) ((desc) & 0xfff) 19962306a36Sopenharmony_ci#define MVPP2_PREF_BUF_SIZE_4 (BIT(12) | BIT(13)) 20062306a36Sopenharmony_ci#define MVPP2_PREF_BUF_SIZE_16 (BIT(12) | BIT(14)) 20162306a36Sopenharmony_ci#define MVPP2_PREF_BUF_THRESH(val) ((val) << 17) 20262306a36Sopenharmony_ci#define MVPP2_TXQ_DRAIN_EN_MASK BIT(31) 20362306a36Sopenharmony_ci#define MVPP2_TXQ_PENDING_REG 0x20a0 20462306a36Sopenharmony_ci#define MVPP2_TXQ_PENDING_MASK 0x3fff 20562306a36Sopenharmony_ci#define MVPP2_TXQ_INT_STATUS_REG 0x20a4 20662306a36Sopenharmony_ci#define MVPP2_TXQ_SENT_REG(txq) (0x3c00 + 4 * (txq)) 20762306a36Sopenharmony_ci#define MVPP2_TRANSMITTED_COUNT_OFFSET 16 20862306a36Sopenharmony_ci#define MVPP2_TRANSMITTED_COUNT_MASK 0x3fff0000 20962306a36Sopenharmony_ci#define MVPP2_TXQ_RSVD_REQ_REG 0x20b0 21062306a36Sopenharmony_ci#define MVPP2_TXQ_RSVD_REQ_Q_OFFSET 16 21162306a36Sopenharmony_ci#define MVPP2_TXQ_RSVD_RSLT_REG 0x20b4 21262306a36Sopenharmony_ci#define MVPP2_TXQ_RSVD_RSLT_MASK 0x3fff 21362306a36Sopenharmony_ci#define MVPP2_TXQ_RSVD_CLR_REG 0x20b8 21462306a36Sopenharmony_ci#define MVPP2_TXQ_RSVD_CLR_OFFSET 16 21562306a36Sopenharmony_ci#define MVPP2_AGGR_TXQ_DESC_ADDR_REG(cpu) (0x2100 + 4 * (cpu)) 21662306a36Sopenharmony_ci#define MVPP22_AGGR_TXQ_DESC_ADDR_OFFS 8 21762306a36Sopenharmony_ci#define MVPP2_AGGR_TXQ_DESC_SIZE_REG(cpu) (0x2140 + 4 * (cpu)) 21862306a36Sopenharmony_ci#define MVPP2_AGGR_TXQ_DESC_SIZE_MASK 0x3ff0 21962306a36Sopenharmony_ci#define MVPP2_AGGR_TXQ_STATUS_REG(cpu) (0x2180 + 4 * (cpu)) 22062306a36Sopenharmony_ci#define MVPP2_AGGR_TXQ_PENDING_MASK 0x3fff 22162306a36Sopenharmony_ci#define MVPP2_AGGR_TXQ_INDEX_REG(cpu) (0x21c0 + 4 * (cpu)) 22262306a36Sopenharmony_ci 22362306a36Sopenharmony_ci/* MBUS bridge registers */ 22462306a36Sopenharmony_ci#define MVPP2_WIN_BASE(w) (0x4000 + ((w) << 2)) 22562306a36Sopenharmony_ci#define MVPP2_WIN_SIZE(w) (0x4020 + ((w) << 2)) 22662306a36Sopenharmony_ci#define MVPP2_WIN_REMAP(w) (0x4040 + ((w) << 2)) 22762306a36Sopenharmony_ci#define MVPP2_BASE_ADDR_ENABLE 0x4060 22862306a36Sopenharmony_ci 22962306a36Sopenharmony_ci/* AXI Bridge Registers */ 23062306a36Sopenharmony_ci#define MVPP22_AXI_BM_WR_ATTR_REG 0x4100 23162306a36Sopenharmony_ci#define MVPP22_AXI_BM_RD_ATTR_REG 0x4104 23262306a36Sopenharmony_ci#define MVPP22_AXI_AGGRQ_DESCR_RD_ATTR_REG 0x4110 23362306a36Sopenharmony_ci#define MVPP22_AXI_TXQ_DESCR_WR_ATTR_REG 0x4114 23462306a36Sopenharmony_ci#define MVPP22_AXI_TXQ_DESCR_RD_ATTR_REG 0x4118 23562306a36Sopenharmony_ci#define MVPP22_AXI_RXQ_DESCR_WR_ATTR_REG 0x411c 23662306a36Sopenharmony_ci#define MVPP22_AXI_RX_DATA_WR_ATTR_REG 0x4120 23762306a36Sopenharmony_ci#define MVPP22_AXI_TX_DATA_RD_ATTR_REG 0x4130 23862306a36Sopenharmony_ci#define MVPP22_AXI_RD_NORMAL_CODE_REG 0x4150 23962306a36Sopenharmony_ci#define MVPP22_AXI_RD_SNOOP_CODE_REG 0x4154 24062306a36Sopenharmony_ci#define MVPP22_AXI_WR_NORMAL_CODE_REG 0x4160 24162306a36Sopenharmony_ci#define MVPP22_AXI_WR_SNOOP_CODE_REG 0x4164 24262306a36Sopenharmony_ci 24362306a36Sopenharmony_ci/* Values for AXI Bridge registers */ 24462306a36Sopenharmony_ci#define MVPP22_AXI_ATTR_CACHE_OFFS 0 24562306a36Sopenharmony_ci#define MVPP22_AXI_ATTR_DOMAIN_OFFS 12 24662306a36Sopenharmony_ci 24762306a36Sopenharmony_ci#define MVPP22_AXI_CODE_CACHE_OFFS 0 24862306a36Sopenharmony_ci#define MVPP22_AXI_CODE_DOMAIN_OFFS 4 24962306a36Sopenharmony_ci 25062306a36Sopenharmony_ci#define MVPP22_AXI_CODE_CACHE_NON_CACHE 0x3 25162306a36Sopenharmony_ci#define MVPP22_AXI_CODE_CACHE_WR_CACHE 0x7 25262306a36Sopenharmony_ci#define MVPP22_AXI_CODE_CACHE_RD_CACHE 0xb 25362306a36Sopenharmony_ci 25462306a36Sopenharmony_ci#define MVPP22_AXI_CODE_DOMAIN_OUTER_DOM 2 25562306a36Sopenharmony_ci#define MVPP22_AXI_CODE_DOMAIN_SYSTEM 3 25662306a36Sopenharmony_ci 25762306a36Sopenharmony_ci/* Interrupt Cause and Mask registers */ 25862306a36Sopenharmony_ci#define MVPP2_ISR_TX_THRESHOLD_REG(port) (0x5140 + 4 * (port)) 25962306a36Sopenharmony_ci#define MVPP2_MAX_ISR_TX_THRESHOLD 0xfffff0 26062306a36Sopenharmony_ci 26162306a36Sopenharmony_ci#define MVPP2_ISR_RX_THRESHOLD_REG(rxq) (0x5200 + 4 * (rxq)) 26262306a36Sopenharmony_ci#define MVPP2_MAX_ISR_RX_THRESHOLD 0xfffff0 26362306a36Sopenharmony_ci#define MVPP21_ISR_RXQ_GROUP_REG(port) (0x5400 + 4 * (port)) 26462306a36Sopenharmony_ci 26562306a36Sopenharmony_ci#define MVPP22_ISR_RXQ_GROUP_INDEX_REG 0x5400 26662306a36Sopenharmony_ci#define MVPP22_ISR_RXQ_GROUP_INDEX_SUBGROUP_MASK 0xf 26762306a36Sopenharmony_ci#define MVPP22_ISR_RXQ_GROUP_INDEX_GROUP_MASK 0x380 26862306a36Sopenharmony_ci#define MVPP22_ISR_RXQ_GROUP_INDEX_GROUP_OFFSET 7 26962306a36Sopenharmony_ci 27062306a36Sopenharmony_ci#define MVPP22_ISR_RXQ_GROUP_INDEX_SUBGROUP_MASK 0xf 27162306a36Sopenharmony_ci#define MVPP22_ISR_RXQ_GROUP_INDEX_GROUP_MASK 0x380 27262306a36Sopenharmony_ci 27362306a36Sopenharmony_ci#define MVPP22_ISR_RXQ_SUB_GROUP_CONFIG_REG 0x5404 27462306a36Sopenharmony_ci#define MVPP22_ISR_RXQ_SUB_GROUP_STARTQ_MASK 0x1f 27562306a36Sopenharmony_ci#define MVPP22_ISR_RXQ_SUB_GROUP_SIZE_MASK 0xf00 27662306a36Sopenharmony_ci#define MVPP22_ISR_RXQ_SUB_GROUP_SIZE_OFFSET 8 27762306a36Sopenharmony_ci 27862306a36Sopenharmony_ci#define MVPP2_ISR_ENABLE_REG(port) (0x5420 + 4 * (port)) 27962306a36Sopenharmony_ci#define MVPP2_ISR_ENABLE_INTERRUPT(mask) ((mask) & 0xffff) 28062306a36Sopenharmony_ci#define MVPP2_ISR_DISABLE_INTERRUPT(mask) (((mask) << 16) & 0xffff0000) 28162306a36Sopenharmony_ci#define MVPP2_ISR_RX_TX_CAUSE_REG(port) (0x5480 + 4 * (port)) 28262306a36Sopenharmony_ci#define MVPP2_CAUSE_RXQ_OCCUP_DESC_ALL_MASK(version) \ 28362306a36Sopenharmony_ci ((version) == MVPP21 ? 0xffff : 0xff) 28462306a36Sopenharmony_ci#define MVPP2_CAUSE_TXQ_OCCUP_DESC_ALL_MASK 0xff0000 28562306a36Sopenharmony_ci#define MVPP2_CAUSE_TXQ_OCCUP_DESC_ALL_OFFSET 16 28662306a36Sopenharmony_ci#define MVPP2_CAUSE_RX_FIFO_OVERRUN_MASK BIT(24) 28762306a36Sopenharmony_ci#define MVPP2_CAUSE_FCS_ERR_MASK BIT(25) 28862306a36Sopenharmony_ci#define MVPP2_CAUSE_TX_FIFO_UNDERRUN_MASK BIT(26) 28962306a36Sopenharmony_ci#define MVPP2_CAUSE_TX_EXCEPTION_SUM_MASK BIT(29) 29062306a36Sopenharmony_ci#define MVPP2_CAUSE_RX_EXCEPTION_SUM_MASK BIT(30) 29162306a36Sopenharmony_ci#define MVPP2_CAUSE_MISC_SUM_MASK BIT(31) 29262306a36Sopenharmony_ci#define MVPP2_ISR_RX_TX_MASK_REG(port) (0x54a0 + 4 * (port)) 29362306a36Sopenharmony_ci#define MVPP2_ISR_PON_RX_TX_MASK_REG 0x54bc 29462306a36Sopenharmony_ci#define MVPP2_PON_CAUSE_RXQ_OCCUP_DESC_ALL_MASK 0xffff 29562306a36Sopenharmony_ci#define MVPP2_PON_CAUSE_TXP_OCCUP_DESC_ALL_MASK 0x3fc00000 29662306a36Sopenharmony_ci#define MVPP2_PON_CAUSE_MISC_SUM_MASK BIT(31) 29762306a36Sopenharmony_ci#define MVPP2_ISR_MISC_CAUSE_REG 0x55b0 29862306a36Sopenharmony_ci#define MVPP2_ISR_RX_ERR_CAUSE_REG(port) (0x5520 + 4 * (port)) 29962306a36Sopenharmony_ci#define MVPP2_ISR_RX_ERR_CAUSE_NONOCC_MASK 0x00ff 30062306a36Sopenharmony_ci 30162306a36Sopenharmony_ci/* Buffer Manager registers */ 30262306a36Sopenharmony_ci#define MVPP2_BM_POOL_BASE_REG(pool) (0x6000 + ((pool) * 4)) 30362306a36Sopenharmony_ci#define MVPP2_BM_POOL_BASE_ADDR_MASK 0xfffff80 30462306a36Sopenharmony_ci#define MVPP2_BM_POOL_SIZE_REG(pool) (0x6040 + ((pool) * 4)) 30562306a36Sopenharmony_ci#define MVPP2_BM_POOL_SIZE_MASK 0xfff0 30662306a36Sopenharmony_ci#define MVPP2_BM_POOL_READ_PTR_REG(pool) (0x6080 + ((pool) * 4)) 30762306a36Sopenharmony_ci#define MVPP2_BM_POOL_GET_READ_PTR_MASK 0xfff0 30862306a36Sopenharmony_ci#define MVPP2_BM_POOL_PTRS_NUM_REG(pool) (0x60c0 + ((pool) * 4)) 30962306a36Sopenharmony_ci#define MVPP2_BM_POOL_PTRS_NUM_MASK 0xfff0 31062306a36Sopenharmony_ci#define MVPP2_BM_BPPI_READ_PTR_REG(pool) (0x6100 + ((pool) * 4)) 31162306a36Sopenharmony_ci#define MVPP2_BM_BPPI_PTRS_NUM_REG(pool) (0x6140 + ((pool) * 4)) 31262306a36Sopenharmony_ci#define MVPP2_BM_BPPI_PTR_NUM_MASK 0x7ff 31362306a36Sopenharmony_ci#define MVPP22_BM_POOL_PTRS_NUM_MASK 0xfff8 31462306a36Sopenharmony_ci#define MVPP2_BM_BPPI_PREFETCH_FULL_MASK BIT(16) 31562306a36Sopenharmony_ci#define MVPP2_BM_POOL_CTRL_REG(pool) (0x6200 + ((pool) * 4)) 31662306a36Sopenharmony_ci#define MVPP2_BM_START_MASK BIT(0) 31762306a36Sopenharmony_ci#define MVPP2_BM_STOP_MASK BIT(1) 31862306a36Sopenharmony_ci#define MVPP2_BM_STATE_MASK BIT(4) 31962306a36Sopenharmony_ci#define MVPP2_BM_LOW_THRESH_OFFS 8 32062306a36Sopenharmony_ci#define MVPP2_BM_LOW_THRESH_MASK 0x7f00 32162306a36Sopenharmony_ci#define MVPP2_BM_LOW_THRESH_VALUE(val) ((val) << \ 32262306a36Sopenharmony_ci MVPP2_BM_LOW_THRESH_OFFS) 32362306a36Sopenharmony_ci#define MVPP2_BM_HIGH_THRESH_OFFS 16 32462306a36Sopenharmony_ci#define MVPP2_BM_HIGH_THRESH_MASK 0x7f0000 32562306a36Sopenharmony_ci#define MVPP2_BM_HIGH_THRESH_VALUE(val) ((val) << \ 32662306a36Sopenharmony_ci MVPP2_BM_HIGH_THRESH_OFFS) 32762306a36Sopenharmony_ci#define MVPP2_BM_BPPI_HIGH_THRESH 0x1E 32862306a36Sopenharmony_ci#define MVPP2_BM_BPPI_LOW_THRESH 0x1C 32962306a36Sopenharmony_ci#define MVPP23_BM_BPPI_HIGH_THRESH 0x34 33062306a36Sopenharmony_ci#define MVPP23_BM_BPPI_LOW_THRESH 0x28 33162306a36Sopenharmony_ci#define MVPP2_BM_INTR_CAUSE_REG(pool) (0x6240 + ((pool) * 4)) 33262306a36Sopenharmony_ci#define MVPP2_BM_RELEASED_DELAY_MASK BIT(0) 33362306a36Sopenharmony_ci#define MVPP2_BM_ALLOC_FAILED_MASK BIT(1) 33462306a36Sopenharmony_ci#define MVPP2_BM_BPPE_EMPTY_MASK BIT(2) 33562306a36Sopenharmony_ci#define MVPP2_BM_BPPE_FULL_MASK BIT(3) 33662306a36Sopenharmony_ci#define MVPP2_BM_AVAILABLE_BP_LOW_MASK BIT(4) 33762306a36Sopenharmony_ci#define MVPP2_BM_INTR_MASK_REG(pool) (0x6280 + ((pool) * 4)) 33862306a36Sopenharmony_ci#define MVPP2_BM_PHY_ALLOC_REG(pool) (0x6400 + ((pool) * 4)) 33962306a36Sopenharmony_ci#define MVPP2_BM_PHY_ALLOC_GRNTD_MASK BIT(0) 34062306a36Sopenharmony_ci#define MVPP2_BM_VIRT_ALLOC_REG 0x6440 34162306a36Sopenharmony_ci#define MVPP22_BM_ADDR_HIGH_ALLOC 0x6444 34262306a36Sopenharmony_ci#define MVPP22_BM_ADDR_HIGH_PHYS_MASK 0xff 34362306a36Sopenharmony_ci#define MVPP22_BM_ADDR_HIGH_VIRT_MASK 0xff00 34462306a36Sopenharmony_ci#define MVPP22_BM_ADDR_HIGH_VIRT_SHIFT 8 34562306a36Sopenharmony_ci#define MVPP2_BM_PHY_RLS_REG(pool) (0x6480 + ((pool) * 4)) 34662306a36Sopenharmony_ci#define MVPP2_BM_PHY_RLS_MC_BUFF_MASK BIT(0) 34762306a36Sopenharmony_ci#define MVPP2_BM_PHY_RLS_PRIO_EN_MASK BIT(1) 34862306a36Sopenharmony_ci#define MVPP2_BM_PHY_RLS_GRNTD_MASK BIT(2) 34962306a36Sopenharmony_ci#define MVPP2_BM_VIRT_RLS_REG 0x64c0 35062306a36Sopenharmony_ci#define MVPP22_BM_ADDR_HIGH_RLS_REG 0x64c4 35162306a36Sopenharmony_ci#define MVPP22_BM_ADDR_HIGH_PHYS_RLS_MASK 0xff 35262306a36Sopenharmony_ci#define MVPP22_BM_ADDR_HIGH_VIRT_RLS_MASK 0xff00 35362306a36Sopenharmony_ci#define MVPP22_BM_ADDR_HIGH_VIRT_RLS_SHIFT 8 35462306a36Sopenharmony_ci 35562306a36Sopenharmony_ci/* Packet Processor per-port counters */ 35662306a36Sopenharmony_ci#define MVPP2_OVERRUN_ETH_DROP 0x7000 35762306a36Sopenharmony_ci#define MVPP2_CLS_ETH_DROP 0x7020 35862306a36Sopenharmony_ci 35962306a36Sopenharmony_ci#define MVPP22_BM_POOL_BASE_ADDR_HIGH_REG 0x6310 36062306a36Sopenharmony_ci#define MVPP22_BM_POOL_BASE_ADDR_HIGH_MASK 0xff 36162306a36Sopenharmony_ci#define MVPP23_BM_8POOL_MODE BIT(8) 36262306a36Sopenharmony_ci 36362306a36Sopenharmony_ci/* Hit counters registers */ 36462306a36Sopenharmony_ci#define MVPP2_CTRS_IDX 0x7040 36562306a36Sopenharmony_ci#define MVPP22_CTRS_TX_CTR(port, txq) ((txq) | ((port) << 3) | BIT(7)) 36662306a36Sopenharmony_ci#define MVPP2_TX_DESC_ENQ_CTR 0x7100 36762306a36Sopenharmony_ci#define MVPP2_TX_DESC_ENQ_TO_DDR_CTR 0x7104 36862306a36Sopenharmony_ci#define MVPP2_TX_BUFF_ENQ_TO_DDR_CTR 0x7108 36962306a36Sopenharmony_ci#define MVPP2_TX_DESC_ENQ_HW_FWD_CTR 0x710c 37062306a36Sopenharmony_ci#define MVPP2_RX_DESC_ENQ_CTR 0x7120 37162306a36Sopenharmony_ci#define MVPP2_TX_PKTS_DEQ_CTR 0x7130 37262306a36Sopenharmony_ci#define MVPP2_TX_PKTS_FULL_QUEUE_DROP_CTR 0x7200 37362306a36Sopenharmony_ci#define MVPP2_TX_PKTS_EARLY_DROP_CTR 0x7204 37462306a36Sopenharmony_ci#define MVPP2_TX_PKTS_BM_DROP_CTR 0x7208 37562306a36Sopenharmony_ci#define MVPP2_TX_PKTS_BM_MC_DROP_CTR 0x720c 37662306a36Sopenharmony_ci#define MVPP2_RX_PKTS_FULL_QUEUE_DROP_CTR 0x7220 37762306a36Sopenharmony_ci#define MVPP2_RX_PKTS_EARLY_DROP_CTR 0x7224 37862306a36Sopenharmony_ci#define MVPP2_RX_PKTS_BM_DROP_CTR 0x7228 37962306a36Sopenharmony_ci#define MVPP2_CLS_DEC_TBL_HIT_CTR 0x7700 38062306a36Sopenharmony_ci#define MVPP2_CLS_FLOW_TBL_HIT_CTR 0x7704 38162306a36Sopenharmony_ci 38262306a36Sopenharmony_ci/* TX Scheduler registers */ 38362306a36Sopenharmony_ci#define MVPP2_TXP_SCHED_PORT_INDEX_REG 0x8000 38462306a36Sopenharmony_ci#define MVPP2_TXP_SCHED_Q_CMD_REG 0x8004 38562306a36Sopenharmony_ci#define MVPP2_TXP_SCHED_ENQ_MASK 0xff 38662306a36Sopenharmony_ci#define MVPP2_TXP_SCHED_DISQ_OFFSET 8 38762306a36Sopenharmony_ci#define MVPP2_TXP_SCHED_CMD_1_REG 0x8010 38862306a36Sopenharmony_ci#define MVPP2_TXP_SCHED_FIXED_PRIO_REG 0x8014 38962306a36Sopenharmony_ci#define MVPP2_TXP_SCHED_PERIOD_REG 0x8018 39062306a36Sopenharmony_ci#define MVPP2_TXP_SCHED_MTU_REG 0x801c 39162306a36Sopenharmony_ci#define MVPP2_TXP_MTU_MAX 0x7FFFF 39262306a36Sopenharmony_ci#define MVPP2_TXP_SCHED_REFILL_REG 0x8020 39362306a36Sopenharmony_ci#define MVPP2_TXP_REFILL_TOKENS_ALL_MASK 0x7ffff 39462306a36Sopenharmony_ci#define MVPP2_TXP_REFILL_PERIOD_ALL_MASK 0x3ff00000 39562306a36Sopenharmony_ci#define MVPP2_TXP_REFILL_PERIOD_MASK(v) ((v) << 20) 39662306a36Sopenharmony_ci#define MVPP2_TXP_SCHED_TOKEN_SIZE_REG 0x8024 39762306a36Sopenharmony_ci#define MVPP2_TXP_TOKEN_SIZE_MAX 0xffffffff 39862306a36Sopenharmony_ci#define MVPP2_TXQ_SCHED_REFILL_REG(q) (0x8040 + ((q) << 2)) 39962306a36Sopenharmony_ci#define MVPP2_TXQ_REFILL_TOKENS_ALL_MASK 0x7ffff 40062306a36Sopenharmony_ci#define MVPP2_TXQ_REFILL_PERIOD_ALL_MASK 0x3ff00000 40162306a36Sopenharmony_ci#define MVPP2_TXQ_REFILL_PERIOD_MASK(v) ((v) << 20) 40262306a36Sopenharmony_ci#define MVPP2_TXQ_SCHED_TOKEN_SIZE_REG(q) (0x8060 + ((q) << 2)) 40362306a36Sopenharmony_ci#define MVPP2_TXQ_TOKEN_SIZE_MAX 0x7fffffff 40462306a36Sopenharmony_ci#define MVPP2_TXQ_SCHED_TOKEN_CNTR_REG(q) (0x8080 + ((q) << 2)) 40562306a36Sopenharmony_ci#define MVPP2_TXQ_TOKEN_CNTR_MAX 0xffffffff 40662306a36Sopenharmony_ci 40762306a36Sopenharmony_ci/* TX general registers */ 40862306a36Sopenharmony_ci#define MVPP2_TX_SNOOP_REG 0x8800 40962306a36Sopenharmony_ci#define MVPP2_TX_PORT_FLUSH_REG 0x8810 41062306a36Sopenharmony_ci#define MVPP2_TX_PORT_FLUSH_MASK(port) (1 << (port)) 41162306a36Sopenharmony_ci 41262306a36Sopenharmony_ci/* LMS registers */ 41362306a36Sopenharmony_ci#define MVPP2_SRC_ADDR_MIDDLE 0x24 41462306a36Sopenharmony_ci#define MVPP2_SRC_ADDR_HIGH 0x28 41562306a36Sopenharmony_ci#define MVPP2_PHY_AN_CFG0_REG 0x34 41662306a36Sopenharmony_ci#define MVPP2_PHY_AN_STOP_SMI0_MASK BIT(7) 41762306a36Sopenharmony_ci#define MVPP2_MNG_EXTENDED_GLOBAL_CTRL_REG 0x305c 41862306a36Sopenharmony_ci#define MVPP2_EXT_GLOBAL_CTRL_DEFAULT 0x27 41962306a36Sopenharmony_ci 42062306a36Sopenharmony_ci/* Per-port registers */ 42162306a36Sopenharmony_ci#define MVPP2_GMAC_CTRL_0_REG 0x0 42262306a36Sopenharmony_ci#define MVPP2_GMAC_PORT_EN_MASK BIT(0) 42362306a36Sopenharmony_ci#define MVPP2_GMAC_PORT_TYPE_MASK BIT(1) 42462306a36Sopenharmony_ci#define MVPP2_GMAC_MAX_RX_SIZE_OFFS 2 42562306a36Sopenharmony_ci#define MVPP2_GMAC_MAX_RX_SIZE_MASK 0x7ffc 42662306a36Sopenharmony_ci#define MVPP2_GMAC_MIB_CNTR_EN_MASK BIT(15) 42762306a36Sopenharmony_ci#define MVPP2_GMAC_CTRL_1_REG 0x4 42862306a36Sopenharmony_ci#define MVPP2_GMAC_PERIODIC_XON_EN_MASK BIT(1) 42962306a36Sopenharmony_ci#define MVPP2_GMAC_GMII_LB_EN_MASK BIT(5) 43062306a36Sopenharmony_ci#define MVPP2_GMAC_PCS_LB_EN_BIT 6 43162306a36Sopenharmony_ci#define MVPP2_GMAC_PCS_LB_EN_MASK BIT(6) 43262306a36Sopenharmony_ci#define MVPP2_GMAC_SA_LOW_OFFS 7 43362306a36Sopenharmony_ci#define MVPP2_GMAC_CTRL_2_REG 0x8 43462306a36Sopenharmony_ci#define MVPP2_GMAC_INBAND_AN_MASK BIT(0) 43562306a36Sopenharmony_ci#define MVPP2_GMAC_FLOW_CTRL_MASK GENMASK(2, 1) 43662306a36Sopenharmony_ci#define MVPP2_GMAC_PCS_ENABLE_MASK BIT(3) 43762306a36Sopenharmony_ci#define MVPP2_GMAC_INTERNAL_CLK_MASK BIT(4) 43862306a36Sopenharmony_ci#define MVPP2_GMAC_DISABLE_PADDING BIT(5) 43962306a36Sopenharmony_ci#define MVPP2_GMAC_PORT_RESET_MASK BIT(6) 44062306a36Sopenharmony_ci#define MVPP2_GMAC_AUTONEG_CONFIG 0xc 44162306a36Sopenharmony_ci#define MVPP2_GMAC_FORCE_LINK_DOWN BIT(0) 44262306a36Sopenharmony_ci#define MVPP2_GMAC_FORCE_LINK_PASS BIT(1) 44362306a36Sopenharmony_ci#define MVPP2_GMAC_IN_BAND_AUTONEG BIT(2) 44462306a36Sopenharmony_ci#define MVPP2_GMAC_IN_BAND_AUTONEG_BYPASS BIT(3) 44562306a36Sopenharmony_ci#define MVPP2_GMAC_IN_BAND_RESTART_AN BIT(4) 44662306a36Sopenharmony_ci#define MVPP2_GMAC_CONFIG_MII_SPEED BIT(5) 44762306a36Sopenharmony_ci#define MVPP2_GMAC_CONFIG_GMII_SPEED BIT(6) 44862306a36Sopenharmony_ci#define MVPP2_GMAC_AN_SPEED_EN BIT(7) 44962306a36Sopenharmony_ci#define MVPP2_GMAC_FC_ADV_EN BIT(9) 45062306a36Sopenharmony_ci#define MVPP2_GMAC_FC_ADV_ASM_EN BIT(10) 45162306a36Sopenharmony_ci#define MVPP2_GMAC_FLOW_CTRL_AUTONEG BIT(11) 45262306a36Sopenharmony_ci#define MVPP2_GMAC_CONFIG_FULL_DUPLEX BIT(12) 45362306a36Sopenharmony_ci#define MVPP2_GMAC_AN_DUPLEX_EN BIT(13) 45462306a36Sopenharmony_ci#define MVPP2_GMAC_STATUS0 0x10 45562306a36Sopenharmony_ci#define MVPP2_GMAC_STATUS0_LINK_UP BIT(0) 45662306a36Sopenharmony_ci#define MVPP2_GMAC_STATUS0_GMII_SPEED BIT(1) 45762306a36Sopenharmony_ci#define MVPP2_GMAC_STATUS0_MII_SPEED BIT(2) 45862306a36Sopenharmony_ci#define MVPP2_GMAC_STATUS0_FULL_DUPLEX BIT(3) 45962306a36Sopenharmony_ci#define MVPP2_GMAC_STATUS0_RX_PAUSE BIT(4) 46062306a36Sopenharmony_ci#define MVPP2_GMAC_STATUS0_TX_PAUSE BIT(5) 46162306a36Sopenharmony_ci#define MVPP2_GMAC_STATUS0_AN_COMPLETE BIT(11) 46262306a36Sopenharmony_ci#define MVPP2_GMAC_PORT_FIFO_CFG_1_REG 0x1c 46362306a36Sopenharmony_ci#define MVPP2_GMAC_TX_FIFO_MIN_TH_OFFS 6 46462306a36Sopenharmony_ci#define MVPP2_GMAC_TX_FIFO_MIN_TH_ALL_MASK 0x1fc0 46562306a36Sopenharmony_ci#define MVPP2_GMAC_TX_FIFO_MIN_TH_MASK(v) (((v) << 6) & \ 46662306a36Sopenharmony_ci MVPP2_GMAC_TX_FIFO_MIN_TH_ALL_MASK) 46762306a36Sopenharmony_ci#define MVPP22_GMAC_INT_STAT 0x20 46862306a36Sopenharmony_ci#define MVPP22_GMAC_INT_STAT_LINK BIT(1) 46962306a36Sopenharmony_ci#define MVPP22_GMAC_INT_MASK 0x24 47062306a36Sopenharmony_ci#define MVPP22_GMAC_INT_MASK_LINK_STAT BIT(1) 47162306a36Sopenharmony_ci#define MVPP22_GMAC_CTRL_4_REG 0x90 47262306a36Sopenharmony_ci#define MVPP22_CTRL4_EXT_PIN_GMII_SEL BIT(0) 47362306a36Sopenharmony_ci#define MVPP22_CTRL4_RX_FC_EN BIT(3) 47462306a36Sopenharmony_ci#define MVPP22_CTRL4_TX_FC_EN BIT(4) 47562306a36Sopenharmony_ci#define MVPP22_CTRL4_DP_CLK_SEL BIT(5) 47662306a36Sopenharmony_ci#define MVPP22_CTRL4_SYNC_BYPASS_DIS BIT(6) 47762306a36Sopenharmony_ci#define MVPP22_CTRL4_QSGMII_BYPASS_ACTIVE BIT(7) 47862306a36Sopenharmony_ci#define MVPP22_GMAC_INT_SUM_STAT 0xa0 47962306a36Sopenharmony_ci#define MVPP22_GMAC_INT_SUM_STAT_INTERNAL BIT(1) 48062306a36Sopenharmony_ci#define MVPP22_GMAC_INT_SUM_STAT_PTP BIT(2) 48162306a36Sopenharmony_ci#define MVPP22_GMAC_INT_SUM_MASK 0xa4 48262306a36Sopenharmony_ci#define MVPP22_GMAC_INT_SUM_MASK_LINK_STAT BIT(1) 48362306a36Sopenharmony_ci#define MVPP22_GMAC_INT_SUM_MASK_PTP BIT(2) 48462306a36Sopenharmony_ci 48562306a36Sopenharmony_ci/* Per-port XGMAC registers. PPv2.2 and PPv2.3, only for GOP port 0, 48662306a36Sopenharmony_ci * relative to port->base. 48762306a36Sopenharmony_ci */ 48862306a36Sopenharmony_ci#define MVPP22_XLG_CTRL0_REG 0x100 48962306a36Sopenharmony_ci#define MVPP22_XLG_CTRL0_PORT_EN BIT(0) 49062306a36Sopenharmony_ci#define MVPP22_XLG_CTRL0_MAC_RESET_DIS BIT(1) 49162306a36Sopenharmony_ci#define MVPP22_XLG_CTRL0_FORCE_LINK_DOWN BIT(2) 49262306a36Sopenharmony_ci#define MVPP22_XLG_CTRL0_FORCE_LINK_PASS BIT(3) 49362306a36Sopenharmony_ci#define MVPP22_XLG_CTRL0_RX_FLOW_CTRL_EN BIT(7) 49462306a36Sopenharmony_ci#define MVPP22_XLG_CTRL0_TX_FLOW_CTRL_EN BIT(8) 49562306a36Sopenharmony_ci#define MVPP22_XLG_CTRL0_MIB_CNT_DIS BIT(14) 49662306a36Sopenharmony_ci#define MVPP22_XLG_CTRL1_REG 0x104 49762306a36Sopenharmony_ci#define MVPP22_XLG_CTRL1_FRAMESIZELIMIT_OFFS 0 49862306a36Sopenharmony_ci#define MVPP22_XLG_CTRL1_FRAMESIZELIMIT_MASK 0x1fff 49962306a36Sopenharmony_ci#define MVPP22_XLG_STATUS 0x10c 50062306a36Sopenharmony_ci#define MVPP22_XLG_STATUS_LINK_UP BIT(0) 50162306a36Sopenharmony_ci#define MVPP22_XLG_INT_STAT 0x114 50262306a36Sopenharmony_ci#define MVPP22_XLG_INT_STAT_LINK BIT(1) 50362306a36Sopenharmony_ci#define MVPP22_XLG_INT_MASK 0x118 50462306a36Sopenharmony_ci#define MVPP22_XLG_INT_MASK_LINK BIT(1) 50562306a36Sopenharmony_ci#define MVPP22_XLG_CTRL3_REG 0x11c 50662306a36Sopenharmony_ci#define MVPP22_XLG_CTRL3_MACMODESELECT_MASK (7 << 13) 50762306a36Sopenharmony_ci#define MVPP22_XLG_CTRL3_MACMODESELECT_GMAC (0 << 13) 50862306a36Sopenharmony_ci#define MVPP22_XLG_CTRL3_MACMODESELECT_10G (1 << 13) 50962306a36Sopenharmony_ci#define MVPP22_XLG_EXT_INT_STAT 0x158 51062306a36Sopenharmony_ci#define MVPP22_XLG_EXT_INT_STAT_XLG BIT(1) 51162306a36Sopenharmony_ci#define MVPP22_XLG_EXT_INT_STAT_PTP BIT(7) 51262306a36Sopenharmony_ci#define MVPP22_XLG_EXT_INT_MASK 0x15c 51362306a36Sopenharmony_ci#define MVPP22_XLG_EXT_INT_MASK_XLG BIT(1) 51462306a36Sopenharmony_ci#define MVPP22_XLG_EXT_INT_MASK_GIG BIT(2) 51562306a36Sopenharmony_ci#define MVPP22_XLG_EXT_INT_MASK_PTP BIT(7) 51662306a36Sopenharmony_ci#define MVPP22_XLG_CTRL4_REG 0x184 51762306a36Sopenharmony_ci#define MVPP22_XLG_CTRL4_FWD_FC BIT(5) 51862306a36Sopenharmony_ci#define MVPP22_XLG_CTRL4_FWD_PFC BIT(6) 51962306a36Sopenharmony_ci#define MVPP22_XLG_CTRL4_MACMODSELECT_GMAC BIT(12) 52062306a36Sopenharmony_ci#define MVPP22_XLG_CTRL4_EN_IDLE_CHECK BIT(14) 52162306a36Sopenharmony_ci 52262306a36Sopenharmony_ci/* SMI registers. PPv2.2 and PPv2.3, relative to priv->iface_base. */ 52362306a36Sopenharmony_ci#define MVPP22_SMI_MISC_CFG_REG 0x1204 52462306a36Sopenharmony_ci#define MVPP22_SMI_POLLING_EN BIT(10) 52562306a36Sopenharmony_ci 52662306a36Sopenharmony_ci/* TAI registers, PPv2.2 only, relative to priv->iface_base */ 52762306a36Sopenharmony_ci#define MVPP22_TAI_INT_CAUSE 0x1400 52862306a36Sopenharmony_ci#define MVPP22_TAI_INT_MASK 0x1404 52962306a36Sopenharmony_ci#define MVPP22_TAI_CR0 0x1408 53062306a36Sopenharmony_ci#define MVPP22_TAI_CR1 0x140c 53162306a36Sopenharmony_ci#define MVPP22_TAI_TCFCR0 0x1410 53262306a36Sopenharmony_ci#define MVPP22_TAI_TCFCR1 0x1414 53362306a36Sopenharmony_ci#define MVPP22_TAI_TCFCR2 0x1418 53462306a36Sopenharmony_ci#define MVPP22_TAI_FATWR 0x141c 53562306a36Sopenharmony_ci#define MVPP22_TAI_TOD_STEP_NANO_CR 0x1420 53662306a36Sopenharmony_ci#define MVPP22_TAI_TOD_STEP_FRAC_HIGH 0x1424 53762306a36Sopenharmony_ci#define MVPP22_TAI_TOD_STEP_FRAC_LOW 0x1428 53862306a36Sopenharmony_ci#define MVPP22_TAI_TAPDC_HIGH 0x142c 53962306a36Sopenharmony_ci#define MVPP22_TAI_TAPDC_LOW 0x1430 54062306a36Sopenharmony_ci#define MVPP22_TAI_TGTOD_SEC_HIGH 0x1434 54162306a36Sopenharmony_ci#define MVPP22_TAI_TGTOD_SEC_MED 0x1438 54262306a36Sopenharmony_ci#define MVPP22_TAI_TGTOD_SEC_LOW 0x143c 54362306a36Sopenharmony_ci#define MVPP22_TAI_TGTOD_NANO_HIGH 0x1440 54462306a36Sopenharmony_ci#define MVPP22_TAI_TGTOD_NANO_LOW 0x1444 54562306a36Sopenharmony_ci#define MVPP22_TAI_TGTOD_FRAC_HIGH 0x1448 54662306a36Sopenharmony_ci#define MVPP22_TAI_TGTOD_FRAC_LOW 0x144c 54762306a36Sopenharmony_ci#define MVPP22_TAI_TLV_SEC_HIGH 0x1450 54862306a36Sopenharmony_ci#define MVPP22_TAI_TLV_SEC_MED 0x1454 54962306a36Sopenharmony_ci#define MVPP22_TAI_TLV_SEC_LOW 0x1458 55062306a36Sopenharmony_ci#define MVPP22_TAI_TLV_NANO_HIGH 0x145c 55162306a36Sopenharmony_ci#define MVPP22_TAI_TLV_NANO_LOW 0x1460 55262306a36Sopenharmony_ci#define MVPP22_TAI_TLV_FRAC_HIGH 0x1464 55362306a36Sopenharmony_ci#define MVPP22_TAI_TLV_FRAC_LOW 0x1468 55462306a36Sopenharmony_ci#define MVPP22_TAI_TCV0_SEC_HIGH 0x146c 55562306a36Sopenharmony_ci#define MVPP22_TAI_TCV0_SEC_MED 0x1470 55662306a36Sopenharmony_ci#define MVPP22_TAI_TCV0_SEC_LOW 0x1474 55762306a36Sopenharmony_ci#define MVPP22_TAI_TCV0_NANO_HIGH 0x1478 55862306a36Sopenharmony_ci#define MVPP22_TAI_TCV0_NANO_LOW 0x147c 55962306a36Sopenharmony_ci#define MVPP22_TAI_TCV0_FRAC_HIGH 0x1480 56062306a36Sopenharmony_ci#define MVPP22_TAI_TCV0_FRAC_LOW 0x1484 56162306a36Sopenharmony_ci#define MVPP22_TAI_TCV1_SEC_HIGH 0x1488 56262306a36Sopenharmony_ci#define MVPP22_TAI_TCV1_SEC_MED 0x148c 56362306a36Sopenharmony_ci#define MVPP22_TAI_TCV1_SEC_LOW 0x1490 56462306a36Sopenharmony_ci#define MVPP22_TAI_TCV1_NANO_HIGH 0x1494 56562306a36Sopenharmony_ci#define MVPP22_TAI_TCV1_NANO_LOW 0x1498 56662306a36Sopenharmony_ci#define MVPP22_TAI_TCV1_FRAC_HIGH 0x149c 56762306a36Sopenharmony_ci#define MVPP22_TAI_TCV1_FRAC_LOW 0x14a0 56862306a36Sopenharmony_ci#define MVPP22_TAI_TCSR 0x14a4 56962306a36Sopenharmony_ci#define MVPP22_TAI_TUC_LSB 0x14a8 57062306a36Sopenharmony_ci#define MVPP22_TAI_GFM_SEC_HIGH 0x14ac 57162306a36Sopenharmony_ci#define MVPP22_TAI_GFM_SEC_MED 0x14b0 57262306a36Sopenharmony_ci#define MVPP22_TAI_GFM_SEC_LOW 0x14b4 57362306a36Sopenharmony_ci#define MVPP22_TAI_GFM_NANO_HIGH 0x14b8 57462306a36Sopenharmony_ci#define MVPP22_TAI_GFM_NANO_LOW 0x14bc 57562306a36Sopenharmony_ci#define MVPP22_TAI_GFM_FRAC_HIGH 0x14c0 57662306a36Sopenharmony_ci#define MVPP22_TAI_GFM_FRAC_LOW 0x14c4 57762306a36Sopenharmony_ci#define MVPP22_TAI_PCLK_DA_HIGH 0x14c8 57862306a36Sopenharmony_ci#define MVPP22_TAI_PCLK_DA_LOW 0x14cc 57962306a36Sopenharmony_ci#define MVPP22_TAI_CTCR 0x14d0 58062306a36Sopenharmony_ci#define MVPP22_TAI_PCLK_CCC_HIGH 0x14d4 58162306a36Sopenharmony_ci#define MVPP22_TAI_PCLK_CCC_LOW 0x14d8 58262306a36Sopenharmony_ci#define MVPP22_TAI_DTC_HIGH 0x14dc 58362306a36Sopenharmony_ci#define MVPP22_TAI_DTC_LOW 0x14e0 58462306a36Sopenharmony_ci#define MVPP22_TAI_CCC_HIGH 0x14e4 58562306a36Sopenharmony_ci#define MVPP22_TAI_CCC_LOW 0x14e8 58662306a36Sopenharmony_ci#define MVPP22_TAI_ICICE 0x14f4 58762306a36Sopenharmony_ci#define MVPP22_TAI_ICICC_LOW 0x14f8 58862306a36Sopenharmony_ci#define MVPP22_TAI_TUC_MSB 0x14fc 58962306a36Sopenharmony_ci 59062306a36Sopenharmony_ci#define MVPP22_GMAC_BASE(port) (0x7000 + (port) * 0x1000 + 0xe00) 59162306a36Sopenharmony_ci 59262306a36Sopenharmony_ci#define MVPP2_CAUSE_TXQ_SENT_DESC_ALL_MASK 0xff 59362306a36Sopenharmony_ci 59462306a36Sopenharmony_ci/* Descriptor ring Macros */ 59562306a36Sopenharmony_ci#define MVPP2_QUEUE_NEXT_DESC(q, index) \ 59662306a36Sopenharmony_ci (((index) < (q)->last_desc) ? ((index) + 1) : 0) 59762306a36Sopenharmony_ci 59862306a36Sopenharmony_ci/* XPCS registers.PPv2.2 and PPv2.3 */ 59962306a36Sopenharmony_ci#define MVPP22_MPCS_BASE(port) (0x7000 + (port) * 0x1000) 60062306a36Sopenharmony_ci#define MVPP22_MPCS_CTRL 0x14 60162306a36Sopenharmony_ci#define MVPP22_MPCS_CTRL_FWD_ERR_CONN BIT(10) 60262306a36Sopenharmony_ci#define MVPP22_MPCS_CLK_RESET 0x14c 60362306a36Sopenharmony_ci#define MAC_CLK_RESET_SD_TX BIT(0) 60462306a36Sopenharmony_ci#define MAC_CLK_RESET_SD_RX BIT(1) 60562306a36Sopenharmony_ci#define MAC_CLK_RESET_MAC BIT(2) 60662306a36Sopenharmony_ci#define MVPP22_MPCS_CLK_RESET_DIV_RATIO(n) ((n) << 4) 60762306a36Sopenharmony_ci#define MVPP22_MPCS_CLK_RESET_DIV_SET BIT(11) 60862306a36Sopenharmony_ci 60962306a36Sopenharmony_ci/* FCA registers. PPv2.2 and PPv2.3 */ 61062306a36Sopenharmony_ci#define MVPP22_FCA_BASE(port) (0x7600 + (port) * 0x1000) 61162306a36Sopenharmony_ci#define MVPP22_FCA_REG_SIZE 16 61262306a36Sopenharmony_ci#define MVPP22_FCA_REG_MASK 0xFFFF 61362306a36Sopenharmony_ci#define MVPP22_FCA_CONTROL_REG 0x0 61462306a36Sopenharmony_ci#define MVPP22_FCA_ENABLE_PERIODIC BIT(11) 61562306a36Sopenharmony_ci#define MVPP22_PERIODIC_COUNTER_LSB_REG (0x110) 61662306a36Sopenharmony_ci#define MVPP22_PERIODIC_COUNTER_MSB_REG (0x114) 61762306a36Sopenharmony_ci 61862306a36Sopenharmony_ci/* XPCS registers. PPv2.2 and PPv2.3 */ 61962306a36Sopenharmony_ci#define MVPP22_XPCS_BASE(port) (0x7400 + (port) * 0x1000) 62062306a36Sopenharmony_ci#define MVPP22_XPCS_CFG0 0x0 62162306a36Sopenharmony_ci#define MVPP22_XPCS_CFG0_RESET_DIS BIT(0) 62262306a36Sopenharmony_ci#define MVPP22_XPCS_CFG0_PCS_MODE(n) ((n) << 3) 62362306a36Sopenharmony_ci#define MVPP22_XPCS_CFG0_ACTIVE_LANE(n) ((n) << 5) 62462306a36Sopenharmony_ci 62562306a36Sopenharmony_ci/* PTP registers. PPv2.2 only */ 62662306a36Sopenharmony_ci#define MVPP22_PTP_BASE(port) (0x7800 + (port * 0x1000)) 62762306a36Sopenharmony_ci#define MVPP22_PTP_INT_CAUSE 0x00 62862306a36Sopenharmony_ci#define MVPP22_PTP_INT_CAUSE_QUEUE1 BIT(6) 62962306a36Sopenharmony_ci#define MVPP22_PTP_INT_CAUSE_QUEUE0 BIT(5) 63062306a36Sopenharmony_ci#define MVPP22_PTP_INT_MASK 0x04 63162306a36Sopenharmony_ci#define MVPP22_PTP_INT_MASK_QUEUE1 BIT(6) 63262306a36Sopenharmony_ci#define MVPP22_PTP_INT_MASK_QUEUE0 BIT(5) 63362306a36Sopenharmony_ci#define MVPP22_PTP_GCR 0x08 63462306a36Sopenharmony_ci#define MVPP22_PTP_GCR_RX_RESET BIT(13) 63562306a36Sopenharmony_ci#define MVPP22_PTP_GCR_TX_RESET BIT(1) 63662306a36Sopenharmony_ci#define MVPP22_PTP_GCR_TSU_ENABLE BIT(0) 63762306a36Sopenharmony_ci#define MVPP22_PTP_TX_Q0_R0 0x0c 63862306a36Sopenharmony_ci#define MVPP22_PTP_TX_Q0_R1 0x10 63962306a36Sopenharmony_ci#define MVPP22_PTP_TX_Q0_R2 0x14 64062306a36Sopenharmony_ci#define MVPP22_PTP_TX_Q1_R0 0x18 64162306a36Sopenharmony_ci#define MVPP22_PTP_TX_Q1_R1 0x1c 64262306a36Sopenharmony_ci#define MVPP22_PTP_TX_Q1_R2 0x20 64362306a36Sopenharmony_ci#define MVPP22_PTP_TPCR 0x24 64462306a36Sopenharmony_ci#define MVPP22_PTP_V1PCR 0x28 64562306a36Sopenharmony_ci#define MVPP22_PTP_V2PCR 0x2c 64662306a36Sopenharmony_ci#define MVPP22_PTP_Y1731PCR 0x30 64762306a36Sopenharmony_ci#define MVPP22_PTP_NTPTSPCR 0x34 64862306a36Sopenharmony_ci#define MVPP22_PTP_NTPRXPCR 0x38 64962306a36Sopenharmony_ci#define MVPP22_PTP_NTPTXPCR 0x3c 65062306a36Sopenharmony_ci#define MVPP22_PTP_WAMPPCR 0x40 65162306a36Sopenharmony_ci#define MVPP22_PTP_NAPCR 0x44 65262306a36Sopenharmony_ci#define MVPP22_PTP_FAPCR 0x48 65362306a36Sopenharmony_ci#define MVPP22_PTP_CAPCR 0x50 65462306a36Sopenharmony_ci#define MVPP22_PTP_ATAPCR 0x54 65562306a36Sopenharmony_ci#define MVPP22_PTP_ACTAPCR 0x58 65662306a36Sopenharmony_ci#define MVPP22_PTP_CATAPCR 0x5c 65762306a36Sopenharmony_ci#define MVPP22_PTP_CACTAPCR 0x60 65862306a36Sopenharmony_ci#define MVPP22_PTP_AITAPCR 0x64 65962306a36Sopenharmony_ci#define MVPP22_PTP_CAITAPCR 0x68 66062306a36Sopenharmony_ci#define MVPP22_PTP_CITAPCR 0x6c 66162306a36Sopenharmony_ci#define MVPP22_PTP_NTP_OFF_HIGH 0x70 66262306a36Sopenharmony_ci#define MVPP22_PTP_NTP_OFF_LOW 0x74 66362306a36Sopenharmony_ci#define MVPP22_PTP_TX_PIPE_STATUS_DELAY 0x78 66462306a36Sopenharmony_ci 66562306a36Sopenharmony_ci/* System controller registers. Accessed through a regmap. */ 66662306a36Sopenharmony_ci#define GENCONF_SOFT_RESET1 0x1108 66762306a36Sopenharmony_ci#define GENCONF_SOFT_RESET1_GOP BIT(6) 66862306a36Sopenharmony_ci#define GENCONF_PORT_CTRL0 0x1110 66962306a36Sopenharmony_ci#define GENCONF_PORT_CTRL0_BUS_WIDTH_SELECT BIT(1) 67062306a36Sopenharmony_ci#define GENCONF_PORT_CTRL0_RX_DATA_SAMPLE BIT(29) 67162306a36Sopenharmony_ci#define GENCONF_PORT_CTRL0_CLK_DIV_PHASE_CLR BIT(31) 67262306a36Sopenharmony_ci#define GENCONF_PORT_CTRL1 0x1114 67362306a36Sopenharmony_ci#define GENCONF_PORT_CTRL1_EN(p) BIT(p) 67462306a36Sopenharmony_ci#define GENCONF_PORT_CTRL1_RESET(p) (BIT(p) << 28) 67562306a36Sopenharmony_ci#define GENCONF_CTRL0 0x1120 67662306a36Sopenharmony_ci#define GENCONF_CTRL0_PORT2_RGMII BIT(0) 67762306a36Sopenharmony_ci#define GENCONF_CTRL0_PORT3_RGMII_MII BIT(1) 67862306a36Sopenharmony_ci#define GENCONF_CTRL0_PORT3_RGMII BIT(2) 67962306a36Sopenharmony_ci 68062306a36Sopenharmony_ci/* Various constants */ 68162306a36Sopenharmony_ci 68262306a36Sopenharmony_ci/* Coalescing */ 68362306a36Sopenharmony_ci#define MVPP2_TXDONE_COAL_PKTS_THRESH 64 68462306a36Sopenharmony_ci#define MVPP2_TXDONE_HRTIMER_PERIOD_NS 1000000UL 68562306a36Sopenharmony_ci#define MVPP2_TXDONE_COAL_USEC 1000 68662306a36Sopenharmony_ci#define MVPP2_RX_COAL_PKTS 32 68762306a36Sopenharmony_ci#define MVPP2_RX_COAL_USEC 64 68862306a36Sopenharmony_ci 68962306a36Sopenharmony_ci/* The two bytes Marvell header. Either contains a special value used 69062306a36Sopenharmony_ci * by Marvell switches when a specific hardware mode is enabled (not 69162306a36Sopenharmony_ci * supported by this driver) or is filled automatically by zeroes on 69262306a36Sopenharmony_ci * the RX side. Those two bytes being at the front of the Ethernet 69362306a36Sopenharmony_ci * header, they allow to have the IP header aligned on a 4 bytes 69462306a36Sopenharmony_ci * boundary automatically: the hardware skips those two bytes on its 69562306a36Sopenharmony_ci * own. 69662306a36Sopenharmony_ci */ 69762306a36Sopenharmony_ci#define MVPP2_MH_SIZE 2 69862306a36Sopenharmony_ci#define MVPP2_ETH_TYPE_LEN 2 69962306a36Sopenharmony_ci#define MVPP2_PPPOE_HDR_SIZE 8 70062306a36Sopenharmony_ci#define MVPP2_VLAN_TAG_LEN 4 70162306a36Sopenharmony_ci#define MVPP2_VLAN_TAG_EDSA_LEN 8 70262306a36Sopenharmony_ci 70362306a36Sopenharmony_ci/* Lbtd 802.3 type */ 70462306a36Sopenharmony_ci#define MVPP2_IP_LBDT_TYPE 0xfffa 70562306a36Sopenharmony_ci 70662306a36Sopenharmony_ci#define MVPP2_TX_CSUM_MAX_SIZE 9800 70762306a36Sopenharmony_ci 70862306a36Sopenharmony_ci/* Timeout constants */ 70962306a36Sopenharmony_ci#define MVPP2_TX_DISABLE_TIMEOUT_MSEC 1000 71062306a36Sopenharmony_ci#define MVPP2_TX_PENDING_TIMEOUT_MSEC 1000 71162306a36Sopenharmony_ci 71262306a36Sopenharmony_ci#define MVPP2_TX_MTU_MAX 0x7ffff 71362306a36Sopenharmony_ci 71462306a36Sopenharmony_ci/* Maximum number of T-CONTs of PON port */ 71562306a36Sopenharmony_ci#define MVPP2_MAX_TCONT 16 71662306a36Sopenharmony_ci 71762306a36Sopenharmony_ci/* Maximum number of supported ports */ 71862306a36Sopenharmony_ci#define MVPP2_MAX_PORTS 4 71962306a36Sopenharmony_ci 72062306a36Sopenharmony_ci/* Loopback port index */ 72162306a36Sopenharmony_ci#define MVPP2_LOOPBACK_PORT_INDEX 3 72262306a36Sopenharmony_ci 72362306a36Sopenharmony_ci/* Maximum number of TXQs used by single port */ 72462306a36Sopenharmony_ci#define MVPP2_MAX_TXQ 8 72562306a36Sopenharmony_ci 72662306a36Sopenharmony_ci/* MVPP2_MAX_TSO_SEGS is the maximum number of fragments to allow in the GSO 72762306a36Sopenharmony_ci * skb. As we need a maxium of two descriptors per fragments (1 header, 1 data), 72862306a36Sopenharmony_ci * multiply this value by two to count the maximum number of skb descs needed. 72962306a36Sopenharmony_ci */ 73062306a36Sopenharmony_ci#define MVPP2_MAX_TSO_SEGS 300 73162306a36Sopenharmony_ci#define MVPP2_MAX_SKB_DESCS (MVPP2_MAX_TSO_SEGS * 2 + MAX_SKB_FRAGS) 73262306a36Sopenharmony_ci 73362306a36Sopenharmony_ci/* Max number of RXQs per port */ 73462306a36Sopenharmony_ci#define MVPP2_PORT_MAX_RXQ 32 73562306a36Sopenharmony_ci 73662306a36Sopenharmony_ci/* Max number of Rx descriptors */ 73762306a36Sopenharmony_ci#define MVPP2_MAX_RXD_MAX 2048 73862306a36Sopenharmony_ci#define MVPP2_MAX_RXD_DFLT 1024 73962306a36Sopenharmony_ci 74062306a36Sopenharmony_ci/* Max number of Tx descriptors */ 74162306a36Sopenharmony_ci#define MVPP2_MAX_TXD_MAX 2048 74262306a36Sopenharmony_ci#define MVPP2_MAX_TXD_DFLT 1024 74362306a36Sopenharmony_ci 74462306a36Sopenharmony_ci/* Amount of Tx descriptors that can be reserved at once by CPU */ 74562306a36Sopenharmony_ci#define MVPP2_CPU_DESC_CHUNK 64 74662306a36Sopenharmony_ci 74762306a36Sopenharmony_ci/* Max number of Tx descriptors in each aggregated queue */ 74862306a36Sopenharmony_ci#define MVPP2_AGGR_TXQ_SIZE 256 74962306a36Sopenharmony_ci 75062306a36Sopenharmony_ci/* Descriptor aligned size */ 75162306a36Sopenharmony_ci#define MVPP2_DESC_ALIGNED_SIZE 32 75262306a36Sopenharmony_ci 75362306a36Sopenharmony_ci/* Descriptor alignment mask */ 75462306a36Sopenharmony_ci#define MVPP2_TX_DESC_ALIGN (MVPP2_DESC_ALIGNED_SIZE - 1) 75562306a36Sopenharmony_ci 75662306a36Sopenharmony_ci/* RX FIFO constants */ 75762306a36Sopenharmony_ci#define MVPP2_RX_FIFO_PORT_DATA_SIZE_44KB 0xb000 75862306a36Sopenharmony_ci#define MVPP2_RX_FIFO_PORT_DATA_SIZE_32KB 0x8000 75962306a36Sopenharmony_ci#define MVPP2_RX_FIFO_PORT_DATA_SIZE_8KB 0x2000 76062306a36Sopenharmony_ci#define MVPP2_RX_FIFO_PORT_DATA_SIZE_4KB 0x1000 76162306a36Sopenharmony_ci#define MVPP2_RX_FIFO_PORT_ATTR_SIZE(data_size) ((data_size) >> 6) 76262306a36Sopenharmony_ci#define MVPP2_RX_FIFO_PORT_ATTR_SIZE_4KB 0x40 76362306a36Sopenharmony_ci#define MVPP2_RX_FIFO_PORT_MIN_PKT 0x80 76462306a36Sopenharmony_ci 76562306a36Sopenharmony_ci/* TX FIFO constants */ 76662306a36Sopenharmony_ci#define MVPP22_TX_FIFO_DATA_SIZE_18KB 18 76762306a36Sopenharmony_ci#define MVPP22_TX_FIFO_DATA_SIZE_10KB 10 76862306a36Sopenharmony_ci#define MVPP22_TX_FIFO_DATA_SIZE_1KB 1 76962306a36Sopenharmony_ci#define MVPP2_TX_FIFO_THRESHOLD_MIN 256 /* Bytes */ 77062306a36Sopenharmony_ci#define MVPP2_TX_FIFO_THRESHOLD(kb) \ 77162306a36Sopenharmony_ci ((kb) * 1024 - MVPP2_TX_FIFO_THRESHOLD_MIN) 77262306a36Sopenharmony_ci 77362306a36Sopenharmony_ci/* RX FIFO threshold in 1KB granularity */ 77462306a36Sopenharmony_ci#define MVPP23_PORT0_FIFO_TRSH (9 * 1024) 77562306a36Sopenharmony_ci#define MVPP23_PORT1_FIFO_TRSH (4 * 1024) 77662306a36Sopenharmony_ci#define MVPP23_PORT2_FIFO_TRSH (2 * 1024) 77762306a36Sopenharmony_ci 77862306a36Sopenharmony_ci/* RX Flow Control Registers */ 77962306a36Sopenharmony_ci#define MVPP2_RX_FC_REG(port) (0x150 + 4 * (port)) 78062306a36Sopenharmony_ci#define MVPP2_RX_FC_EN BIT(24) 78162306a36Sopenharmony_ci#define MVPP2_RX_FC_TRSH_OFFS 16 78262306a36Sopenharmony_ci#define MVPP2_RX_FC_TRSH_MASK (0xFF << MVPP2_RX_FC_TRSH_OFFS) 78362306a36Sopenharmony_ci#define MVPP2_RX_FC_TRSH_UNIT 256 78462306a36Sopenharmony_ci 78562306a36Sopenharmony_ci/* MSS Flow control */ 78662306a36Sopenharmony_ci#define MSS_FC_COM_REG 0 78762306a36Sopenharmony_ci#define FLOW_CONTROL_ENABLE_BIT BIT(0) 78862306a36Sopenharmony_ci#define FLOW_CONTROL_UPDATE_COMMAND_BIT BIT(31) 78962306a36Sopenharmony_ci#define FC_QUANTA 0xFFFF 79062306a36Sopenharmony_ci#define FC_CLK_DIVIDER 100 79162306a36Sopenharmony_ci 79262306a36Sopenharmony_ci#define MSS_RXQ_TRESH_BASE 0x200 79362306a36Sopenharmony_ci#define MSS_RXQ_TRESH_OFFS 4 79462306a36Sopenharmony_ci#define MSS_RXQ_TRESH_REG(q, fq) (MSS_RXQ_TRESH_BASE + (((q) + (fq)) \ 79562306a36Sopenharmony_ci * MSS_RXQ_TRESH_OFFS)) 79662306a36Sopenharmony_ci 79762306a36Sopenharmony_ci#define MSS_BUF_POOL_BASE 0x40 79862306a36Sopenharmony_ci#define MSS_BUF_POOL_OFFS 4 79962306a36Sopenharmony_ci#define MSS_BUF_POOL_REG(id) (MSS_BUF_POOL_BASE \ 80062306a36Sopenharmony_ci + (id) * MSS_BUF_POOL_OFFS) 80162306a36Sopenharmony_ci 80262306a36Sopenharmony_ci#define MSS_BUF_POOL_STOP_MASK 0xFFF 80362306a36Sopenharmony_ci#define MSS_BUF_POOL_START_MASK (0xFFF << MSS_BUF_POOL_START_OFFS) 80462306a36Sopenharmony_ci#define MSS_BUF_POOL_START_OFFS 12 80562306a36Sopenharmony_ci#define MSS_BUF_POOL_PORTS_MASK (0xF << MSS_BUF_POOL_PORTS_OFFS) 80662306a36Sopenharmony_ci#define MSS_BUF_POOL_PORTS_OFFS 24 80762306a36Sopenharmony_ci#define MSS_BUF_POOL_PORT_OFFS(id) (0x1 << \ 80862306a36Sopenharmony_ci ((id) + MSS_BUF_POOL_PORTS_OFFS)) 80962306a36Sopenharmony_ci 81062306a36Sopenharmony_ci#define MSS_RXQ_TRESH_START_MASK 0xFFFF 81162306a36Sopenharmony_ci#define MSS_RXQ_TRESH_STOP_MASK (0xFFFF << MSS_RXQ_TRESH_STOP_OFFS) 81262306a36Sopenharmony_ci#define MSS_RXQ_TRESH_STOP_OFFS 16 81362306a36Sopenharmony_ci 81462306a36Sopenharmony_ci#define MSS_RXQ_ASS_BASE 0x80 81562306a36Sopenharmony_ci#define MSS_RXQ_ASS_OFFS 4 81662306a36Sopenharmony_ci#define MSS_RXQ_ASS_PER_REG 4 81762306a36Sopenharmony_ci#define MSS_RXQ_ASS_PER_OFFS 8 81862306a36Sopenharmony_ci#define MSS_RXQ_ASS_PORTID_OFFS 0 81962306a36Sopenharmony_ci#define MSS_RXQ_ASS_PORTID_MASK 0x3 82062306a36Sopenharmony_ci#define MSS_RXQ_ASS_HOSTID_OFFS 2 82162306a36Sopenharmony_ci#define MSS_RXQ_ASS_HOSTID_MASK 0x3F 82262306a36Sopenharmony_ci 82362306a36Sopenharmony_ci#define MSS_RXQ_ASS_Q_BASE(q, fq) ((((q) + (fq)) % MSS_RXQ_ASS_PER_REG) \ 82462306a36Sopenharmony_ci * MSS_RXQ_ASS_PER_OFFS) 82562306a36Sopenharmony_ci#define MSS_RXQ_ASS_PQ_BASE(q, fq) ((((q) + (fq)) / MSS_RXQ_ASS_PER_REG) \ 82662306a36Sopenharmony_ci * MSS_RXQ_ASS_OFFS) 82762306a36Sopenharmony_ci#define MSS_RXQ_ASS_REG(q, fq) (MSS_RXQ_ASS_BASE + MSS_RXQ_ASS_PQ_BASE(q, fq)) 82862306a36Sopenharmony_ci 82962306a36Sopenharmony_ci#define MSS_THRESHOLD_STOP 768 83062306a36Sopenharmony_ci#define MSS_THRESHOLD_START 1024 83162306a36Sopenharmony_ci#define MSS_FC_MAX_TIMEOUT 5000 83262306a36Sopenharmony_ci 83362306a36Sopenharmony_ci/* RX buffer constants */ 83462306a36Sopenharmony_ci#define MVPP2_SKB_SHINFO_SIZE \ 83562306a36Sopenharmony_ci SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) 83662306a36Sopenharmony_ci 83762306a36Sopenharmony_ci#define MVPP2_RX_PKT_SIZE(mtu) \ 83862306a36Sopenharmony_ci ALIGN((mtu) + MVPP2_MH_SIZE + MVPP2_VLAN_TAG_LEN + \ 83962306a36Sopenharmony_ci ETH_HLEN + ETH_FCS_LEN, cache_line_size()) 84062306a36Sopenharmony_ci 84162306a36Sopenharmony_ci#define MVPP2_RX_BUF_SIZE(pkt_size) ((pkt_size) + MVPP2_SKB_HEADROOM) 84262306a36Sopenharmony_ci#define MVPP2_RX_TOTAL_SIZE(buf_size) ((buf_size) + MVPP2_SKB_SHINFO_SIZE) 84362306a36Sopenharmony_ci#define MVPP2_RX_MAX_PKT_SIZE(total_size) \ 84462306a36Sopenharmony_ci ((total_size) - MVPP2_SKB_HEADROOM - MVPP2_SKB_SHINFO_SIZE) 84562306a36Sopenharmony_ci 84662306a36Sopenharmony_ci#define MVPP2_MAX_RX_BUF_SIZE (PAGE_SIZE - MVPP2_SKB_SHINFO_SIZE - MVPP2_SKB_HEADROOM) 84762306a36Sopenharmony_ci 84862306a36Sopenharmony_ci#define MVPP2_BIT_TO_BYTE(bit) ((bit) / 8) 84962306a36Sopenharmony_ci#define MVPP2_BIT_TO_WORD(bit) ((bit) / 32) 85062306a36Sopenharmony_ci#define MVPP2_BIT_IN_WORD(bit) ((bit) % 32) 85162306a36Sopenharmony_ci 85262306a36Sopenharmony_ci#define MVPP2_N_PRS_FLOWS 52 85362306a36Sopenharmony_ci#define MVPP2_N_RFS_ENTRIES_PER_FLOW 4 85462306a36Sopenharmony_ci 85562306a36Sopenharmony_ci/* There are 7 supported high-level flows */ 85662306a36Sopenharmony_ci#define MVPP2_N_RFS_RULES (MVPP2_N_RFS_ENTRIES_PER_FLOW * 7) 85762306a36Sopenharmony_ci 85862306a36Sopenharmony_ci/* RSS constants */ 85962306a36Sopenharmony_ci#define MVPP22_N_RSS_TABLES 8 86062306a36Sopenharmony_ci#define MVPP22_RSS_TABLE_ENTRIES 32 86162306a36Sopenharmony_ci 86262306a36Sopenharmony_ci/* IPv6 max L3 address size */ 86362306a36Sopenharmony_ci#define MVPP2_MAX_L3_ADDR_SIZE 16 86462306a36Sopenharmony_ci 86562306a36Sopenharmony_ci/* Port flags */ 86662306a36Sopenharmony_ci#define MVPP2_F_LOOPBACK BIT(0) 86762306a36Sopenharmony_ci#define MVPP2_F_DT_COMPAT BIT(1) 86862306a36Sopenharmony_ci 86962306a36Sopenharmony_ci/* Marvell tag types */ 87062306a36Sopenharmony_cienum mvpp2_tag_type { 87162306a36Sopenharmony_ci MVPP2_TAG_TYPE_NONE = 0, 87262306a36Sopenharmony_ci MVPP2_TAG_TYPE_MH = 1, 87362306a36Sopenharmony_ci MVPP2_TAG_TYPE_DSA = 2, 87462306a36Sopenharmony_ci MVPP2_TAG_TYPE_EDSA = 3, 87562306a36Sopenharmony_ci MVPP2_TAG_TYPE_VLAN = 4, 87662306a36Sopenharmony_ci MVPP2_TAG_TYPE_LAST = 5 87762306a36Sopenharmony_ci}; 87862306a36Sopenharmony_ci 87962306a36Sopenharmony_ci/* L2 cast enum */ 88062306a36Sopenharmony_cienum mvpp2_prs_l2_cast { 88162306a36Sopenharmony_ci MVPP2_PRS_L2_UNI_CAST, 88262306a36Sopenharmony_ci MVPP2_PRS_L2_MULTI_CAST, 88362306a36Sopenharmony_ci}; 88462306a36Sopenharmony_ci 88562306a36Sopenharmony_ci/* L3 cast enum */ 88662306a36Sopenharmony_cienum mvpp2_prs_l3_cast { 88762306a36Sopenharmony_ci MVPP2_PRS_L3_UNI_CAST, 88862306a36Sopenharmony_ci MVPP2_PRS_L3_MULTI_CAST, 88962306a36Sopenharmony_ci MVPP2_PRS_L3_BROAD_CAST 89062306a36Sopenharmony_ci}; 89162306a36Sopenharmony_ci 89262306a36Sopenharmony_ci/* PTP descriptor constants. The low bits of the descriptor are stored 89362306a36Sopenharmony_ci * separately from the high bits. 89462306a36Sopenharmony_ci */ 89562306a36Sopenharmony_ci#define MVPP22_PTP_DESC_MASK_LOW 0xfff 89662306a36Sopenharmony_ci 89762306a36Sopenharmony_ci/* PTPAction */ 89862306a36Sopenharmony_cienum mvpp22_ptp_action { 89962306a36Sopenharmony_ci MVPP22_PTP_ACTION_NONE = 0, 90062306a36Sopenharmony_ci MVPP22_PTP_ACTION_FORWARD = 1, 90162306a36Sopenharmony_ci MVPP22_PTP_ACTION_CAPTURE = 3, 90262306a36Sopenharmony_ci /* The following have not been verified */ 90362306a36Sopenharmony_ci MVPP22_PTP_ACTION_ADDTIME = 4, 90462306a36Sopenharmony_ci MVPP22_PTP_ACTION_ADDCORRECTEDTIME = 5, 90562306a36Sopenharmony_ci MVPP22_PTP_ACTION_CAPTUREADDTIME = 6, 90662306a36Sopenharmony_ci MVPP22_PTP_ACTION_CAPTUREADDCORRECTEDTIME = 7, 90762306a36Sopenharmony_ci MVPP22_PTP_ACTION_ADDINGRESSTIME = 8, 90862306a36Sopenharmony_ci MVPP22_PTP_ACTION_CAPTUREADDINGRESSTIME = 9, 90962306a36Sopenharmony_ci MVPP22_PTP_ACTION_CAPTUREINGRESSTIME = 10, 91062306a36Sopenharmony_ci}; 91162306a36Sopenharmony_ci 91262306a36Sopenharmony_ci/* PTPPacketFormat */ 91362306a36Sopenharmony_cienum mvpp22_ptp_packet_format { 91462306a36Sopenharmony_ci MVPP22_PTP_PKT_FMT_PTPV2 = 0, 91562306a36Sopenharmony_ci MVPP22_PTP_PKT_FMT_PTPV1 = 1, 91662306a36Sopenharmony_ci MVPP22_PTP_PKT_FMT_Y1731 = 2, 91762306a36Sopenharmony_ci MVPP22_PTP_PKT_FMT_NTPTS = 3, 91862306a36Sopenharmony_ci MVPP22_PTP_PKT_FMT_NTPRX = 4, 91962306a36Sopenharmony_ci MVPP22_PTP_PKT_FMT_NTPTX = 5, 92062306a36Sopenharmony_ci MVPP22_PTP_PKT_FMT_TWAMP = 6, 92162306a36Sopenharmony_ci}; 92262306a36Sopenharmony_ci 92362306a36Sopenharmony_ci#define MVPP22_PTP_ACTION(x) (((x) & 15) << 0) 92462306a36Sopenharmony_ci#define MVPP22_PTP_PACKETFORMAT(x) (((x) & 7) << 4) 92562306a36Sopenharmony_ci#define MVPP22_PTP_MACTIMESTAMPINGEN BIT(11) 92662306a36Sopenharmony_ci#define MVPP22_PTP_TIMESTAMPENTRYID(x) (((x) & 31) << 12) 92762306a36Sopenharmony_ci#define MVPP22_PTP_TIMESTAMPQUEUESELECT BIT(18) 92862306a36Sopenharmony_ci 92962306a36Sopenharmony_ci/* BM constants */ 93062306a36Sopenharmony_ci#define MVPP2_BM_JUMBO_BUF_NUM 2048 93162306a36Sopenharmony_ci#define MVPP2_BM_LONG_BUF_NUM 2048 93262306a36Sopenharmony_ci#define MVPP2_BM_SHORT_BUF_NUM 2048 93362306a36Sopenharmony_ci#define MVPP2_BM_POOL_SIZE_MAX (16*1024 - MVPP2_BM_POOL_PTR_ALIGN/4) 93462306a36Sopenharmony_ci#define MVPP2_BM_POOL_PTR_ALIGN 128 93562306a36Sopenharmony_ci#define MVPP2_BM_MAX_POOLS 8 93662306a36Sopenharmony_ci 93762306a36Sopenharmony_ci/* BM cookie (32 bits) definition */ 93862306a36Sopenharmony_ci#define MVPP2_BM_COOKIE_POOL_OFFS 8 93962306a36Sopenharmony_ci#define MVPP2_BM_COOKIE_CPU_OFFS 24 94062306a36Sopenharmony_ci 94162306a36Sopenharmony_ci#define MVPP2_BM_SHORT_FRAME_SIZE 736 /* frame size 128 */ 94262306a36Sopenharmony_ci#define MVPP2_BM_LONG_FRAME_SIZE 2240 /* frame size 1664 */ 94362306a36Sopenharmony_ci#define MVPP2_BM_JUMBO_FRAME_SIZE 10432 /* frame size 9856 */ 94462306a36Sopenharmony_ci/* BM short pool packet size 94562306a36Sopenharmony_ci * These value assure that for SWF the total number 94662306a36Sopenharmony_ci * of bytes allocated for each buffer will be 512 94762306a36Sopenharmony_ci */ 94862306a36Sopenharmony_ci#define MVPP2_BM_SHORT_PKT_SIZE MVPP2_RX_MAX_PKT_SIZE(MVPP2_BM_SHORT_FRAME_SIZE) 94962306a36Sopenharmony_ci#define MVPP2_BM_LONG_PKT_SIZE MVPP2_RX_MAX_PKT_SIZE(MVPP2_BM_LONG_FRAME_SIZE) 95062306a36Sopenharmony_ci#define MVPP2_BM_JUMBO_PKT_SIZE MVPP2_RX_MAX_PKT_SIZE(MVPP2_BM_JUMBO_FRAME_SIZE) 95162306a36Sopenharmony_ci 95262306a36Sopenharmony_ci#define MVPP21_ADDR_SPACE_SZ 0 95362306a36Sopenharmony_ci#define MVPP22_ADDR_SPACE_SZ SZ_64K 95462306a36Sopenharmony_ci 95562306a36Sopenharmony_ci#define MVPP2_MAX_THREADS 9 95662306a36Sopenharmony_ci#define MVPP2_MAX_QVECS MVPP2_MAX_THREADS 95762306a36Sopenharmony_ci 95862306a36Sopenharmony_ci/* GMAC MIB Counters register definitions */ 95962306a36Sopenharmony_ci#define MVPP21_MIB_COUNTERS_OFFSET 0x1000 96062306a36Sopenharmony_ci#define MVPP21_MIB_COUNTERS_PORT_SZ 0x400 96162306a36Sopenharmony_ci#define MVPP22_MIB_COUNTERS_OFFSET 0x0 96262306a36Sopenharmony_ci#define MVPP22_MIB_COUNTERS_PORT_SZ 0x100 96362306a36Sopenharmony_ci 96462306a36Sopenharmony_ci#define MVPP2_MIB_GOOD_OCTETS_RCVD 0x0 96562306a36Sopenharmony_ci#define MVPP2_MIB_BAD_OCTETS_RCVD 0x8 96662306a36Sopenharmony_ci#define MVPP2_MIB_CRC_ERRORS_SENT 0xc 96762306a36Sopenharmony_ci#define MVPP2_MIB_UNICAST_FRAMES_RCVD 0x10 96862306a36Sopenharmony_ci#define MVPP2_MIB_BROADCAST_FRAMES_RCVD 0x18 96962306a36Sopenharmony_ci#define MVPP2_MIB_MULTICAST_FRAMES_RCVD 0x1c 97062306a36Sopenharmony_ci#define MVPP2_MIB_FRAMES_64_OCTETS 0x20 97162306a36Sopenharmony_ci#define MVPP2_MIB_FRAMES_65_TO_127_OCTETS 0x24 97262306a36Sopenharmony_ci#define MVPP2_MIB_FRAMES_128_TO_255_OCTETS 0x28 97362306a36Sopenharmony_ci#define MVPP2_MIB_FRAMES_256_TO_511_OCTETS 0x2c 97462306a36Sopenharmony_ci#define MVPP2_MIB_FRAMES_512_TO_1023_OCTETS 0x30 97562306a36Sopenharmony_ci#define MVPP2_MIB_FRAMES_1024_TO_MAX_OCTETS 0x34 97662306a36Sopenharmony_ci#define MVPP2_MIB_GOOD_OCTETS_SENT 0x38 97762306a36Sopenharmony_ci#define MVPP2_MIB_UNICAST_FRAMES_SENT 0x40 97862306a36Sopenharmony_ci#define MVPP2_MIB_MULTICAST_FRAMES_SENT 0x48 97962306a36Sopenharmony_ci#define MVPP2_MIB_BROADCAST_FRAMES_SENT 0x4c 98062306a36Sopenharmony_ci#define MVPP2_MIB_FC_SENT 0x54 98162306a36Sopenharmony_ci#define MVPP2_MIB_FC_RCVD 0x58 98262306a36Sopenharmony_ci#define MVPP2_MIB_RX_FIFO_OVERRUN 0x5c 98362306a36Sopenharmony_ci#define MVPP2_MIB_UNDERSIZE_RCVD 0x60 98462306a36Sopenharmony_ci#define MVPP2_MIB_FRAGMENTS_RCVD 0x64 98562306a36Sopenharmony_ci#define MVPP2_MIB_OVERSIZE_RCVD 0x68 98662306a36Sopenharmony_ci#define MVPP2_MIB_JABBER_RCVD 0x6c 98762306a36Sopenharmony_ci#define MVPP2_MIB_MAC_RCV_ERROR 0x70 98862306a36Sopenharmony_ci#define MVPP2_MIB_BAD_CRC_EVENT 0x74 98962306a36Sopenharmony_ci#define MVPP2_MIB_COLLISION 0x78 99062306a36Sopenharmony_ci#define MVPP2_MIB_LATE_COLLISION 0x7c 99162306a36Sopenharmony_ci 99262306a36Sopenharmony_ci#define MVPP2_MIB_COUNTERS_STATS_DELAY (1 * HZ) 99362306a36Sopenharmony_ci 99462306a36Sopenharmony_ci#define MVPP2_DESC_DMA_MASK DMA_BIT_MASK(40) 99562306a36Sopenharmony_ci 99662306a36Sopenharmony_ci/* Buffer header info bits */ 99762306a36Sopenharmony_ci#define MVPP2_B_HDR_INFO_MC_ID_MASK 0xfff 99862306a36Sopenharmony_ci#define MVPP2_B_HDR_INFO_MC_ID(info) ((info) & MVPP2_B_HDR_INFO_MC_ID_MASK) 99962306a36Sopenharmony_ci#define MVPP2_B_HDR_INFO_LAST_OFFS 12 100062306a36Sopenharmony_ci#define MVPP2_B_HDR_INFO_LAST_MASK BIT(12) 100162306a36Sopenharmony_ci#define MVPP2_B_HDR_INFO_IS_LAST(info) \ 100262306a36Sopenharmony_ci (((info) & MVPP2_B_HDR_INFO_LAST_MASK) >> MVPP2_B_HDR_INFO_LAST_OFFS) 100362306a36Sopenharmony_ci 100462306a36Sopenharmony_cistruct mvpp2_tai; 100562306a36Sopenharmony_ci 100662306a36Sopenharmony_ci/* Definitions */ 100762306a36Sopenharmony_cistruct mvpp2_dbgfs_entries; 100862306a36Sopenharmony_ci 100962306a36Sopenharmony_cistruct mvpp2_rss_table { 101062306a36Sopenharmony_ci u32 indir[MVPP22_RSS_TABLE_ENTRIES]; 101162306a36Sopenharmony_ci}; 101262306a36Sopenharmony_ci 101362306a36Sopenharmony_cistruct mvpp2_buff_hdr { 101462306a36Sopenharmony_ci __le32 next_phys_addr; 101562306a36Sopenharmony_ci __le32 next_dma_addr; 101662306a36Sopenharmony_ci __le16 byte_count; 101762306a36Sopenharmony_ci __le16 info; 101862306a36Sopenharmony_ci __le16 reserved1; /* bm_qset (for future use, BM) */ 101962306a36Sopenharmony_ci u8 next_phys_addr_high; 102062306a36Sopenharmony_ci u8 next_dma_addr_high; 102162306a36Sopenharmony_ci __le16 reserved2; 102262306a36Sopenharmony_ci __le16 reserved3; 102362306a36Sopenharmony_ci __le16 reserved4; 102462306a36Sopenharmony_ci __le16 reserved5; 102562306a36Sopenharmony_ci}; 102662306a36Sopenharmony_ci 102762306a36Sopenharmony_ci/* Shared Packet Processor resources */ 102862306a36Sopenharmony_cistruct mvpp2 { 102962306a36Sopenharmony_ci /* Shared registers' base addresses */ 103062306a36Sopenharmony_ci void __iomem *lms_base; 103162306a36Sopenharmony_ci void __iomem *iface_base; 103262306a36Sopenharmony_ci void __iomem *cm3_base; 103362306a36Sopenharmony_ci 103462306a36Sopenharmony_ci /* On PPv2.2 and PPv2.3, each "software thread" can access the base 103562306a36Sopenharmony_ci * register through a separate address space, each 64 KB apart 103662306a36Sopenharmony_ci * from each other. Typically, such address spaces will be 103762306a36Sopenharmony_ci * used per CPU. 103862306a36Sopenharmony_ci */ 103962306a36Sopenharmony_ci void __iomem *swth_base[MVPP2_MAX_THREADS]; 104062306a36Sopenharmony_ci 104162306a36Sopenharmony_ci /* On PPv2.2 and PPv2.3, some port control registers are located into 104262306a36Sopenharmony_ci * the system controller space. These registers are accessible 104362306a36Sopenharmony_ci * through a regmap. 104462306a36Sopenharmony_ci */ 104562306a36Sopenharmony_ci struct regmap *sysctrl_base; 104662306a36Sopenharmony_ci 104762306a36Sopenharmony_ci /* Common clocks */ 104862306a36Sopenharmony_ci struct clk *pp_clk; 104962306a36Sopenharmony_ci struct clk *gop_clk; 105062306a36Sopenharmony_ci struct clk *mg_clk; 105162306a36Sopenharmony_ci struct clk *mg_core_clk; 105262306a36Sopenharmony_ci struct clk *axi_clk; 105362306a36Sopenharmony_ci 105462306a36Sopenharmony_ci /* List of pointers to port structures */ 105562306a36Sopenharmony_ci int port_count; 105662306a36Sopenharmony_ci struct mvpp2_port *port_list[MVPP2_MAX_PORTS]; 105762306a36Sopenharmony_ci /* Map of enabled ports */ 105862306a36Sopenharmony_ci unsigned long port_map; 105962306a36Sopenharmony_ci 106062306a36Sopenharmony_ci struct mvpp2_tai *tai; 106162306a36Sopenharmony_ci 106262306a36Sopenharmony_ci /* Number of Tx threads used */ 106362306a36Sopenharmony_ci unsigned int nthreads; 106462306a36Sopenharmony_ci /* Map of threads needing locking */ 106562306a36Sopenharmony_ci unsigned long lock_map; 106662306a36Sopenharmony_ci 106762306a36Sopenharmony_ci /* Aggregated TXQs */ 106862306a36Sopenharmony_ci struct mvpp2_tx_queue *aggr_txqs; 106962306a36Sopenharmony_ci 107062306a36Sopenharmony_ci /* Are we using page_pool with per-cpu pools? */ 107162306a36Sopenharmony_ci int percpu_pools; 107262306a36Sopenharmony_ci 107362306a36Sopenharmony_ci /* BM pools */ 107462306a36Sopenharmony_ci struct mvpp2_bm_pool *bm_pools; 107562306a36Sopenharmony_ci 107662306a36Sopenharmony_ci /* PRS shadow table */ 107762306a36Sopenharmony_ci struct mvpp2_prs_shadow *prs_shadow; 107862306a36Sopenharmony_ci /* PRS auxiliary table for double vlan entries control */ 107962306a36Sopenharmony_ci bool *prs_double_vlans; 108062306a36Sopenharmony_ci 108162306a36Sopenharmony_ci /* Tclk value */ 108262306a36Sopenharmony_ci u32 tclk; 108362306a36Sopenharmony_ci 108462306a36Sopenharmony_ci /* HW version */ 108562306a36Sopenharmony_ci enum { MVPP21, MVPP22, MVPP23 } hw_version; 108662306a36Sopenharmony_ci 108762306a36Sopenharmony_ci /* Maximum number of RXQs per port */ 108862306a36Sopenharmony_ci unsigned int max_port_rxqs; 108962306a36Sopenharmony_ci 109062306a36Sopenharmony_ci /* Workqueue to gather hardware statistics */ 109162306a36Sopenharmony_ci char queue_name[30]; 109262306a36Sopenharmony_ci struct workqueue_struct *stats_queue; 109362306a36Sopenharmony_ci 109462306a36Sopenharmony_ci /* Debugfs root entry */ 109562306a36Sopenharmony_ci struct dentry *dbgfs_dir; 109662306a36Sopenharmony_ci 109762306a36Sopenharmony_ci /* Debugfs entries private data */ 109862306a36Sopenharmony_ci struct mvpp2_dbgfs_entries *dbgfs_entries; 109962306a36Sopenharmony_ci 110062306a36Sopenharmony_ci /* RSS Indirection tables */ 110162306a36Sopenharmony_ci struct mvpp2_rss_table *rss_tables[MVPP22_N_RSS_TABLES]; 110262306a36Sopenharmony_ci 110362306a36Sopenharmony_ci /* page_pool allocator */ 110462306a36Sopenharmony_ci struct page_pool *page_pool[MVPP2_PORT_MAX_RXQ]; 110562306a36Sopenharmony_ci 110662306a36Sopenharmony_ci /* Global TX Flow Control config */ 110762306a36Sopenharmony_ci bool global_tx_fc; 110862306a36Sopenharmony_ci 110962306a36Sopenharmony_ci /* Spinlocks for CM3 shared memory configuration */ 111062306a36Sopenharmony_ci spinlock_t mss_spinlock; 111162306a36Sopenharmony_ci}; 111262306a36Sopenharmony_ci 111362306a36Sopenharmony_cistruct mvpp2_pcpu_stats { 111462306a36Sopenharmony_ci struct u64_stats_sync syncp; 111562306a36Sopenharmony_ci u64 rx_packets; 111662306a36Sopenharmony_ci u64 rx_bytes; 111762306a36Sopenharmony_ci u64 tx_packets; 111862306a36Sopenharmony_ci u64 tx_bytes; 111962306a36Sopenharmony_ci /* XDP */ 112062306a36Sopenharmony_ci u64 xdp_redirect; 112162306a36Sopenharmony_ci u64 xdp_pass; 112262306a36Sopenharmony_ci u64 xdp_drop; 112362306a36Sopenharmony_ci u64 xdp_xmit; 112462306a36Sopenharmony_ci u64 xdp_xmit_err; 112562306a36Sopenharmony_ci u64 xdp_tx; 112662306a36Sopenharmony_ci u64 xdp_tx_err; 112762306a36Sopenharmony_ci}; 112862306a36Sopenharmony_ci 112962306a36Sopenharmony_ci/* Per-CPU port control */ 113062306a36Sopenharmony_cistruct mvpp2_port_pcpu { 113162306a36Sopenharmony_ci struct hrtimer tx_done_timer; 113262306a36Sopenharmony_ci struct net_device *dev; 113362306a36Sopenharmony_ci bool timer_scheduled; 113462306a36Sopenharmony_ci}; 113562306a36Sopenharmony_ci 113662306a36Sopenharmony_cistruct mvpp2_queue_vector { 113762306a36Sopenharmony_ci int irq; 113862306a36Sopenharmony_ci struct napi_struct napi; 113962306a36Sopenharmony_ci enum { MVPP2_QUEUE_VECTOR_SHARED, MVPP2_QUEUE_VECTOR_PRIVATE } type; 114062306a36Sopenharmony_ci int sw_thread_id; 114162306a36Sopenharmony_ci u16 sw_thread_mask; 114262306a36Sopenharmony_ci int first_rxq; 114362306a36Sopenharmony_ci int nrxqs; 114462306a36Sopenharmony_ci u32 pending_cause_rx; 114562306a36Sopenharmony_ci struct mvpp2_port *port; 114662306a36Sopenharmony_ci struct cpumask *mask; 114762306a36Sopenharmony_ci}; 114862306a36Sopenharmony_ci 114962306a36Sopenharmony_ci/* Internal represention of a Flow Steering rule */ 115062306a36Sopenharmony_cistruct mvpp2_rfs_rule { 115162306a36Sopenharmony_ci /* Rule location inside the flow*/ 115262306a36Sopenharmony_ci int loc; 115362306a36Sopenharmony_ci 115462306a36Sopenharmony_ci /* Flow type, such as TCP_V4_FLOW, IP6_FLOW, etc. */ 115562306a36Sopenharmony_ci int flow_type; 115662306a36Sopenharmony_ci 115762306a36Sopenharmony_ci /* Index of the C2 TCAM entry handling this rule */ 115862306a36Sopenharmony_ci int c2_index; 115962306a36Sopenharmony_ci 116062306a36Sopenharmony_ci /* Header fields that needs to be extracted to match this flow */ 116162306a36Sopenharmony_ci u16 hek_fields; 116262306a36Sopenharmony_ci 116362306a36Sopenharmony_ci /* CLS engine : only c2 is supported for now. */ 116462306a36Sopenharmony_ci u8 engine; 116562306a36Sopenharmony_ci 116662306a36Sopenharmony_ci /* TCAM key and mask for C2-based steering. These fields should be 116762306a36Sopenharmony_ci * encapsulated in a union should we add more engines. 116862306a36Sopenharmony_ci */ 116962306a36Sopenharmony_ci u64 c2_tcam; 117062306a36Sopenharmony_ci u64 c2_tcam_mask; 117162306a36Sopenharmony_ci 117262306a36Sopenharmony_ci struct flow_rule *flow; 117362306a36Sopenharmony_ci}; 117462306a36Sopenharmony_ci 117562306a36Sopenharmony_cistruct mvpp2_ethtool_fs { 117662306a36Sopenharmony_ci struct mvpp2_rfs_rule rule; 117762306a36Sopenharmony_ci struct ethtool_rxnfc rxnfc; 117862306a36Sopenharmony_ci}; 117962306a36Sopenharmony_ci 118062306a36Sopenharmony_cistruct mvpp2_hwtstamp_queue { 118162306a36Sopenharmony_ci struct sk_buff *skb[32]; 118262306a36Sopenharmony_ci u8 next; 118362306a36Sopenharmony_ci}; 118462306a36Sopenharmony_ci 118562306a36Sopenharmony_cistruct mvpp2_port { 118662306a36Sopenharmony_ci u8 id; 118762306a36Sopenharmony_ci 118862306a36Sopenharmony_ci /* Index of the port from the "group of ports" complex point 118962306a36Sopenharmony_ci * of view. This is specific to PPv2.2. 119062306a36Sopenharmony_ci */ 119162306a36Sopenharmony_ci int gop_id; 119262306a36Sopenharmony_ci 119362306a36Sopenharmony_ci int port_irq; 119462306a36Sopenharmony_ci 119562306a36Sopenharmony_ci struct mvpp2 *priv; 119662306a36Sopenharmony_ci 119762306a36Sopenharmony_ci /* Firmware node associated to the port */ 119862306a36Sopenharmony_ci struct fwnode_handle *fwnode; 119962306a36Sopenharmony_ci 120062306a36Sopenharmony_ci /* Per-port registers' base address */ 120162306a36Sopenharmony_ci void __iomem *base; 120262306a36Sopenharmony_ci void __iomem *stats_base; 120362306a36Sopenharmony_ci 120462306a36Sopenharmony_ci struct mvpp2_rx_queue **rxqs; 120562306a36Sopenharmony_ci unsigned int nrxqs; 120662306a36Sopenharmony_ci struct mvpp2_tx_queue **txqs; 120762306a36Sopenharmony_ci unsigned int ntxqs; 120862306a36Sopenharmony_ci struct net_device *dev; 120962306a36Sopenharmony_ci 121062306a36Sopenharmony_ci struct bpf_prog *xdp_prog; 121162306a36Sopenharmony_ci 121262306a36Sopenharmony_ci int pkt_size; 121362306a36Sopenharmony_ci 121462306a36Sopenharmony_ci /* Per-CPU port control */ 121562306a36Sopenharmony_ci struct mvpp2_port_pcpu __percpu *pcpu; 121662306a36Sopenharmony_ci 121762306a36Sopenharmony_ci /* Protect the BM refills and the Tx paths when a thread is used on more 121862306a36Sopenharmony_ci * than a single CPU. 121962306a36Sopenharmony_ci */ 122062306a36Sopenharmony_ci spinlock_t bm_lock[MVPP2_MAX_THREADS]; 122162306a36Sopenharmony_ci spinlock_t tx_lock[MVPP2_MAX_THREADS]; 122262306a36Sopenharmony_ci 122362306a36Sopenharmony_ci /* Flags */ 122462306a36Sopenharmony_ci unsigned long flags; 122562306a36Sopenharmony_ci 122662306a36Sopenharmony_ci u16 tx_ring_size; 122762306a36Sopenharmony_ci u16 rx_ring_size; 122862306a36Sopenharmony_ci struct mvpp2_pcpu_stats __percpu *stats; 122962306a36Sopenharmony_ci u64 *ethtool_stats; 123062306a36Sopenharmony_ci 123162306a36Sopenharmony_ci unsigned long state; 123262306a36Sopenharmony_ci 123362306a36Sopenharmony_ci /* Per-port work and its lock to gather hardware statistics */ 123462306a36Sopenharmony_ci struct mutex gather_stats_lock; 123562306a36Sopenharmony_ci struct delayed_work stats_work; 123662306a36Sopenharmony_ci 123762306a36Sopenharmony_ci struct device_node *of_node; 123862306a36Sopenharmony_ci 123962306a36Sopenharmony_ci phy_interface_t phy_interface; 124062306a36Sopenharmony_ci struct phylink *phylink; 124162306a36Sopenharmony_ci struct phylink_config phylink_config; 124262306a36Sopenharmony_ci struct phylink_pcs pcs_gmac; 124362306a36Sopenharmony_ci struct phylink_pcs pcs_xlg; 124462306a36Sopenharmony_ci struct phy *comphy; 124562306a36Sopenharmony_ci 124662306a36Sopenharmony_ci struct mvpp2_bm_pool *pool_long; 124762306a36Sopenharmony_ci struct mvpp2_bm_pool *pool_short; 124862306a36Sopenharmony_ci 124962306a36Sopenharmony_ci /* Index of first port's physical RXQ */ 125062306a36Sopenharmony_ci u8 first_rxq; 125162306a36Sopenharmony_ci 125262306a36Sopenharmony_ci struct mvpp2_queue_vector qvecs[MVPP2_MAX_QVECS]; 125362306a36Sopenharmony_ci unsigned int nqvecs; 125462306a36Sopenharmony_ci bool has_tx_irqs; 125562306a36Sopenharmony_ci 125662306a36Sopenharmony_ci u32 tx_time_coal; 125762306a36Sopenharmony_ci 125862306a36Sopenharmony_ci /* List of steering rules active on that port */ 125962306a36Sopenharmony_ci struct mvpp2_ethtool_fs *rfs_rules[MVPP2_N_RFS_ENTRIES_PER_FLOW]; 126062306a36Sopenharmony_ci int n_rfs_rules; 126162306a36Sopenharmony_ci 126262306a36Sopenharmony_ci /* Each port has its own view of the rss contexts, so that it can number 126362306a36Sopenharmony_ci * them from 0 126462306a36Sopenharmony_ci */ 126562306a36Sopenharmony_ci int rss_ctx[MVPP22_N_RSS_TABLES]; 126662306a36Sopenharmony_ci 126762306a36Sopenharmony_ci bool hwtstamp; 126862306a36Sopenharmony_ci bool rx_hwtstamp; 126962306a36Sopenharmony_ci enum hwtstamp_tx_types tx_hwtstamp_type; 127062306a36Sopenharmony_ci struct mvpp2_hwtstamp_queue tx_hwtstamp_queue[2]; 127162306a36Sopenharmony_ci 127262306a36Sopenharmony_ci /* Firmware TX flow control */ 127362306a36Sopenharmony_ci bool tx_fc; 127462306a36Sopenharmony_ci}; 127562306a36Sopenharmony_ci 127662306a36Sopenharmony_ci/* The mvpp2_tx_desc and mvpp2_rx_desc structures describe the 127762306a36Sopenharmony_ci * layout of the transmit and reception DMA descriptors, and their 127862306a36Sopenharmony_ci * layout is therefore defined by the hardware design 127962306a36Sopenharmony_ci */ 128062306a36Sopenharmony_ci 128162306a36Sopenharmony_ci#define MVPP2_TXD_L3_OFF_SHIFT 0 128262306a36Sopenharmony_ci#define MVPP2_TXD_IP_HLEN_SHIFT 8 128362306a36Sopenharmony_ci#define MVPP2_TXD_L4_CSUM_FRAG BIT(13) 128462306a36Sopenharmony_ci#define MVPP2_TXD_L4_CSUM_NOT BIT(14) 128562306a36Sopenharmony_ci#define MVPP2_TXD_IP_CSUM_DISABLE BIT(15) 128662306a36Sopenharmony_ci#define MVPP2_TXD_PADDING_DISABLE BIT(23) 128762306a36Sopenharmony_ci#define MVPP2_TXD_L4_UDP BIT(24) 128862306a36Sopenharmony_ci#define MVPP2_TXD_L3_IP6 BIT(26) 128962306a36Sopenharmony_ci#define MVPP2_TXD_L_DESC BIT(28) 129062306a36Sopenharmony_ci#define MVPP2_TXD_F_DESC BIT(29) 129162306a36Sopenharmony_ci 129262306a36Sopenharmony_ci#define MVPP2_RXD_ERR_SUMMARY BIT(15) 129362306a36Sopenharmony_ci#define MVPP2_RXD_ERR_CODE_MASK (BIT(13) | BIT(14)) 129462306a36Sopenharmony_ci#define MVPP2_RXD_ERR_CRC 0x0 129562306a36Sopenharmony_ci#define MVPP2_RXD_ERR_OVERRUN BIT(13) 129662306a36Sopenharmony_ci#define MVPP2_RXD_ERR_RESOURCE (BIT(13) | BIT(14)) 129762306a36Sopenharmony_ci#define MVPP2_RXD_BM_POOL_ID_OFFS 16 129862306a36Sopenharmony_ci#define MVPP2_RXD_BM_POOL_ID_MASK (BIT(16) | BIT(17) | BIT(18)) 129962306a36Sopenharmony_ci#define MVPP2_RXD_HWF_SYNC BIT(21) 130062306a36Sopenharmony_ci#define MVPP2_RXD_L4_CSUM_OK BIT(22) 130162306a36Sopenharmony_ci#define MVPP2_RXD_IP4_HEADER_ERR BIT(24) 130262306a36Sopenharmony_ci#define MVPP2_RXD_L4_TCP BIT(25) 130362306a36Sopenharmony_ci#define MVPP2_RXD_L4_UDP BIT(26) 130462306a36Sopenharmony_ci#define MVPP2_RXD_L3_IP4 BIT(28) 130562306a36Sopenharmony_ci#define MVPP2_RXD_L3_IP6 BIT(30) 130662306a36Sopenharmony_ci#define MVPP2_RXD_BUF_HDR BIT(31) 130762306a36Sopenharmony_ci 130862306a36Sopenharmony_ci/* HW TX descriptor for PPv2.1 */ 130962306a36Sopenharmony_cistruct mvpp21_tx_desc { 131062306a36Sopenharmony_ci __le32 command; /* Options used by HW for packet transmitting.*/ 131162306a36Sopenharmony_ci u8 packet_offset; /* the offset from the buffer beginning */ 131262306a36Sopenharmony_ci u8 phys_txq; /* destination queue ID */ 131362306a36Sopenharmony_ci __le16 data_size; /* data size of transmitted packet in bytes */ 131462306a36Sopenharmony_ci __le32 buf_dma_addr; /* physical addr of transmitted buffer */ 131562306a36Sopenharmony_ci __le32 buf_cookie; /* cookie for access to TX buffer in tx path */ 131662306a36Sopenharmony_ci __le32 reserved1[3]; /* hw_cmd (for future use, BM, PON, PNC) */ 131762306a36Sopenharmony_ci __le32 reserved2; /* reserved (for future use) */ 131862306a36Sopenharmony_ci}; 131962306a36Sopenharmony_ci 132062306a36Sopenharmony_ci/* HW RX descriptor for PPv2.1 */ 132162306a36Sopenharmony_cistruct mvpp21_rx_desc { 132262306a36Sopenharmony_ci __le32 status; /* info about received packet */ 132362306a36Sopenharmony_ci __le16 reserved1; /* parser_info (for future use, PnC) */ 132462306a36Sopenharmony_ci __le16 data_size; /* size of received packet in bytes */ 132562306a36Sopenharmony_ci __le32 buf_dma_addr; /* physical address of the buffer */ 132662306a36Sopenharmony_ci __le32 buf_cookie; /* cookie for access to RX buffer in rx path */ 132762306a36Sopenharmony_ci __le16 reserved2; /* gem_port_id (for future use, PON) */ 132862306a36Sopenharmony_ci __le16 reserved3; /* csum_l4 (for future use, PnC) */ 132962306a36Sopenharmony_ci u8 reserved4; /* bm_qset (for future use, BM) */ 133062306a36Sopenharmony_ci u8 reserved5; 133162306a36Sopenharmony_ci __le16 reserved6; /* classify_info (for future use, PnC) */ 133262306a36Sopenharmony_ci __le32 reserved7; /* flow_id (for future use, PnC) */ 133362306a36Sopenharmony_ci __le32 reserved8; 133462306a36Sopenharmony_ci}; 133562306a36Sopenharmony_ci 133662306a36Sopenharmony_ci/* HW TX descriptor for PPv2.2 and PPv2.3 */ 133762306a36Sopenharmony_cistruct mvpp22_tx_desc { 133862306a36Sopenharmony_ci __le32 command; 133962306a36Sopenharmony_ci u8 packet_offset; 134062306a36Sopenharmony_ci u8 phys_txq; 134162306a36Sopenharmony_ci __le16 data_size; 134262306a36Sopenharmony_ci __le32 ptp_descriptor; 134362306a36Sopenharmony_ci __le32 reserved2; 134462306a36Sopenharmony_ci __le64 buf_dma_addr_ptp; 134562306a36Sopenharmony_ci __le64 buf_cookie_misc; 134662306a36Sopenharmony_ci}; 134762306a36Sopenharmony_ci 134862306a36Sopenharmony_ci/* HW RX descriptor for PPv2.2 and PPv2.3 */ 134962306a36Sopenharmony_cistruct mvpp22_rx_desc { 135062306a36Sopenharmony_ci __le32 status; 135162306a36Sopenharmony_ci __le16 reserved1; 135262306a36Sopenharmony_ci __le16 data_size; 135362306a36Sopenharmony_ci __le32 reserved2; 135462306a36Sopenharmony_ci __le32 timestamp; 135562306a36Sopenharmony_ci __le64 buf_dma_addr_key_hash; 135662306a36Sopenharmony_ci __le64 buf_cookie_misc; 135762306a36Sopenharmony_ci}; 135862306a36Sopenharmony_ci 135962306a36Sopenharmony_ci/* Opaque type used by the driver to manipulate the HW TX and RX 136062306a36Sopenharmony_ci * descriptors 136162306a36Sopenharmony_ci */ 136262306a36Sopenharmony_cistruct mvpp2_tx_desc { 136362306a36Sopenharmony_ci union { 136462306a36Sopenharmony_ci struct mvpp21_tx_desc pp21; 136562306a36Sopenharmony_ci struct mvpp22_tx_desc pp22; 136662306a36Sopenharmony_ci }; 136762306a36Sopenharmony_ci}; 136862306a36Sopenharmony_ci 136962306a36Sopenharmony_cistruct mvpp2_rx_desc { 137062306a36Sopenharmony_ci union { 137162306a36Sopenharmony_ci struct mvpp21_rx_desc pp21; 137262306a36Sopenharmony_ci struct mvpp22_rx_desc pp22; 137362306a36Sopenharmony_ci }; 137462306a36Sopenharmony_ci}; 137562306a36Sopenharmony_ci 137662306a36Sopenharmony_cienum mvpp2_tx_buf_type { 137762306a36Sopenharmony_ci MVPP2_TYPE_SKB, 137862306a36Sopenharmony_ci MVPP2_TYPE_XDP_TX, 137962306a36Sopenharmony_ci MVPP2_TYPE_XDP_NDO, 138062306a36Sopenharmony_ci}; 138162306a36Sopenharmony_ci 138262306a36Sopenharmony_cistruct mvpp2_txq_pcpu_buf { 138362306a36Sopenharmony_ci enum mvpp2_tx_buf_type type; 138462306a36Sopenharmony_ci 138562306a36Sopenharmony_ci /* Transmitted SKB */ 138662306a36Sopenharmony_ci union { 138762306a36Sopenharmony_ci struct xdp_frame *xdpf; 138862306a36Sopenharmony_ci struct sk_buff *skb; 138962306a36Sopenharmony_ci }; 139062306a36Sopenharmony_ci 139162306a36Sopenharmony_ci /* Physical address of transmitted buffer */ 139262306a36Sopenharmony_ci dma_addr_t dma; 139362306a36Sopenharmony_ci 139462306a36Sopenharmony_ci /* Size transmitted */ 139562306a36Sopenharmony_ci size_t size; 139662306a36Sopenharmony_ci}; 139762306a36Sopenharmony_ci 139862306a36Sopenharmony_ci/* Per-CPU Tx queue control */ 139962306a36Sopenharmony_cistruct mvpp2_txq_pcpu { 140062306a36Sopenharmony_ci unsigned int thread; 140162306a36Sopenharmony_ci 140262306a36Sopenharmony_ci /* Number of Tx DMA descriptors in the descriptor ring */ 140362306a36Sopenharmony_ci int size; 140462306a36Sopenharmony_ci 140562306a36Sopenharmony_ci /* Number of currently used Tx DMA descriptor in the 140662306a36Sopenharmony_ci * descriptor ring 140762306a36Sopenharmony_ci */ 140862306a36Sopenharmony_ci int count; 140962306a36Sopenharmony_ci 141062306a36Sopenharmony_ci int wake_threshold; 141162306a36Sopenharmony_ci int stop_threshold; 141262306a36Sopenharmony_ci 141362306a36Sopenharmony_ci /* Number of Tx DMA descriptors reserved for each CPU */ 141462306a36Sopenharmony_ci int reserved_num; 141562306a36Sopenharmony_ci 141662306a36Sopenharmony_ci /* Infos about transmitted buffers */ 141762306a36Sopenharmony_ci struct mvpp2_txq_pcpu_buf *buffs; 141862306a36Sopenharmony_ci 141962306a36Sopenharmony_ci /* Index of last TX DMA descriptor that was inserted */ 142062306a36Sopenharmony_ci int txq_put_index; 142162306a36Sopenharmony_ci 142262306a36Sopenharmony_ci /* Index of the TX DMA descriptor to be cleaned up */ 142362306a36Sopenharmony_ci int txq_get_index; 142462306a36Sopenharmony_ci 142562306a36Sopenharmony_ci /* DMA buffer for TSO headers */ 142662306a36Sopenharmony_ci char *tso_headers; 142762306a36Sopenharmony_ci dma_addr_t tso_headers_dma; 142862306a36Sopenharmony_ci}; 142962306a36Sopenharmony_ci 143062306a36Sopenharmony_cistruct mvpp2_tx_queue { 143162306a36Sopenharmony_ci /* Physical number of this Tx queue */ 143262306a36Sopenharmony_ci u8 id; 143362306a36Sopenharmony_ci 143462306a36Sopenharmony_ci /* Logical number of this Tx queue */ 143562306a36Sopenharmony_ci u8 log_id; 143662306a36Sopenharmony_ci 143762306a36Sopenharmony_ci /* Number of Tx DMA descriptors in the descriptor ring */ 143862306a36Sopenharmony_ci int size; 143962306a36Sopenharmony_ci 144062306a36Sopenharmony_ci /* Number of currently used Tx DMA descriptor in the descriptor ring */ 144162306a36Sopenharmony_ci int count; 144262306a36Sopenharmony_ci 144362306a36Sopenharmony_ci /* Per-CPU control of physical Tx queues */ 144462306a36Sopenharmony_ci struct mvpp2_txq_pcpu __percpu *pcpu; 144562306a36Sopenharmony_ci 144662306a36Sopenharmony_ci u32 done_pkts_coal; 144762306a36Sopenharmony_ci 144862306a36Sopenharmony_ci /* Virtual address of thex Tx DMA descriptors array */ 144962306a36Sopenharmony_ci struct mvpp2_tx_desc *descs; 145062306a36Sopenharmony_ci 145162306a36Sopenharmony_ci /* DMA address of the Tx DMA descriptors array */ 145262306a36Sopenharmony_ci dma_addr_t descs_dma; 145362306a36Sopenharmony_ci 145462306a36Sopenharmony_ci /* Index of the last Tx DMA descriptor */ 145562306a36Sopenharmony_ci int last_desc; 145662306a36Sopenharmony_ci 145762306a36Sopenharmony_ci /* Index of the next Tx DMA descriptor to process */ 145862306a36Sopenharmony_ci int next_desc_to_proc; 145962306a36Sopenharmony_ci}; 146062306a36Sopenharmony_ci 146162306a36Sopenharmony_cistruct mvpp2_rx_queue { 146262306a36Sopenharmony_ci /* RX queue number, in the range 0-31 for physical RXQs */ 146362306a36Sopenharmony_ci u8 id; 146462306a36Sopenharmony_ci 146562306a36Sopenharmony_ci /* Num of rx descriptors in the rx descriptor ring */ 146662306a36Sopenharmony_ci int size; 146762306a36Sopenharmony_ci 146862306a36Sopenharmony_ci u32 pkts_coal; 146962306a36Sopenharmony_ci u32 time_coal; 147062306a36Sopenharmony_ci 147162306a36Sopenharmony_ci /* Virtual address of the RX DMA descriptors array */ 147262306a36Sopenharmony_ci struct mvpp2_rx_desc *descs; 147362306a36Sopenharmony_ci 147462306a36Sopenharmony_ci /* DMA address of the RX DMA descriptors array */ 147562306a36Sopenharmony_ci dma_addr_t descs_dma; 147662306a36Sopenharmony_ci 147762306a36Sopenharmony_ci /* Index of the last RX DMA descriptor */ 147862306a36Sopenharmony_ci int last_desc; 147962306a36Sopenharmony_ci 148062306a36Sopenharmony_ci /* Index of the next RX DMA descriptor to process */ 148162306a36Sopenharmony_ci int next_desc_to_proc; 148262306a36Sopenharmony_ci 148362306a36Sopenharmony_ci /* ID of port to which physical RXQ is mapped */ 148462306a36Sopenharmony_ci int port; 148562306a36Sopenharmony_ci 148662306a36Sopenharmony_ci /* Port's logic RXQ number to which physical RXQ is mapped */ 148762306a36Sopenharmony_ci int logic_rxq; 148862306a36Sopenharmony_ci 148962306a36Sopenharmony_ci /* XDP memory accounting */ 149062306a36Sopenharmony_ci struct xdp_rxq_info xdp_rxq_short; 149162306a36Sopenharmony_ci struct xdp_rxq_info xdp_rxq_long; 149262306a36Sopenharmony_ci}; 149362306a36Sopenharmony_ci 149462306a36Sopenharmony_cistruct mvpp2_bm_pool { 149562306a36Sopenharmony_ci /* Pool number in the range 0-7 */ 149662306a36Sopenharmony_ci int id; 149762306a36Sopenharmony_ci 149862306a36Sopenharmony_ci /* Buffer Pointers Pool External (BPPE) size */ 149962306a36Sopenharmony_ci int size; 150062306a36Sopenharmony_ci /* BPPE size in bytes */ 150162306a36Sopenharmony_ci int size_bytes; 150262306a36Sopenharmony_ci /* Number of buffers for this pool */ 150362306a36Sopenharmony_ci int buf_num; 150462306a36Sopenharmony_ci /* Pool buffer size */ 150562306a36Sopenharmony_ci int buf_size; 150662306a36Sopenharmony_ci /* Packet size */ 150762306a36Sopenharmony_ci int pkt_size; 150862306a36Sopenharmony_ci int frag_size; 150962306a36Sopenharmony_ci 151062306a36Sopenharmony_ci /* BPPE virtual base address */ 151162306a36Sopenharmony_ci u32 *virt_addr; 151262306a36Sopenharmony_ci /* BPPE DMA base address */ 151362306a36Sopenharmony_ci dma_addr_t dma_addr; 151462306a36Sopenharmony_ci 151562306a36Sopenharmony_ci /* Ports using BM pool */ 151662306a36Sopenharmony_ci u32 port_map; 151762306a36Sopenharmony_ci}; 151862306a36Sopenharmony_ci 151962306a36Sopenharmony_ci#define IS_TSO_HEADER(txq_pcpu, addr) \ 152062306a36Sopenharmony_ci ((addr) >= (txq_pcpu)->tso_headers_dma && \ 152162306a36Sopenharmony_ci (addr) < (txq_pcpu)->tso_headers_dma + \ 152262306a36Sopenharmony_ci (txq_pcpu)->size * TSO_HEADER_SIZE) 152362306a36Sopenharmony_ci 152462306a36Sopenharmony_ci#define MVPP2_DRIVER_NAME "mvpp2" 152562306a36Sopenharmony_ci#define MVPP2_DRIVER_VERSION "1.0" 152662306a36Sopenharmony_ci 152762306a36Sopenharmony_civoid mvpp2_write(struct mvpp2 *priv, u32 offset, u32 data); 152862306a36Sopenharmony_ciu32 mvpp2_read(struct mvpp2 *priv, u32 offset); 152962306a36Sopenharmony_ci 153062306a36Sopenharmony_civoid mvpp2_dbgfs_init(struct mvpp2 *priv, const char *name); 153162306a36Sopenharmony_ci 153262306a36Sopenharmony_civoid mvpp2_dbgfs_cleanup(struct mvpp2 *priv); 153362306a36Sopenharmony_civoid mvpp2_dbgfs_exit(void); 153462306a36Sopenharmony_ci 153562306a36Sopenharmony_civoid mvpp23_rx_fifo_fc_en(struct mvpp2 *priv, int port, bool en); 153662306a36Sopenharmony_ci 153762306a36Sopenharmony_ci#ifdef CONFIG_MVPP2_PTP 153862306a36Sopenharmony_ciint mvpp22_tai_probe(struct device *dev, struct mvpp2 *priv); 153962306a36Sopenharmony_civoid mvpp22_tai_tstamp(struct mvpp2_tai *tai, u32 tstamp, 154062306a36Sopenharmony_ci struct skb_shared_hwtstamps *hwtstamp); 154162306a36Sopenharmony_civoid mvpp22_tai_start(struct mvpp2_tai *tai); 154262306a36Sopenharmony_civoid mvpp22_tai_stop(struct mvpp2_tai *tai); 154362306a36Sopenharmony_ciint mvpp22_tai_ptp_clock_index(struct mvpp2_tai *tai); 154462306a36Sopenharmony_ci#else 154562306a36Sopenharmony_cistatic inline int mvpp22_tai_probe(struct device *dev, struct mvpp2 *priv) 154662306a36Sopenharmony_ci{ 154762306a36Sopenharmony_ci return 0; 154862306a36Sopenharmony_ci} 154962306a36Sopenharmony_cistatic inline void mvpp22_tai_tstamp(struct mvpp2_tai *tai, u32 tstamp, 155062306a36Sopenharmony_ci struct skb_shared_hwtstamps *hwtstamp) 155162306a36Sopenharmony_ci{ 155262306a36Sopenharmony_ci} 155362306a36Sopenharmony_cistatic inline void mvpp22_tai_start(struct mvpp2_tai *tai) 155462306a36Sopenharmony_ci{ 155562306a36Sopenharmony_ci} 155662306a36Sopenharmony_cistatic inline void mvpp22_tai_stop(struct mvpp2_tai *tai) 155762306a36Sopenharmony_ci{ 155862306a36Sopenharmony_ci} 155962306a36Sopenharmony_cistatic inline int mvpp22_tai_ptp_clock_index(struct mvpp2_tai *tai) 156062306a36Sopenharmony_ci{ 156162306a36Sopenharmony_ci return -1; 156262306a36Sopenharmony_ci} 156362306a36Sopenharmony_ci#endif 156462306a36Sopenharmony_ci 156562306a36Sopenharmony_cistatic inline bool mvpp22_rx_hwtstamping(struct mvpp2_port *port) 156662306a36Sopenharmony_ci{ 156762306a36Sopenharmony_ci return IS_ENABLED(CONFIG_MVPP2_PTP) && port->rx_hwtstamp; 156862306a36Sopenharmony_ci} 156962306a36Sopenharmony_ci 157062306a36Sopenharmony_ci#endif 1571