0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _MVPP2_H_
0010 #define _MVPP2_H_
0011
0012 #include <linux/interrupt.h>
0013 #include <linux/kernel.h>
0014 #include <linux/netdevice.h>
0015 #include <linux/net_tstamp.h>
0016 #include <linux/phy.h>
0017 #include <linux/phylink.h>
0018 #include <net/flow_offload.h>
0019 #include <net/page_pool.h>
0020 #include <linux/bpf.h>
0021 #include <net/xdp.h>
0022
0023
0024
0025
0026 #define MVPP2_SKB_HEADROOM min(max(XDP_PACKET_HEADROOM, NET_SKB_PAD), 224)
0027
0028 #define MVPP2_XDP_PASS 0
0029 #define MVPP2_XDP_DROPPED BIT(0)
0030 #define MVPP2_XDP_TX BIT(1)
0031 #define MVPP2_XDP_REDIR BIT(2)
0032
0033
0034 #define MVPP2_RX_DATA_FIFO_SIZE_REG(port) (0x00 + 4 * (port))
0035 #define MVPP2_RX_ATTR_FIFO_SIZE_REG(port) (0x20 + 4 * (port))
0036 #define MVPP2_RX_MIN_PKT_SIZE_REG 0x60
0037 #define MVPP2_RX_FIFO_INIT_REG 0x64
0038 #define MVPP22_TX_FIFO_THRESH_REG(port) (0x8840 + 4 * (port))
0039 #define MVPP22_TX_FIFO_SIZE_REG(port) (0x8860 + 4 * (port))
0040
0041
0042 #define MVPP2_RX_CTRL_REG(port) (0x140 + 4 * (port))
0043 #define MVPP2_RX_LOW_LATENCY_PKT_SIZE(s) (((s) & 0xfff) << 16)
0044 #define MVPP2_RX_USE_PSEUDO_FOR_CSUM_MASK BIT(31)
0045 #define MVPP2_POOL_BUF_SIZE_REG(pool) (0x180 + 4 * (pool))
0046 #define MVPP2_POOL_BUF_SIZE_OFFSET 5
0047 #define MVPP2_RXQ_CONFIG_REG(rxq) (0x800 + 4 * (rxq))
0048 #define MVPP2_SNOOP_PKT_SIZE_MASK 0x1ff
0049 #define MVPP2_SNOOP_BUF_HDR_MASK BIT(9)
0050 #define MVPP2_RXQ_POOL_SHORT_OFFS 20
0051 #define MVPP21_RXQ_POOL_SHORT_MASK 0x700000
0052 #define MVPP22_RXQ_POOL_SHORT_MASK 0xf00000
0053 #define MVPP2_RXQ_POOL_LONG_OFFS 24
0054 #define MVPP21_RXQ_POOL_LONG_MASK 0x7000000
0055 #define MVPP22_RXQ_POOL_LONG_MASK 0xf000000
0056 #define MVPP2_RXQ_PACKET_OFFSET_OFFS 28
0057 #define MVPP2_RXQ_PACKET_OFFSET_MASK 0x70000000
0058 #define MVPP2_RXQ_DISABLE_MASK BIT(31)
0059
0060
0061 #define MVPP2_MH_REG(port) (0x5040 + 4 * (port))
0062 #define MVPP2_DSA_EXTENDED BIT(5)
0063 #define MVPP2_VER_ID_REG 0x50b0
0064 #define MVPP2_VER_PP22 0x10
0065 #define MVPP2_VER_PP23 0x11
0066
0067
0068 #define MVPP2_PRS_INIT_LOOKUP_REG 0x1000
0069 #define MVPP2_PRS_PORT_LU_MAX 0xf
0070 #define MVPP2_PRS_PORT_LU_MASK(port) (0xff << ((port) * 4))
0071 #define MVPP2_PRS_PORT_LU_VAL(port, val) ((val) << ((port) * 4))
0072 #define MVPP2_PRS_INIT_OFFS_REG(port) (0x1004 + ((port) & 4))
0073 #define MVPP2_PRS_INIT_OFF_MASK(port) (0x3f << (((port) % 4) * 8))
0074 #define MVPP2_PRS_INIT_OFF_VAL(port, val) ((val) << (((port) % 4) * 8))
0075 #define MVPP2_PRS_MAX_LOOP_REG(port) (0x100c + ((port) & 4))
0076 #define MVPP2_PRS_MAX_LOOP_MASK(port) (0xff << (((port) % 4) * 8))
0077 #define MVPP2_PRS_MAX_LOOP_VAL(port, val) ((val) << (((port) % 4) * 8))
0078 #define MVPP2_PRS_TCAM_IDX_REG 0x1100
0079 #define MVPP2_PRS_TCAM_DATA_REG(idx) (0x1104 + (idx) * 4)
0080 #define MVPP2_PRS_TCAM_INV_MASK BIT(31)
0081 #define MVPP2_PRS_SRAM_IDX_REG 0x1200
0082 #define MVPP2_PRS_SRAM_DATA_REG(idx) (0x1204 + (idx) * 4)
0083 #define MVPP2_PRS_TCAM_CTRL_REG 0x1230
0084 #define MVPP2_PRS_TCAM_EN_MASK BIT(0)
0085 #define MVPP2_PRS_TCAM_HIT_IDX_REG 0x1240
0086 #define MVPP2_PRS_TCAM_HIT_CNT_REG 0x1244
0087 #define MVPP2_PRS_TCAM_HIT_CNT_MASK GENMASK(15, 0)
0088
0089
0090 #define MVPP22_RSS_INDEX 0x1500
0091 #define MVPP22_RSS_INDEX_TABLE_ENTRY(idx) (idx)
0092 #define MVPP22_RSS_INDEX_TABLE(idx) ((idx) << 8)
0093 #define MVPP22_RSS_INDEX_QUEUE(idx) ((idx) << 16)
0094 #define MVPP22_RXQ2RSS_TABLE 0x1504
0095 #define MVPP22_RSS_TABLE_POINTER(p) (p)
0096 #define MVPP22_RSS_TABLE_ENTRY 0x1508
0097 #define MVPP22_RSS_WIDTH 0x150c
0098
0099
0100 #define MVPP2_CLS_MODE_REG 0x1800
0101 #define MVPP2_CLS_MODE_ACTIVE_MASK BIT(0)
0102 #define MVPP2_CLS_PORT_WAY_REG 0x1810
0103 #define MVPP2_CLS_PORT_WAY_MASK(port) (1 << (port))
0104 #define MVPP2_CLS_LKP_INDEX_REG 0x1814
0105 #define MVPP2_CLS_LKP_INDEX_WAY_OFFS 6
0106 #define MVPP2_CLS_LKP_TBL_REG 0x1818
0107 #define MVPP2_CLS_LKP_TBL_RXQ_MASK 0xff
0108 #define MVPP2_CLS_LKP_FLOW_PTR(flow) ((flow) << 16)
0109 #define MVPP2_CLS_LKP_TBL_LOOKUP_EN_MASK BIT(25)
0110 #define MVPP2_CLS_FLOW_INDEX_REG 0x1820
0111 #define MVPP2_CLS_FLOW_TBL0_REG 0x1824
0112 #define MVPP2_CLS_FLOW_TBL0_LAST BIT(0)
0113 #define MVPP2_CLS_FLOW_TBL0_ENG_MASK 0x7
0114 #define MVPP2_CLS_FLOW_TBL0_OFFS 1
0115 #define MVPP2_CLS_FLOW_TBL0_ENG(x) ((x) << 1)
0116 #define MVPP2_CLS_FLOW_TBL0_PORT_ID_MASK 0xff
0117 #define MVPP2_CLS_FLOW_TBL0_PORT_ID(port) ((port) << 4)
0118 #define MVPP2_CLS_FLOW_TBL0_PORT_ID_SEL BIT(23)
0119 #define MVPP2_CLS_FLOW_TBL1_REG 0x1828
0120 #define MVPP2_CLS_FLOW_TBL1_N_FIELDS_MASK 0x7
0121 #define MVPP2_CLS_FLOW_TBL1_N_FIELDS(x) (x)
0122 #define MVPP2_CLS_FLOW_TBL1_LU_TYPE(lu) (((lu) & 0x3f) << 3)
0123 #define MVPP2_CLS_FLOW_TBL1_PRIO_MASK 0x3f
0124 #define MVPP2_CLS_FLOW_TBL1_PRIO(x) ((x) << 9)
0125 #define MVPP2_CLS_FLOW_TBL1_SEQ_MASK 0x7
0126 #define MVPP2_CLS_FLOW_TBL1_SEQ(x) ((x) << 15)
0127 #define MVPP2_CLS_FLOW_TBL2_REG 0x182c
0128 #define MVPP2_CLS_FLOW_TBL2_FLD_MASK 0x3f
0129 #define MVPP2_CLS_FLOW_TBL2_FLD_OFFS(n) ((n) * 6)
0130 #define MVPP2_CLS_FLOW_TBL2_FLD(n, x) ((x) << ((n) * 6))
0131 #define MVPP2_CLS_OVERSIZE_RXQ_LOW_REG(port) (0x1980 + ((port) * 4))
0132 #define MVPP2_CLS_OVERSIZE_RXQ_LOW_BITS 3
0133 #define MVPP2_CLS_OVERSIZE_RXQ_LOW_MASK 0x7
0134 #define MVPP2_CLS_SWFWD_P2HQ_REG(port) (0x19b0 + ((port) * 4))
0135 #define MVPP2_CLS_SWFWD_PCTRL_REG 0x19d0
0136 #define MVPP2_CLS_SWFWD_PCTRL_MASK(port) (1 << (port))
0137
0138
0139 #define MVPP22_CLS_C2_TCAM_IDX 0x1b00
0140 #define MVPP22_CLS_C2_TCAM_DATA0 0x1b10
0141 #define MVPP22_CLS_C2_TCAM_DATA1 0x1b14
0142 #define MVPP22_CLS_C2_TCAM_DATA2 0x1b18
0143 #define MVPP22_CLS_C2_TCAM_DATA3 0x1b1c
0144 #define MVPP22_CLS_C2_TCAM_DATA4 0x1b20
0145 #define MVPP22_CLS_C2_LU_TYPE(lu) ((lu) & 0x3f)
0146 #define MVPP22_CLS_C2_PORT_ID(port) ((port) << 8)
0147 #define MVPP22_CLS_C2_PORT_MASK (0xff << 8)
0148 #define MVPP22_CLS_C2_TCAM_INV 0x1b24
0149 #define MVPP22_CLS_C2_TCAM_INV_BIT BIT(31)
0150 #define MVPP22_CLS_C2_HIT_CTR 0x1b50
0151 #define MVPP22_CLS_C2_ACT 0x1b60
0152 #define MVPP22_CLS_C2_ACT_RSS_EN(act) (((act) & 0x3) << 19)
0153 #define MVPP22_CLS_C2_ACT_FWD(act) (((act) & 0x7) << 13)
0154 #define MVPP22_CLS_C2_ACT_QHIGH(act) (((act) & 0x3) << 11)
0155 #define MVPP22_CLS_C2_ACT_QLOW(act) (((act) & 0x3) << 9)
0156 #define MVPP22_CLS_C2_ACT_COLOR(act) ((act) & 0x7)
0157 #define MVPP22_CLS_C2_ATTR0 0x1b64
0158 #define MVPP22_CLS_C2_ATTR0_QHIGH(qh) (((qh) & 0x1f) << 24)
0159 #define MVPP22_CLS_C2_ATTR0_QHIGH_MASK 0x1f
0160 #define MVPP22_CLS_C2_ATTR0_QHIGH_OFFS 24
0161 #define MVPP22_CLS_C2_ATTR0_QLOW(ql) (((ql) & 0x7) << 21)
0162 #define MVPP22_CLS_C2_ATTR0_QLOW_MASK 0x7
0163 #define MVPP22_CLS_C2_ATTR0_QLOW_OFFS 21
0164 #define MVPP22_CLS_C2_ATTR1 0x1b68
0165 #define MVPP22_CLS_C2_ATTR2 0x1b6c
0166 #define MVPP22_CLS_C2_ATTR2_RSS_EN BIT(30)
0167 #define MVPP22_CLS_C2_ATTR3 0x1b70
0168 #define MVPP22_CLS_C2_TCAM_CTRL 0x1b90
0169 #define MVPP22_CLS_C2_TCAM_BYPASS_FIFO BIT(0)
0170
0171
0172 #define MVPP2_RXQ_NUM_REG 0x2040
0173 #define MVPP2_RXQ_DESC_ADDR_REG 0x2044
0174 #define MVPP22_DESC_ADDR_OFFS 8
0175 #define MVPP2_RXQ_DESC_SIZE_REG 0x2048
0176 #define MVPP2_RXQ_DESC_SIZE_MASK 0x3ff0
0177 #define MVPP2_RXQ_STATUS_UPDATE_REG(rxq) (0x3000 + 4 * (rxq))
0178 #define MVPP2_RXQ_NUM_PROCESSED_OFFSET 0
0179 #define MVPP2_RXQ_NUM_NEW_OFFSET 16
0180 #define MVPP2_RXQ_STATUS_REG(rxq) (0x3400 + 4 * (rxq))
0181 #define MVPP2_RXQ_OCCUPIED_MASK 0x3fff
0182 #define MVPP2_RXQ_NON_OCCUPIED_OFFSET 16
0183 #define MVPP2_RXQ_NON_OCCUPIED_MASK 0x3fff0000
0184 #define MVPP2_RXQ_THRESH_REG 0x204c
0185 #define MVPP2_OCCUPIED_THRESH_OFFSET 0
0186 #define MVPP2_OCCUPIED_THRESH_MASK 0x3fff
0187 #define MVPP2_RXQ_INDEX_REG 0x2050
0188 #define MVPP2_TXQ_NUM_REG 0x2080
0189 #define MVPP2_TXQ_DESC_ADDR_REG 0x2084
0190 #define MVPP2_TXQ_DESC_SIZE_REG 0x2088
0191 #define MVPP2_TXQ_DESC_SIZE_MASK 0x3ff0
0192 #define MVPP2_TXQ_THRESH_REG 0x2094
0193 #define MVPP2_TXQ_THRESH_OFFSET 16
0194 #define MVPP2_TXQ_THRESH_MASK 0x3fff
0195 #define MVPP2_AGGR_TXQ_UPDATE_REG 0x2090
0196 #define MVPP2_TXQ_INDEX_REG 0x2098
0197 #define MVPP2_TXQ_PREF_BUF_REG 0x209c
0198 #define MVPP2_PREF_BUF_PTR(desc) ((desc) & 0xfff)
0199 #define MVPP2_PREF_BUF_SIZE_4 (BIT(12) | BIT(13))
0200 #define MVPP2_PREF_BUF_SIZE_16 (BIT(12) | BIT(14))
0201 #define MVPP2_PREF_BUF_THRESH(val) ((val) << 17)
0202 #define MVPP2_TXQ_DRAIN_EN_MASK BIT(31)
0203 #define MVPP2_TXQ_PENDING_REG 0x20a0
0204 #define MVPP2_TXQ_PENDING_MASK 0x3fff
0205 #define MVPP2_TXQ_INT_STATUS_REG 0x20a4
0206 #define MVPP2_TXQ_SENT_REG(txq) (0x3c00 + 4 * (txq))
0207 #define MVPP2_TRANSMITTED_COUNT_OFFSET 16
0208 #define MVPP2_TRANSMITTED_COUNT_MASK 0x3fff0000
0209 #define MVPP2_TXQ_RSVD_REQ_REG 0x20b0
0210 #define MVPP2_TXQ_RSVD_REQ_Q_OFFSET 16
0211 #define MVPP2_TXQ_RSVD_RSLT_REG 0x20b4
0212 #define MVPP2_TXQ_RSVD_RSLT_MASK 0x3fff
0213 #define MVPP2_TXQ_RSVD_CLR_REG 0x20b8
0214 #define MVPP2_TXQ_RSVD_CLR_OFFSET 16
0215 #define MVPP2_AGGR_TXQ_DESC_ADDR_REG(cpu) (0x2100 + 4 * (cpu))
0216 #define MVPP22_AGGR_TXQ_DESC_ADDR_OFFS 8
0217 #define MVPP2_AGGR_TXQ_DESC_SIZE_REG(cpu) (0x2140 + 4 * (cpu))
0218 #define MVPP2_AGGR_TXQ_DESC_SIZE_MASK 0x3ff0
0219 #define MVPP2_AGGR_TXQ_STATUS_REG(cpu) (0x2180 + 4 * (cpu))
0220 #define MVPP2_AGGR_TXQ_PENDING_MASK 0x3fff
0221 #define MVPP2_AGGR_TXQ_INDEX_REG(cpu) (0x21c0 + 4 * (cpu))
0222
0223
0224 #define MVPP2_WIN_BASE(w) (0x4000 + ((w) << 2))
0225 #define MVPP2_WIN_SIZE(w) (0x4020 + ((w) << 2))
0226 #define MVPP2_WIN_REMAP(w) (0x4040 + ((w) << 2))
0227 #define MVPP2_BASE_ADDR_ENABLE 0x4060
0228
0229
0230 #define MVPP22_AXI_BM_WR_ATTR_REG 0x4100
0231 #define MVPP22_AXI_BM_RD_ATTR_REG 0x4104
0232 #define MVPP22_AXI_AGGRQ_DESCR_RD_ATTR_REG 0x4110
0233 #define MVPP22_AXI_TXQ_DESCR_WR_ATTR_REG 0x4114
0234 #define MVPP22_AXI_TXQ_DESCR_RD_ATTR_REG 0x4118
0235 #define MVPP22_AXI_RXQ_DESCR_WR_ATTR_REG 0x411c
0236 #define MVPP22_AXI_RX_DATA_WR_ATTR_REG 0x4120
0237 #define MVPP22_AXI_TX_DATA_RD_ATTR_REG 0x4130
0238 #define MVPP22_AXI_RD_NORMAL_CODE_REG 0x4150
0239 #define MVPP22_AXI_RD_SNOOP_CODE_REG 0x4154
0240 #define MVPP22_AXI_WR_NORMAL_CODE_REG 0x4160
0241 #define MVPP22_AXI_WR_SNOOP_CODE_REG 0x4164
0242
0243
0244 #define MVPP22_AXI_ATTR_CACHE_OFFS 0
0245 #define MVPP22_AXI_ATTR_DOMAIN_OFFS 12
0246
0247 #define MVPP22_AXI_CODE_CACHE_OFFS 0
0248 #define MVPP22_AXI_CODE_DOMAIN_OFFS 4
0249
0250 #define MVPP22_AXI_CODE_CACHE_NON_CACHE 0x3
0251 #define MVPP22_AXI_CODE_CACHE_WR_CACHE 0x7
0252 #define MVPP22_AXI_CODE_CACHE_RD_CACHE 0xb
0253
0254 #define MVPP22_AXI_CODE_DOMAIN_OUTER_DOM 2
0255 #define MVPP22_AXI_CODE_DOMAIN_SYSTEM 3
0256
0257
0258 #define MVPP2_ISR_TX_THRESHOLD_REG(port) (0x5140 + 4 * (port))
0259 #define MVPP2_MAX_ISR_TX_THRESHOLD 0xfffff0
0260
0261 #define MVPP2_ISR_RX_THRESHOLD_REG(rxq) (0x5200 + 4 * (rxq))
0262 #define MVPP2_MAX_ISR_RX_THRESHOLD 0xfffff0
0263 #define MVPP21_ISR_RXQ_GROUP_REG(port) (0x5400 + 4 * (port))
0264
0265 #define MVPP22_ISR_RXQ_GROUP_INDEX_REG 0x5400
0266 #define MVPP22_ISR_RXQ_GROUP_INDEX_SUBGROUP_MASK 0xf
0267 #define MVPP22_ISR_RXQ_GROUP_INDEX_GROUP_MASK 0x380
0268 #define MVPP22_ISR_RXQ_GROUP_INDEX_GROUP_OFFSET 7
0269
0270 #define MVPP22_ISR_RXQ_GROUP_INDEX_SUBGROUP_MASK 0xf
0271 #define MVPP22_ISR_RXQ_GROUP_INDEX_GROUP_MASK 0x380
0272
0273 #define MVPP22_ISR_RXQ_SUB_GROUP_CONFIG_REG 0x5404
0274 #define MVPP22_ISR_RXQ_SUB_GROUP_STARTQ_MASK 0x1f
0275 #define MVPP22_ISR_RXQ_SUB_GROUP_SIZE_MASK 0xf00
0276 #define MVPP22_ISR_RXQ_SUB_GROUP_SIZE_OFFSET 8
0277
0278 #define MVPP2_ISR_ENABLE_REG(port) (0x5420 + 4 * (port))
0279 #define MVPP2_ISR_ENABLE_INTERRUPT(mask) ((mask) & 0xffff)
0280 #define MVPP2_ISR_DISABLE_INTERRUPT(mask) (((mask) << 16) & 0xffff0000)
0281 #define MVPP2_ISR_RX_TX_CAUSE_REG(port) (0x5480 + 4 * (port))
0282 #define MVPP2_CAUSE_RXQ_OCCUP_DESC_ALL_MASK(version) \
0283 ((version) == MVPP21 ? 0xffff : 0xff)
0284 #define MVPP2_CAUSE_TXQ_OCCUP_DESC_ALL_MASK 0xff0000
0285 #define MVPP2_CAUSE_TXQ_OCCUP_DESC_ALL_OFFSET 16
0286 #define MVPP2_CAUSE_RX_FIFO_OVERRUN_MASK BIT(24)
0287 #define MVPP2_CAUSE_FCS_ERR_MASK BIT(25)
0288 #define MVPP2_CAUSE_TX_FIFO_UNDERRUN_MASK BIT(26)
0289 #define MVPP2_CAUSE_TX_EXCEPTION_SUM_MASK BIT(29)
0290 #define MVPP2_CAUSE_RX_EXCEPTION_SUM_MASK BIT(30)
0291 #define MVPP2_CAUSE_MISC_SUM_MASK BIT(31)
0292 #define MVPP2_ISR_RX_TX_MASK_REG(port) (0x54a0 + 4 * (port))
0293 #define MVPP2_ISR_PON_RX_TX_MASK_REG 0x54bc
0294 #define MVPP2_PON_CAUSE_RXQ_OCCUP_DESC_ALL_MASK 0xffff
0295 #define MVPP2_PON_CAUSE_TXP_OCCUP_DESC_ALL_MASK 0x3fc00000
0296 #define MVPP2_PON_CAUSE_MISC_SUM_MASK BIT(31)
0297 #define MVPP2_ISR_MISC_CAUSE_REG 0x55b0
0298 #define MVPP2_ISR_RX_ERR_CAUSE_REG(port) (0x5520 + 4 * (port))
0299 #define MVPP2_ISR_RX_ERR_CAUSE_NONOCC_MASK 0x00ff
0300
0301
0302 #define MVPP2_BM_POOL_BASE_REG(pool) (0x6000 + ((pool) * 4))
0303 #define MVPP2_BM_POOL_BASE_ADDR_MASK 0xfffff80
0304 #define MVPP2_BM_POOL_SIZE_REG(pool) (0x6040 + ((pool) * 4))
0305 #define MVPP2_BM_POOL_SIZE_MASK 0xfff0
0306 #define MVPP2_BM_POOL_READ_PTR_REG(pool) (0x6080 + ((pool) * 4))
0307 #define MVPP2_BM_POOL_GET_READ_PTR_MASK 0xfff0
0308 #define MVPP2_BM_POOL_PTRS_NUM_REG(pool) (0x60c0 + ((pool) * 4))
0309 #define MVPP2_BM_POOL_PTRS_NUM_MASK 0xfff0
0310 #define MVPP2_BM_BPPI_READ_PTR_REG(pool) (0x6100 + ((pool) * 4))
0311 #define MVPP2_BM_BPPI_PTRS_NUM_REG(pool) (0x6140 + ((pool) * 4))
0312 #define MVPP2_BM_BPPI_PTR_NUM_MASK 0x7ff
0313 #define MVPP22_BM_POOL_PTRS_NUM_MASK 0xfff8
0314 #define MVPP2_BM_BPPI_PREFETCH_FULL_MASK BIT(16)
0315 #define MVPP2_BM_POOL_CTRL_REG(pool) (0x6200 + ((pool) * 4))
0316 #define MVPP2_BM_START_MASK BIT(0)
0317 #define MVPP2_BM_STOP_MASK BIT(1)
0318 #define MVPP2_BM_STATE_MASK BIT(4)
0319 #define MVPP2_BM_LOW_THRESH_OFFS 8
0320 #define MVPP2_BM_LOW_THRESH_MASK 0x7f00
0321 #define MVPP2_BM_LOW_THRESH_VALUE(val) ((val) << \
0322 MVPP2_BM_LOW_THRESH_OFFS)
0323 #define MVPP2_BM_HIGH_THRESH_OFFS 16
0324 #define MVPP2_BM_HIGH_THRESH_MASK 0x7f0000
0325 #define MVPP2_BM_HIGH_THRESH_VALUE(val) ((val) << \
0326 MVPP2_BM_HIGH_THRESH_OFFS)
0327 #define MVPP2_BM_BPPI_HIGH_THRESH 0x1E
0328 #define MVPP2_BM_BPPI_LOW_THRESH 0x1C
0329 #define MVPP23_BM_BPPI_HIGH_THRESH 0x34
0330 #define MVPP23_BM_BPPI_LOW_THRESH 0x28
0331 #define MVPP2_BM_INTR_CAUSE_REG(pool) (0x6240 + ((pool) * 4))
0332 #define MVPP2_BM_RELEASED_DELAY_MASK BIT(0)
0333 #define MVPP2_BM_ALLOC_FAILED_MASK BIT(1)
0334 #define MVPP2_BM_BPPE_EMPTY_MASK BIT(2)
0335 #define MVPP2_BM_BPPE_FULL_MASK BIT(3)
0336 #define MVPP2_BM_AVAILABLE_BP_LOW_MASK BIT(4)
0337 #define MVPP2_BM_INTR_MASK_REG(pool) (0x6280 + ((pool) * 4))
0338 #define MVPP2_BM_PHY_ALLOC_REG(pool) (0x6400 + ((pool) * 4))
0339 #define MVPP2_BM_PHY_ALLOC_GRNTD_MASK BIT(0)
0340 #define MVPP2_BM_VIRT_ALLOC_REG 0x6440
0341 #define MVPP22_BM_ADDR_HIGH_ALLOC 0x6444
0342 #define MVPP22_BM_ADDR_HIGH_PHYS_MASK 0xff
0343 #define MVPP22_BM_ADDR_HIGH_VIRT_MASK 0xff00
0344 #define MVPP22_BM_ADDR_HIGH_VIRT_SHIFT 8
0345 #define MVPP2_BM_PHY_RLS_REG(pool) (0x6480 + ((pool) * 4))
0346 #define MVPP2_BM_PHY_RLS_MC_BUFF_MASK BIT(0)
0347 #define MVPP2_BM_PHY_RLS_PRIO_EN_MASK BIT(1)
0348 #define MVPP2_BM_PHY_RLS_GRNTD_MASK BIT(2)
0349 #define MVPP2_BM_VIRT_RLS_REG 0x64c0
0350 #define MVPP22_BM_ADDR_HIGH_RLS_REG 0x64c4
0351 #define MVPP22_BM_ADDR_HIGH_PHYS_RLS_MASK 0xff
0352 #define MVPP22_BM_ADDR_HIGH_VIRT_RLS_MASK 0xff00
0353 #define MVPP22_BM_ADDR_HIGH_VIRT_RLS_SHIFT 8
0354
0355
0356 #define MVPP2_OVERRUN_ETH_DROP 0x7000
0357 #define MVPP2_CLS_ETH_DROP 0x7020
0358
0359 #define MVPP22_BM_POOL_BASE_ADDR_HIGH_REG 0x6310
0360 #define MVPP22_BM_POOL_BASE_ADDR_HIGH_MASK 0xff
0361 #define MVPP23_BM_8POOL_MODE BIT(8)
0362
0363
0364 #define MVPP2_CTRS_IDX 0x7040
0365 #define MVPP22_CTRS_TX_CTR(port, txq) ((txq) | ((port) << 3) | BIT(7))
0366 #define MVPP2_TX_DESC_ENQ_CTR 0x7100
0367 #define MVPP2_TX_DESC_ENQ_TO_DDR_CTR 0x7104
0368 #define MVPP2_TX_BUFF_ENQ_TO_DDR_CTR 0x7108
0369 #define MVPP2_TX_DESC_ENQ_HW_FWD_CTR 0x710c
0370 #define MVPP2_RX_DESC_ENQ_CTR 0x7120
0371 #define MVPP2_TX_PKTS_DEQ_CTR 0x7130
0372 #define MVPP2_TX_PKTS_FULL_QUEUE_DROP_CTR 0x7200
0373 #define MVPP2_TX_PKTS_EARLY_DROP_CTR 0x7204
0374 #define MVPP2_TX_PKTS_BM_DROP_CTR 0x7208
0375 #define MVPP2_TX_PKTS_BM_MC_DROP_CTR 0x720c
0376 #define MVPP2_RX_PKTS_FULL_QUEUE_DROP_CTR 0x7220
0377 #define MVPP2_RX_PKTS_EARLY_DROP_CTR 0x7224
0378 #define MVPP2_RX_PKTS_BM_DROP_CTR 0x7228
0379 #define MVPP2_CLS_DEC_TBL_HIT_CTR 0x7700
0380 #define MVPP2_CLS_FLOW_TBL_HIT_CTR 0x7704
0381
0382
0383 #define MVPP2_TXP_SCHED_PORT_INDEX_REG 0x8000
0384 #define MVPP2_TXP_SCHED_Q_CMD_REG 0x8004
0385 #define MVPP2_TXP_SCHED_ENQ_MASK 0xff
0386 #define MVPP2_TXP_SCHED_DISQ_OFFSET 8
0387 #define MVPP2_TXP_SCHED_CMD_1_REG 0x8010
0388 #define MVPP2_TXP_SCHED_FIXED_PRIO_REG 0x8014
0389 #define MVPP2_TXP_SCHED_PERIOD_REG 0x8018
0390 #define MVPP2_TXP_SCHED_MTU_REG 0x801c
0391 #define MVPP2_TXP_MTU_MAX 0x7FFFF
0392 #define MVPP2_TXP_SCHED_REFILL_REG 0x8020
0393 #define MVPP2_TXP_REFILL_TOKENS_ALL_MASK 0x7ffff
0394 #define MVPP2_TXP_REFILL_PERIOD_ALL_MASK 0x3ff00000
0395 #define MVPP2_TXP_REFILL_PERIOD_MASK(v) ((v) << 20)
0396 #define MVPP2_TXP_SCHED_TOKEN_SIZE_REG 0x8024
0397 #define MVPP2_TXP_TOKEN_SIZE_MAX 0xffffffff
0398 #define MVPP2_TXQ_SCHED_REFILL_REG(q) (0x8040 + ((q) << 2))
0399 #define MVPP2_TXQ_REFILL_TOKENS_ALL_MASK 0x7ffff
0400 #define MVPP2_TXQ_REFILL_PERIOD_ALL_MASK 0x3ff00000
0401 #define MVPP2_TXQ_REFILL_PERIOD_MASK(v) ((v) << 20)
0402 #define MVPP2_TXQ_SCHED_TOKEN_SIZE_REG(q) (0x8060 + ((q) << 2))
0403 #define MVPP2_TXQ_TOKEN_SIZE_MAX 0x7fffffff
0404 #define MVPP2_TXQ_SCHED_TOKEN_CNTR_REG(q) (0x8080 + ((q) << 2))
0405 #define MVPP2_TXQ_TOKEN_CNTR_MAX 0xffffffff
0406
0407
0408 #define MVPP2_TX_SNOOP_REG 0x8800
0409 #define MVPP2_TX_PORT_FLUSH_REG 0x8810
0410 #define MVPP2_TX_PORT_FLUSH_MASK(port) (1 << (port))
0411
0412
0413 #define MVPP2_SRC_ADDR_MIDDLE 0x24
0414 #define MVPP2_SRC_ADDR_HIGH 0x28
0415 #define MVPP2_PHY_AN_CFG0_REG 0x34
0416 #define MVPP2_PHY_AN_STOP_SMI0_MASK BIT(7)
0417 #define MVPP2_MNG_EXTENDED_GLOBAL_CTRL_REG 0x305c
0418 #define MVPP2_EXT_GLOBAL_CTRL_DEFAULT 0x27
0419
0420
0421 #define MVPP2_GMAC_CTRL_0_REG 0x0
0422 #define MVPP2_GMAC_PORT_EN_MASK BIT(0)
0423 #define MVPP2_GMAC_PORT_TYPE_MASK BIT(1)
0424 #define MVPP2_GMAC_MAX_RX_SIZE_OFFS 2
0425 #define MVPP2_GMAC_MAX_RX_SIZE_MASK 0x7ffc
0426 #define MVPP2_GMAC_MIB_CNTR_EN_MASK BIT(15)
0427 #define MVPP2_GMAC_CTRL_1_REG 0x4
0428 #define MVPP2_GMAC_PERIODIC_XON_EN_MASK BIT(1)
0429 #define MVPP2_GMAC_GMII_LB_EN_MASK BIT(5)
0430 #define MVPP2_GMAC_PCS_LB_EN_BIT 6
0431 #define MVPP2_GMAC_PCS_LB_EN_MASK BIT(6)
0432 #define MVPP2_GMAC_SA_LOW_OFFS 7
0433 #define MVPP2_GMAC_CTRL_2_REG 0x8
0434 #define MVPP2_GMAC_INBAND_AN_MASK BIT(0)
0435 #define MVPP2_GMAC_FLOW_CTRL_MASK GENMASK(2, 1)
0436 #define MVPP2_GMAC_PCS_ENABLE_MASK BIT(3)
0437 #define MVPP2_GMAC_INTERNAL_CLK_MASK BIT(4)
0438 #define MVPP2_GMAC_DISABLE_PADDING BIT(5)
0439 #define MVPP2_GMAC_PORT_RESET_MASK BIT(6)
0440 #define MVPP2_GMAC_AUTONEG_CONFIG 0xc
0441 #define MVPP2_GMAC_FORCE_LINK_DOWN BIT(0)
0442 #define MVPP2_GMAC_FORCE_LINK_PASS BIT(1)
0443 #define MVPP2_GMAC_IN_BAND_AUTONEG BIT(2)
0444 #define MVPP2_GMAC_IN_BAND_AUTONEG_BYPASS BIT(3)
0445 #define MVPP2_GMAC_IN_BAND_RESTART_AN BIT(4)
0446 #define MVPP2_GMAC_CONFIG_MII_SPEED BIT(5)
0447 #define MVPP2_GMAC_CONFIG_GMII_SPEED BIT(6)
0448 #define MVPP2_GMAC_AN_SPEED_EN BIT(7)
0449 #define MVPP2_GMAC_FC_ADV_EN BIT(9)
0450 #define MVPP2_GMAC_FC_ADV_ASM_EN BIT(10)
0451 #define MVPP2_GMAC_FLOW_CTRL_AUTONEG BIT(11)
0452 #define MVPP2_GMAC_CONFIG_FULL_DUPLEX BIT(12)
0453 #define MVPP2_GMAC_AN_DUPLEX_EN BIT(13)
0454 #define MVPP2_GMAC_STATUS0 0x10
0455 #define MVPP2_GMAC_STATUS0_LINK_UP BIT(0)
0456 #define MVPP2_GMAC_STATUS0_GMII_SPEED BIT(1)
0457 #define MVPP2_GMAC_STATUS0_MII_SPEED BIT(2)
0458 #define MVPP2_GMAC_STATUS0_FULL_DUPLEX BIT(3)
0459 #define MVPP2_GMAC_STATUS0_RX_PAUSE BIT(4)
0460 #define MVPP2_GMAC_STATUS0_TX_PAUSE BIT(5)
0461 #define MVPP2_GMAC_STATUS0_AN_COMPLETE BIT(11)
0462 #define MVPP2_GMAC_PORT_FIFO_CFG_1_REG 0x1c
0463 #define MVPP2_GMAC_TX_FIFO_MIN_TH_OFFS 6
0464 #define MVPP2_GMAC_TX_FIFO_MIN_TH_ALL_MASK 0x1fc0
0465 #define MVPP2_GMAC_TX_FIFO_MIN_TH_MASK(v) (((v) << 6) & \
0466 MVPP2_GMAC_TX_FIFO_MIN_TH_ALL_MASK)
0467 #define MVPP22_GMAC_INT_STAT 0x20
0468 #define MVPP22_GMAC_INT_STAT_LINK BIT(1)
0469 #define MVPP22_GMAC_INT_MASK 0x24
0470 #define MVPP22_GMAC_INT_MASK_LINK_STAT BIT(1)
0471 #define MVPP22_GMAC_CTRL_4_REG 0x90
0472 #define MVPP22_CTRL4_EXT_PIN_GMII_SEL BIT(0)
0473 #define MVPP22_CTRL4_RX_FC_EN BIT(3)
0474 #define MVPP22_CTRL4_TX_FC_EN BIT(4)
0475 #define MVPP22_CTRL4_DP_CLK_SEL BIT(5)
0476 #define MVPP22_CTRL4_SYNC_BYPASS_DIS BIT(6)
0477 #define MVPP22_CTRL4_QSGMII_BYPASS_ACTIVE BIT(7)
0478 #define MVPP22_GMAC_INT_SUM_STAT 0xa0
0479 #define MVPP22_GMAC_INT_SUM_STAT_INTERNAL BIT(1)
0480 #define MVPP22_GMAC_INT_SUM_STAT_PTP BIT(2)
0481 #define MVPP22_GMAC_INT_SUM_MASK 0xa4
0482 #define MVPP22_GMAC_INT_SUM_MASK_LINK_STAT BIT(1)
0483 #define MVPP22_GMAC_INT_SUM_MASK_PTP BIT(2)
0484
0485
0486
0487
0488 #define MVPP22_XLG_CTRL0_REG 0x100
0489 #define MVPP22_XLG_CTRL0_PORT_EN BIT(0)
0490 #define MVPP22_XLG_CTRL0_MAC_RESET_DIS BIT(1)
0491 #define MVPP22_XLG_CTRL0_FORCE_LINK_DOWN BIT(2)
0492 #define MVPP22_XLG_CTRL0_FORCE_LINK_PASS BIT(3)
0493 #define MVPP22_XLG_CTRL0_RX_FLOW_CTRL_EN BIT(7)
0494 #define MVPP22_XLG_CTRL0_TX_FLOW_CTRL_EN BIT(8)
0495 #define MVPP22_XLG_CTRL0_MIB_CNT_DIS BIT(14)
0496 #define MVPP22_XLG_CTRL1_REG 0x104
0497 #define MVPP22_XLG_CTRL1_FRAMESIZELIMIT_OFFS 0
0498 #define MVPP22_XLG_CTRL1_FRAMESIZELIMIT_MASK 0x1fff
0499 #define MVPP22_XLG_STATUS 0x10c
0500 #define MVPP22_XLG_STATUS_LINK_UP BIT(0)
0501 #define MVPP22_XLG_INT_STAT 0x114
0502 #define MVPP22_XLG_INT_STAT_LINK BIT(1)
0503 #define MVPP22_XLG_INT_MASK 0x118
0504 #define MVPP22_XLG_INT_MASK_LINK BIT(1)
0505 #define MVPP22_XLG_CTRL3_REG 0x11c
0506 #define MVPP22_XLG_CTRL3_MACMODESELECT_MASK (7 << 13)
0507 #define MVPP22_XLG_CTRL3_MACMODESELECT_GMAC (0 << 13)
0508 #define MVPP22_XLG_CTRL3_MACMODESELECT_10G (1 << 13)
0509 #define MVPP22_XLG_EXT_INT_STAT 0x158
0510 #define MVPP22_XLG_EXT_INT_STAT_XLG BIT(1)
0511 #define MVPP22_XLG_EXT_INT_STAT_PTP BIT(7)
0512 #define MVPP22_XLG_EXT_INT_MASK 0x15c
0513 #define MVPP22_XLG_EXT_INT_MASK_XLG BIT(1)
0514 #define MVPP22_XLG_EXT_INT_MASK_GIG BIT(2)
0515 #define MVPP22_XLG_EXT_INT_MASK_PTP BIT(7)
0516 #define MVPP22_XLG_CTRL4_REG 0x184
0517 #define MVPP22_XLG_CTRL4_FWD_FC BIT(5)
0518 #define MVPP22_XLG_CTRL4_FWD_PFC BIT(6)
0519 #define MVPP22_XLG_CTRL4_MACMODSELECT_GMAC BIT(12)
0520 #define MVPP22_XLG_CTRL4_EN_IDLE_CHECK BIT(14)
0521
0522
0523 #define MVPP22_SMI_MISC_CFG_REG 0x1204
0524 #define MVPP22_SMI_POLLING_EN BIT(10)
0525
0526
0527 #define MVPP22_TAI_INT_CAUSE 0x1400
0528 #define MVPP22_TAI_INT_MASK 0x1404
0529 #define MVPP22_TAI_CR0 0x1408
0530 #define MVPP22_TAI_CR1 0x140c
0531 #define MVPP22_TAI_TCFCR0 0x1410
0532 #define MVPP22_TAI_TCFCR1 0x1414
0533 #define MVPP22_TAI_TCFCR2 0x1418
0534 #define MVPP22_TAI_FATWR 0x141c
0535 #define MVPP22_TAI_TOD_STEP_NANO_CR 0x1420
0536 #define MVPP22_TAI_TOD_STEP_FRAC_HIGH 0x1424
0537 #define MVPP22_TAI_TOD_STEP_FRAC_LOW 0x1428
0538 #define MVPP22_TAI_TAPDC_HIGH 0x142c
0539 #define MVPP22_TAI_TAPDC_LOW 0x1430
0540 #define MVPP22_TAI_TGTOD_SEC_HIGH 0x1434
0541 #define MVPP22_TAI_TGTOD_SEC_MED 0x1438
0542 #define MVPP22_TAI_TGTOD_SEC_LOW 0x143c
0543 #define MVPP22_TAI_TGTOD_NANO_HIGH 0x1440
0544 #define MVPP22_TAI_TGTOD_NANO_LOW 0x1444
0545 #define MVPP22_TAI_TGTOD_FRAC_HIGH 0x1448
0546 #define MVPP22_TAI_TGTOD_FRAC_LOW 0x144c
0547 #define MVPP22_TAI_TLV_SEC_HIGH 0x1450
0548 #define MVPP22_TAI_TLV_SEC_MED 0x1454
0549 #define MVPP22_TAI_TLV_SEC_LOW 0x1458
0550 #define MVPP22_TAI_TLV_NANO_HIGH 0x145c
0551 #define MVPP22_TAI_TLV_NANO_LOW 0x1460
0552 #define MVPP22_TAI_TLV_FRAC_HIGH 0x1464
0553 #define MVPP22_TAI_TLV_FRAC_LOW 0x1468
0554 #define MVPP22_TAI_TCV0_SEC_HIGH 0x146c
0555 #define MVPP22_TAI_TCV0_SEC_MED 0x1470
0556 #define MVPP22_TAI_TCV0_SEC_LOW 0x1474
0557 #define MVPP22_TAI_TCV0_NANO_HIGH 0x1478
0558 #define MVPP22_TAI_TCV0_NANO_LOW 0x147c
0559 #define MVPP22_TAI_TCV0_FRAC_HIGH 0x1480
0560 #define MVPP22_TAI_TCV0_FRAC_LOW 0x1484
0561 #define MVPP22_TAI_TCV1_SEC_HIGH 0x1488
0562 #define MVPP22_TAI_TCV1_SEC_MED 0x148c
0563 #define MVPP22_TAI_TCV1_SEC_LOW 0x1490
0564 #define MVPP22_TAI_TCV1_NANO_HIGH 0x1494
0565 #define MVPP22_TAI_TCV1_NANO_LOW 0x1498
0566 #define MVPP22_TAI_TCV1_FRAC_HIGH 0x149c
0567 #define MVPP22_TAI_TCV1_FRAC_LOW 0x14a0
0568 #define MVPP22_TAI_TCSR 0x14a4
0569 #define MVPP22_TAI_TUC_LSB 0x14a8
0570 #define MVPP22_TAI_GFM_SEC_HIGH 0x14ac
0571 #define MVPP22_TAI_GFM_SEC_MED 0x14b0
0572 #define MVPP22_TAI_GFM_SEC_LOW 0x14b4
0573 #define MVPP22_TAI_GFM_NANO_HIGH 0x14b8
0574 #define MVPP22_TAI_GFM_NANO_LOW 0x14bc
0575 #define MVPP22_TAI_GFM_FRAC_HIGH 0x14c0
0576 #define MVPP22_TAI_GFM_FRAC_LOW 0x14c4
0577 #define MVPP22_TAI_PCLK_DA_HIGH 0x14c8
0578 #define MVPP22_TAI_PCLK_DA_LOW 0x14cc
0579 #define MVPP22_TAI_CTCR 0x14d0
0580 #define MVPP22_TAI_PCLK_CCC_HIGH 0x14d4
0581 #define MVPP22_TAI_PCLK_CCC_LOW 0x14d8
0582 #define MVPP22_TAI_DTC_HIGH 0x14dc
0583 #define MVPP22_TAI_DTC_LOW 0x14e0
0584 #define MVPP22_TAI_CCC_HIGH 0x14e4
0585 #define MVPP22_TAI_CCC_LOW 0x14e8
0586 #define MVPP22_TAI_ICICE 0x14f4
0587 #define MVPP22_TAI_ICICC_LOW 0x14f8
0588 #define MVPP22_TAI_TUC_MSB 0x14fc
0589
0590 #define MVPP22_GMAC_BASE(port) (0x7000 + (port) * 0x1000 + 0xe00)
0591
0592 #define MVPP2_CAUSE_TXQ_SENT_DESC_ALL_MASK 0xff
0593
0594
0595 #define MVPP2_QUEUE_NEXT_DESC(q, index) \
0596 (((index) < (q)->last_desc) ? ((index) + 1) : 0)
0597
0598
0599 #define MVPP22_MPCS_BASE(port) (0x7000 + (port) * 0x1000)
0600 #define MVPP22_MPCS_CTRL 0x14
0601 #define MVPP22_MPCS_CTRL_FWD_ERR_CONN BIT(10)
0602 #define MVPP22_MPCS_CLK_RESET 0x14c
0603 #define MAC_CLK_RESET_SD_TX BIT(0)
0604 #define MAC_CLK_RESET_SD_RX BIT(1)
0605 #define MAC_CLK_RESET_MAC BIT(2)
0606 #define MVPP22_MPCS_CLK_RESET_DIV_RATIO(n) ((n) << 4)
0607 #define MVPP22_MPCS_CLK_RESET_DIV_SET BIT(11)
0608
0609
0610 #define MVPP22_FCA_BASE(port) (0x7600 + (port) * 0x1000)
0611 #define MVPP22_FCA_REG_SIZE 16
0612 #define MVPP22_FCA_REG_MASK 0xFFFF
0613 #define MVPP22_FCA_CONTROL_REG 0x0
0614 #define MVPP22_FCA_ENABLE_PERIODIC BIT(11)
0615 #define MVPP22_PERIODIC_COUNTER_LSB_REG (0x110)
0616 #define MVPP22_PERIODIC_COUNTER_MSB_REG (0x114)
0617
0618
0619 #define MVPP22_XPCS_BASE(port) (0x7400 + (port) * 0x1000)
0620 #define MVPP22_XPCS_CFG0 0x0
0621 #define MVPP22_XPCS_CFG0_RESET_DIS BIT(0)
0622 #define MVPP22_XPCS_CFG0_PCS_MODE(n) ((n) << 3)
0623 #define MVPP22_XPCS_CFG0_ACTIVE_LANE(n) ((n) << 5)
0624
0625
0626 #define MVPP22_PTP_BASE(port) (0x7800 + (port * 0x1000))
0627 #define MVPP22_PTP_INT_CAUSE 0x00
0628 #define MVPP22_PTP_INT_CAUSE_QUEUE1 BIT(6)
0629 #define MVPP22_PTP_INT_CAUSE_QUEUE0 BIT(5)
0630 #define MVPP22_PTP_INT_MASK 0x04
0631 #define MVPP22_PTP_INT_MASK_QUEUE1 BIT(6)
0632 #define MVPP22_PTP_INT_MASK_QUEUE0 BIT(5)
0633 #define MVPP22_PTP_GCR 0x08
0634 #define MVPP22_PTP_GCR_RX_RESET BIT(13)
0635 #define MVPP22_PTP_GCR_TX_RESET BIT(1)
0636 #define MVPP22_PTP_GCR_TSU_ENABLE BIT(0)
0637 #define MVPP22_PTP_TX_Q0_R0 0x0c
0638 #define MVPP22_PTP_TX_Q0_R1 0x10
0639 #define MVPP22_PTP_TX_Q0_R2 0x14
0640 #define MVPP22_PTP_TX_Q1_R0 0x18
0641 #define MVPP22_PTP_TX_Q1_R1 0x1c
0642 #define MVPP22_PTP_TX_Q1_R2 0x20
0643 #define MVPP22_PTP_TPCR 0x24
0644 #define MVPP22_PTP_V1PCR 0x28
0645 #define MVPP22_PTP_V2PCR 0x2c
0646 #define MVPP22_PTP_Y1731PCR 0x30
0647 #define MVPP22_PTP_NTPTSPCR 0x34
0648 #define MVPP22_PTP_NTPRXPCR 0x38
0649 #define MVPP22_PTP_NTPTXPCR 0x3c
0650 #define MVPP22_PTP_WAMPPCR 0x40
0651 #define MVPP22_PTP_NAPCR 0x44
0652 #define MVPP22_PTP_FAPCR 0x48
0653 #define MVPP22_PTP_CAPCR 0x50
0654 #define MVPP22_PTP_ATAPCR 0x54
0655 #define MVPP22_PTP_ACTAPCR 0x58
0656 #define MVPP22_PTP_CATAPCR 0x5c
0657 #define MVPP22_PTP_CACTAPCR 0x60
0658 #define MVPP22_PTP_AITAPCR 0x64
0659 #define MVPP22_PTP_CAITAPCR 0x68
0660 #define MVPP22_PTP_CITAPCR 0x6c
0661 #define MVPP22_PTP_NTP_OFF_HIGH 0x70
0662 #define MVPP22_PTP_NTP_OFF_LOW 0x74
0663 #define MVPP22_PTP_TX_PIPE_STATUS_DELAY 0x78
0664
0665
0666 #define GENCONF_SOFT_RESET1 0x1108
0667 #define GENCONF_SOFT_RESET1_GOP BIT(6)
0668 #define GENCONF_PORT_CTRL0 0x1110
0669 #define GENCONF_PORT_CTRL0_BUS_WIDTH_SELECT BIT(1)
0670 #define GENCONF_PORT_CTRL0_RX_DATA_SAMPLE BIT(29)
0671 #define GENCONF_PORT_CTRL0_CLK_DIV_PHASE_CLR BIT(31)
0672 #define GENCONF_PORT_CTRL1 0x1114
0673 #define GENCONF_PORT_CTRL1_EN(p) BIT(p)
0674 #define GENCONF_PORT_CTRL1_RESET(p) (BIT(p) << 28)
0675 #define GENCONF_CTRL0 0x1120
0676 #define GENCONF_CTRL0_PORT2_RGMII BIT(0)
0677 #define GENCONF_CTRL0_PORT3_RGMII_MII BIT(1)
0678 #define GENCONF_CTRL0_PORT3_RGMII BIT(2)
0679
0680
0681
0682
0683 #define MVPP2_TXDONE_COAL_PKTS_THRESH 64
0684 #define MVPP2_TXDONE_HRTIMER_PERIOD_NS 1000000UL
0685 #define MVPP2_TXDONE_COAL_USEC 1000
0686 #define MVPP2_RX_COAL_PKTS 32
0687 #define MVPP2_RX_COAL_USEC 64
0688
0689
0690
0691
0692
0693
0694
0695
0696
0697 #define MVPP2_MH_SIZE 2
0698 #define MVPP2_ETH_TYPE_LEN 2
0699 #define MVPP2_PPPOE_HDR_SIZE 8
0700 #define MVPP2_VLAN_TAG_LEN 4
0701 #define MVPP2_VLAN_TAG_EDSA_LEN 8
0702
0703
0704 #define MVPP2_IP_LBDT_TYPE 0xfffa
0705
0706 #define MVPP2_TX_CSUM_MAX_SIZE 9800
0707
0708
0709 #define MVPP2_TX_DISABLE_TIMEOUT_MSEC 1000
0710 #define MVPP2_TX_PENDING_TIMEOUT_MSEC 1000
0711
0712 #define MVPP2_TX_MTU_MAX 0x7ffff
0713
0714
0715 #define MVPP2_MAX_TCONT 16
0716
0717
0718 #define MVPP2_MAX_PORTS 4
0719
0720
0721 #define MVPP2_LOOPBACK_PORT_INDEX 3
0722
0723
0724 #define MVPP2_MAX_TXQ 8
0725
0726
0727
0728
0729
0730 #define MVPP2_MAX_TSO_SEGS 300
0731 #define MVPP2_MAX_SKB_DESCS (MVPP2_MAX_TSO_SEGS * 2 + MAX_SKB_FRAGS)
0732
0733
0734 #define MVPP2_PORT_MAX_RXQ 32
0735
0736
0737 #define MVPP2_MAX_RXD_MAX 2048
0738 #define MVPP2_MAX_RXD_DFLT 1024
0739
0740
0741 #define MVPP2_MAX_TXD_MAX 2048
0742 #define MVPP2_MAX_TXD_DFLT 1024
0743
0744
0745 #define MVPP2_CPU_DESC_CHUNK 64
0746
0747
0748 #define MVPP2_AGGR_TXQ_SIZE 256
0749
0750
0751 #define MVPP2_DESC_ALIGNED_SIZE 32
0752
0753
0754 #define MVPP2_TX_DESC_ALIGN (MVPP2_DESC_ALIGNED_SIZE - 1)
0755
0756
0757 #define MVPP2_RX_FIFO_PORT_DATA_SIZE_44KB 0xb000
0758 #define MVPP2_RX_FIFO_PORT_DATA_SIZE_32KB 0x8000
0759 #define MVPP2_RX_FIFO_PORT_DATA_SIZE_8KB 0x2000
0760 #define MVPP2_RX_FIFO_PORT_DATA_SIZE_4KB 0x1000
0761 #define MVPP2_RX_FIFO_PORT_ATTR_SIZE(data_size) ((data_size) >> 6)
0762 #define MVPP2_RX_FIFO_PORT_ATTR_SIZE_4KB 0x40
0763 #define MVPP2_RX_FIFO_PORT_MIN_PKT 0x80
0764
0765
0766 #define MVPP22_TX_FIFO_DATA_SIZE_18KB 18
0767 #define MVPP22_TX_FIFO_DATA_SIZE_10KB 10
0768 #define MVPP22_TX_FIFO_DATA_SIZE_1KB 1
0769 #define MVPP2_TX_FIFO_THRESHOLD_MIN 256
0770 #define MVPP2_TX_FIFO_THRESHOLD(kb) \
0771 ((kb) * 1024 - MVPP2_TX_FIFO_THRESHOLD_MIN)
0772
0773
0774 #define MVPP23_PORT0_FIFO_TRSH (9 * 1024)
0775 #define MVPP23_PORT1_FIFO_TRSH (4 * 1024)
0776 #define MVPP23_PORT2_FIFO_TRSH (2 * 1024)
0777
0778
0779 #define MVPP2_RX_FC_REG(port) (0x150 + 4 * (port))
0780 #define MVPP2_RX_FC_EN BIT(24)
0781 #define MVPP2_RX_FC_TRSH_OFFS 16
0782 #define MVPP2_RX_FC_TRSH_MASK (0xFF << MVPP2_RX_FC_TRSH_OFFS)
0783 #define MVPP2_RX_FC_TRSH_UNIT 256
0784
0785
0786 #define MSS_FC_COM_REG 0
0787 #define FLOW_CONTROL_ENABLE_BIT BIT(0)
0788 #define FLOW_CONTROL_UPDATE_COMMAND_BIT BIT(31)
0789 #define FC_QUANTA 0xFFFF
0790 #define FC_CLK_DIVIDER 100
0791
0792 #define MSS_RXQ_TRESH_BASE 0x200
0793 #define MSS_RXQ_TRESH_OFFS 4
0794 #define MSS_RXQ_TRESH_REG(q, fq) (MSS_RXQ_TRESH_BASE + (((q) + (fq)) \
0795 * MSS_RXQ_TRESH_OFFS))
0796
0797 #define MSS_BUF_POOL_BASE 0x40
0798 #define MSS_BUF_POOL_OFFS 4
0799 #define MSS_BUF_POOL_REG(id) (MSS_BUF_POOL_BASE \
0800 + (id) * MSS_BUF_POOL_OFFS)
0801
0802 #define MSS_BUF_POOL_STOP_MASK 0xFFF
0803 #define MSS_BUF_POOL_START_MASK (0xFFF << MSS_BUF_POOL_START_OFFS)
0804 #define MSS_BUF_POOL_START_OFFS 12
0805 #define MSS_BUF_POOL_PORTS_MASK (0xF << MSS_BUF_POOL_PORTS_OFFS)
0806 #define MSS_BUF_POOL_PORTS_OFFS 24
0807 #define MSS_BUF_POOL_PORT_OFFS(id) (0x1 << \
0808 ((id) + MSS_BUF_POOL_PORTS_OFFS))
0809
0810 #define MSS_RXQ_TRESH_START_MASK 0xFFFF
0811 #define MSS_RXQ_TRESH_STOP_MASK (0xFFFF << MSS_RXQ_TRESH_STOP_OFFS)
0812 #define MSS_RXQ_TRESH_STOP_OFFS 16
0813
0814 #define MSS_RXQ_ASS_BASE 0x80
0815 #define MSS_RXQ_ASS_OFFS 4
0816 #define MSS_RXQ_ASS_PER_REG 4
0817 #define MSS_RXQ_ASS_PER_OFFS 8
0818 #define MSS_RXQ_ASS_PORTID_OFFS 0
0819 #define MSS_RXQ_ASS_PORTID_MASK 0x3
0820 #define MSS_RXQ_ASS_HOSTID_OFFS 2
0821 #define MSS_RXQ_ASS_HOSTID_MASK 0x3F
0822
0823 #define MSS_RXQ_ASS_Q_BASE(q, fq) ((((q) + (fq)) % MSS_RXQ_ASS_PER_REG) \
0824 * MSS_RXQ_ASS_PER_OFFS)
0825 #define MSS_RXQ_ASS_PQ_BASE(q, fq) ((((q) + (fq)) / MSS_RXQ_ASS_PER_REG) \
0826 * MSS_RXQ_ASS_OFFS)
0827 #define MSS_RXQ_ASS_REG(q, fq) (MSS_RXQ_ASS_BASE + MSS_RXQ_ASS_PQ_BASE(q, fq))
0828
0829 #define MSS_THRESHOLD_STOP 768
0830 #define MSS_THRESHOLD_START 1024
0831 #define MSS_FC_MAX_TIMEOUT 5000
0832
0833
0834 #define MVPP2_SKB_SHINFO_SIZE \
0835 SKB_DATA_ALIGN(sizeof(struct skb_shared_info))
0836
0837 #define MVPP2_RX_PKT_SIZE(mtu) \
0838 ALIGN((mtu) + MVPP2_MH_SIZE + MVPP2_VLAN_TAG_LEN + \
0839 ETH_HLEN + ETH_FCS_LEN, cache_line_size())
0840
0841 #define MVPP2_RX_BUF_SIZE(pkt_size) ((pkt_size) + MVPP2_SKB_HEADROOM)
0842 #define MVPP2_RX_TOTAL_SIZE(buf_size) ((buf_size) + MVPP2_SKB_SHINFO_SIZE)
0843 #define MVPP2_RX_MAX_PKT_SIZE(total_size) \
0844 ((total_size) - MVPP2_SKB_HEADROOM - MVPP2_SKB_SHINFO_SIZE)
0845
0846 #define MVPP2_MAX_RX_BUF_SIZE (PAGE_SIZE - MVPP2_SKB_SHINFO_SIZE - MVPP2_SKB_HEADROOM)
0847
0848 #define MVPP2_BIT_TO_BYTE(bit) ((bit) / 8)
0849 #define MVPP2_BIT_TO_WORD(bit) ((bit) / 32)
0850 #define MVPP2_BIT_IN_WORD(bit) ((bit) % 32)
0851
0852 #define MVPP2_N_PRS_FLOWS 52
0853 #define MVPP2_N_RFS_ENTRIES_PER_FLOW 4
0854
0855
0856 #define MVPP2_N_RFS_RULES (MVPP2_N_RFS_ENTRIES_PER_FLOW * 7)
0857
0858
0859 #define MVPP22_N_RSS_TABLES 8
0860 #define MVPP22_RSS_TABLE_ENTRIES 32
0861
0862
0863 #define MVPP2_MAX_L3_ADDR_SIZE 16
0864
0865
0866 #define MVPP2_F_LOOPBACK BIT(0)
0867 #define MVPP2_F_DT_COMPAT BIT(1)
0868
0869
0870 enum mvpp2_tag_type {
0871 MVPP2_TAG_TYPE_NONE = 0,
0872 MVPP2_TAG_TYPE_MH = 1,
0873 MVPP2_TAG_TYPE_DSA = 2,
0874 MVPP2_TAG_TYPE_EDSA = 3,
0875 MVPP2_TAG_TYPE_VLAN = 4,
0876 MVPP2_TAG_TYPE_LAST = 5
0877 };
0878
0879
0880 enum mvpp2_prs_l2_cast {
0881 MVPP2_PRS_L2_UNI_CAST,
0882 MVPP2_PRS_L2_MULTI_CAST,
0883 };
0884
0885
0886 enum mvpp2_prs_l3_cast {
0887 MVPP2_PRS_L3_UNI_CAST,
0888 MVPP2_PRS_L3_MULTI_CAST,
0889 MVPP2_PRS_L3_BROAD_CAST
0890 };
0891
0892
0893
0894
0895 #define MVPP22_PTP_DESC_MASK_LOW 0xfff
0896
0897
0898 enum mvpp22_ptp_action {
0899 MVPP22_PTP_ACTION_NONE = 0,
0900 MVPP22_PTP_ACTION_FORWARD = 1,
0901 MVPP22_PTP_ACTION_CAPTURE = 3,
0902
0903 MVPP22_PTP_ACTION_ADDTIME = 4,
0904 MVPP22_PTP_ACTION_ADDCORRECTEDTIME = 5,
0905 MVPP22_PTP_ACTION_CAPTUREADDTIME = 6,
0906 MVPP22_PTP_ACTION_CAPTUREADDCORRECTEDTIME = 7,
0907 MVPP22_PTP_ACTION_ADDINGRESSTIME = 8,
0908 MVPP22_PTP_ACTION_CAPTUREADDINGRESSTIME = 9,
0909 MVPP22_PTP_ACTION_CAPTUREINGRESSTIME = 10,
0910 };
0911
0912
0913 enum mvpp22_ptp_packet_format {
0914 MVPP22_PTP_PKT_FMT_PTPV2 = 0,
0915 MVPP22_PTP_PKT_FMT_PTPV1 = 1,
0916 MVPP22_PTP_PKT_FMT_Y1731 = 2,
0917 MVPP22_PTP_PKT_FMT_NTPTS = 3,
0918 MVPP22_PTP_PKT_FMT_NTPRX = 4,
0919 MVPP22_PTP_PKT_FMT_NTPTX = 5,
0920 MVPP22_PTP_PKT_FMT_TWAMP = 6,
0921 };
0922
0923 #define MVPP22_PTP_ACTION(x) (((x) & 15) << 0)
0924 #define MVPP22_PTP_PACKETFORMAT(x) (((x) & 7) << 4)
0925 #define MVPP22_PTP_MACTIMESTAMPINGEN BIT(11)
0926 #define MVPP22_PTP_TIMESTAMPENTRYID(x) (((x) & 31) << 12)
0927 #define MVPP22_PTP_TIMESTAMPQUEUESELECT BIT(18)
0928
0929
0930 #define MVPP2_BM_JUMBO_BUF_NUM 2048
0931 #define MVPP2_BM_LONG_BUF_NUM 2048
0932 #define MVPP2_BM_SHORT_BUF_NUM 2048
0933 #define MVPP2_BM_POOL_SIZE_MAX (16*1024 - MVPP2_BM_POOL_PTR_ALIGN/4)
0934 #define MVPP2_BM_POOL_PTR_ALIGN 128
0935 #define MVPP2_BM_MAX_POOLS 8
0936
0937
0938 #define MVPP2_BM_COOKIE_POOL_OFFS 8
0939 #define MVPP2_BM_COOKIE_CPU_OFFS 24
0940
0941 #define MVPP2_BM_SHORT_FRAME_SIZE 736
0942 #define MVPP2_BM_LONG_FRAME_SIZE 2240
0943 #define MVPP2_BM_JUMBO_FRAME_SIZE 10432
0944
0945
0946
0947
0948 #define MVPP2_BM_SHORT_PKT_SIZE MVPP2_RX_MAX_PKT_SIZE(MVPP2_BM_SHORT_FRAME_SIZE)
0949 #define MVPP2_BM_LONG_PKT_SIZE MVPP2_RX_MAX_PKT_SIZE(MVPP2_BM_LONG_FRAME_SIZE)
0950 #define MVPP2_BM_JUMBO_PKT_SIZE MVPP2_RX_MAX_PKT_SIZE(MVPP2_BM_JUMBO_FRAME_SIZE)
0951
0952 #define MVPP21_ADDR_SPACE_SZ 0
0953 #define MVPP22_ADDR_SPACE_SZ SZ_64K
0954
0955 #define MVPP2_MAX_THREADS 9
0956 #define MVPP2_MAX_QVECS MVPP2_MAX_THREADS
0957
0958
0959 #define MVPP21_MIB_COUNTERS_OFFSET 0x1000
0960 #define MVPP21_MIB_COUNTERS_PORT_SZ 0x400
0961 #define MVPP22_MIB_COUNTERS_OFFSET 0x0
0962 #define MVPP22_MIB_COUNTERS_PORT_SZ 0x100
0963
0964 #define MVPP2_MIB_GOOD_OCTETS_RCVD 0x0
0965 #define MVPP2_MIB_BAD_OCTETS_RCVD 0x8
0966 #define MVPP2_MIB_CRC_ERRORS_SENT 0xc
0967 #define MVPP2_MIB_UNICAST_FRAMES_RCVD 0x10
0968 #define MVPP2_MIB_BROADCAST_FRAMES_RCVD 0x18
0969 #define MVPP2_MIB_MULTICAST_FRAMES_RCVD 0x1c
0970 #define MVPP2_MIB_FRAMES_64_OCTETS 0x20
0971 #define MVPP2_MIB_FRAMES_65_TO_127_OCTETS 0x24
0972 #define MVPP2_MIB_FRAMES_128_TO_255_OCTETS 0x28
0973 #define MVPP2_MIB_FRAMES_256_TO_511_OCTETS 0x2c
0974 #define MVPP2_MIB_FRAMES_512_TO_1023_OCTETS 0x30
0975 #define MVPP2_MIB_FRAMES_1024_TO_MAX_OCTETS 0x34
0976 #define MVPP2_MIB_GOOD_OCTETS_SENT 0x38
0977 #define MVPP2_MIB_UNICAST_FRAMES_SENT 0x40
0978 #define MVPP2_MIB_MULTICAST_FRAMES_SENT 0x48
0979 #define MVPP2_MIB_BROADCAST_FRAMES_SENT 0x4c
0980 #define MVPP2_MIB_FC_SENT 0x54
0981 #define MVPP2_MIB_FC_RCVD 0x58
0982 #define MVPP2_MIB_RX_FIFO_OVERRUN 0x5c
0983 #define MVPP2_MIB_UNDERSIZE_RCVD 0x60
0984 #define MVPP2_MIB_FRAGMENTS_RCVD 0x64
0985 #define MVPP2_MIB_OVERSIZE_RCVD 0x68
0986 #define MVPP2_MIB_JABBER_RCVD 0x6c
0987 #define MVPP2_MIB_MAC_RCV_ERROR 0x70
0988 #define MVPP2_MIB_BAD_CRC_EVENT 0x74
0989 #define MVPP2_MIB_COLLISION 0x78
0990 #define MVPP2_MIB_LATE_COLLISION 0x7c
0991
0992 #define MVPP2_MIB_COUNTERS_STATS_DELAY (1 * HZ)
0993
0994 #define MVPP2_DESC_DMA_MASK DMA_BIT_MASK(40)
0995
0996
0997 #define MVPP2_B_HDR_INFO_MC_ID_MASK 0xfff
0998 #define MVPP2_B_HDR_INFO_MC_ID(info) ((info) & MVPP2_B_HDR_INFO_MC_ID_MASK)
0999 #define MVPP2_B_HDR_INFO_LAST_OFFS 12
1000 #define MVPP2_B_HDR_INFO_LAST_MASK BIT(12)
1001 #define MVPP2_B_HDR_INFO_IS_LAST(info) \
1002 (((info) & MVPP2_B_HDR_INFO_LAST_MASK) >> MVPP2_B_HDR_INFO_LAST_OFFS)
1003
1004 struct mvpp2_tai;
1005
1006
1007 struct mvpp2_dbgfs_entries;
1008
1009 struct mvpp2_rss_table {
1010 u32 indir[MVPP22_RSS_TABLE_ENTRIES];
1011 };
1012
1013 struct mvpp2_buff_hdr {
1014 __le32 next_phys_addr;
1015 __le32 next_dma_addr;
1016 __le16 byte_count;
1017 __le16 info;
1018 __le16 reserved1;
1019 u8 next_phys_addr_high;
1020 u8 next_dma_addr_high;
1021 __le16 reserved2;
1022 __le16 reserved3;
1023 __le16 reserved4;
1024 __le16 reserved5;
1025 };
1026
1027
1028 struct mvpp2 {
1029
1030 void __iomem *lms_base;
1031 void __iomem *iface_base;
1032 void __iomem *cm3_base;
1033
1034
1035
1036
1037
1038
1039 void __iomem *swth_base[MVPP2_MAX_THREADS];
1040
1041
1042
1043
1044
1045 struct regmap *sysctrl_base;
1046
1047
1048 struct clk *pp_clk;
1049 struct clk *gop_clk;
1050 struct clk *mg_clk;
1051 struct clk *mg_core_clk;
1052 struct clk *axi_clk;
1053
1054
1055 int port_count;
1056 struct mvpp2_port *port_list[MVPP2_MAX_PORTS];
1057
1058 unsigned long port_map;
1059
1060 struct mvpp2_tai *tai;
1061
1062
1063 unsigned int nthreads;
1064
1065 unsigned long lock_map;
1066
1067
1068 struct mvpp2_tx_queue *aggr_txqs;
1069
1070
1071 int percpu_pools;
1072
1073
1074 struct mvpp2_bm_pool *bm_pools;
1075
1076
1077 struct mvpp2_prs_shadow *prs_shadow;
1078
1079 bool *prs_double_vlans;
1080
1081
1082 u32 tclk;
1083
1084
1085 enum { MVPP21, MVPP22, MVPP23 } hw_version;
1086
1087
1088 unsigned int max_port_rxqs;
1089
1090
1091 char queue_name[30];
1092 struct workqueue_struct *stats_queue;
1093
1094
1095 struct dentry *dbgfs_dir;
1096
1097
1098 struct mvpp2_dbgfs_entries *dbgfs_entries;
1099
1100
1101 struct mvpp2_rss_table *rss_tables[MVPP22_N_RSS_TABLES];
1102
1103
1104 struct page_pool *page_pool[MVPP2_PORT_MAX_RXQ];
1105
1106
1107 bool global_tx_fc;
1108
1109
1110 spinlock_t mss_spinlock;
1111 };
1112
1113 struct mvpp2_pcpu_stats {
1114 struct u64_stats_sync syncp;
1115 u64 rx_packets;
1116 u64 rx_bytes;
1117 u64 tx_packets;
1118 u64 tx_bytes;
1119
1120 u64 xdp_redirect;
1121 u64 xdp_pass;
1122 u64 xdp_drop;
1123 u64 xdp_xmit;
1124 u64 xdp_xmit_err;
1125 u64 xdp_tx;
1126 u64 xdp_tx_err;
1127 };
1128
1129
1130 struct mvpp2_port_pcpu {
1131 struct hrtimer tx_done_timer;
1132 struct net_device *dev;
1133 bool timer_scheduled;
1134 };
1135
1136 struct mvpp2_queue_vector {
1137 int irq;
1138 struct napi_struct napi;
1139 enum { MVPP2_QUEUE_VECTOR_SHARED, MVPP2_QUEUE_VECTOR_PRIVATE } type;
1140 int sw_thread_id;
1141 u16 sw_thread_mask;
1142 int first_rxq;
1143 int nrxqs;
1144 u32 pending_cause_rx;
1145 struct mvpp2_port *port;
1146 struct cpumask *mask;
1147 };
1148
1149
1150 struct mvpp2_rfs_rule {
1151
1152 int loc;
1153
1154
1155 int flow_type;
1156
1157
1158 int c2_index;
1159
1160
1161 u16 hek_fields;
1162
1163
1164 u8 engine;
1165
1166
1167
1168
1169 u64 c2_tcam;
1170 u64 c2_tcam_mask;
1171
1172 struct flow_rule *flow;
1173 };
1174
1175 struct mvpp2_ethtool_fs {
1176 struct mvpp2_rfs_rule rule;
1177 struct ethtool_rxnfc rxnfc;
1178 };
1179
1180 struct mvpp2_hwtstamp_queue {
1181 struct sk_buff *skb[32];
1182 u8 next;
1183 };
1184
1185 struct mvpp2_port {
1186 u8 id;
1187
1188
1189
1190
1191 int gop_id;
1192
1193 int port_irq;
1194
1195 struct mvpp2 *priv;
1196
1197
1198 struct fwnode_handle *fwnode;
1199
1200
1201 void __iomem *base;
1202 void __iomem *stats_base;
1203
1204 struct mvpp2_rx_queue **rxqs;
1205 unsigned int nrxqs;
1206 struct mvpp2_tx_queue **txqs;
1207 unsigned int ntxqs;
1208 struct net_device *dev;
1209
1210 struct bpf_prog *xdp_prog;
1211
1212 int pkt_size;
1213
1214
1215 struct mvpp2_port_pcpu __percpu *pcpu;
1216
1217
1218
1219
1220 spinlock_t bm_lock[MVPP2_MAX_THREADS];
1221 spinlock_t tx_lock[MVPP2_MAX_THREADS];
1222
1223
1224 unsigned long flags;
1225
1226 u16 tx_ring_size;
1227 u16 rx_ring_size;
1228 struct mvpp2_pcpu_stats __percpu *stats;
1229 u64 *ethtool_stats;
1230
1231 unsigned long state;
1232
1233
1234 struct mutex gather_stats_lock;
1235 struct delayed_work stats_work;
1236
1237 struct device_node *of_node;
1238
1239 phy_interface_t phy_interface;
1240 struct phylink *phylink;
1241 struct phylink_config phylink_config;
1242 struct phylink_pcs pcs_gmac;
1243 struct phylink_pcs pcs_xlg;
1244 struct phy *comphy;
1245
1246 struct mvpp2_bm_pool *pool_long;
1247 struct mvpp2_bm_pool *pool_short;
1248
1249
1250 u8 first_rxq;
1251
1252 struct mvpp2_queue_vector qvecs[MVPP2_MAX_QVECS];
1253 unsigned int nqvecs;
1254 bool has_tx_irqs;
1255
1256 u32 tx_time_coal;
1257
1258
1259 struct mvpp2_ethtool_fs *rfs_rules[MVPP2_N_RFS_ENTRIES_PER_FLOW];
1260 int n_rfs_rules;
1261
1262
1263
1264
1265 int rss_ctx[MVPP22_N_RSS_TABLES];
1266
1267 bool hwtstamp;
1268 bool rx_hwtstamp;
1269 enum hwtstamp_tx_types tx_hwtstamp_type;
1270 struct mvpp2_hwtstamp_queue tx_hwtstamp_queue[2];
1271
1272
1273 bool tx_fc;
1274 };
1275
1276
1277
1278
1279
1280
1281 #define MVPP2_TXD_L3_OFF_SHIFT 0
1282 #define MVPP2_TXD_IP_HLEN_SHIFT 8
1283 #define MVPP2_TXD_L4_CSUM_FRAG BIT(13)
1284 #define MVPP2_TXD_L4_CSUM_NOT BIT(14)
1285 #define MVPP2_TXD_IP_CSUM_DISABLE BIT(15)
1286 #define MVPP2_TXD_PADDING_DISABLE BIT(23)
1287 #define MVPP2_TXD_L4_UDP BIT(24)
1288 #define MVPP2_TXD_L3_IP6 BIT(26)
1289 #define MVPP2_TXD_L_DESC BIT(28)
1290 #define MVPP2_TXD_F_DESC BIT(29)
1291
1292 #define MVPP2_RXD_ERR_SUMMARY BIT(15)
1293 #define MVPP2_RXD_ERR_CODE_MASK (BIT(13) | BIT(14))
1294 #define MVPP2_RXD_ERR_CRC 0x0
1295 #define MVPP2_RXD_ERR_OVERRUN BIT(13)
1296 #define MVPP2_RXD_ERR_RESOURCE (BIT(13) | BIT(14))
1297 #define MVPP2_RXD_BM_POOL_ID_OFFS 16
1298 #define MVPP2_RXD_BM_POOL_ID_MASK (BIT(16) | BIT(17) | BIT(18))
1299 #define MVPP2_RXD_HWF_SYNC BIT(21)
1300 #define MVPP2_RXD_L4_CSUM_OK BIT(22)
1301 #define MVPP2_RXD_IP4_HEADER_ERR BIT(24)
1302 #define MVPP2_RXD_L4_TCP BIT(25)
1303 #define MVPP2_RXD_L4_UDP BIT(26)
1304 #define MVPP2_RXD_L3_IP4 BIT(28)
1305 #define MVPP2_RXD_L3_IP6 BIT(30)
1306 #define MVPP2_RXD_BUF_HDR BIT(31)
1307
1308
1309 struct mvpp21_tx_desc {
1310 __le32 command;
1311 u8 packet_offset;
1312 u8 phys_txq;
1313 __le16 data_size;
1314 __le32 buf_dma_addr;
1315 __le32 buf_cookie;
1316 __le32 reserved1[3];
1317 __le32 reserved2;
1318 };
1319
1320
1321 struct mvpp21_rx_desc {
1322 __le32 status;
1323 __le16 reserved1;
1324 __le16 data_size;
1325 __le32 buf_dma_addr;
1326 __le32 buf_cookie;
1327 __le16 reserved2;
1328 __le16 reserved3;
1329 u8 reserved4;
1330 u8 reserved5;
1331 __le16 reserved6;
1332 __le32 reserved7;
1333 __le32 reserved8;
1334 };
1335
1336
1337 struct mvpp22_tx_desc {
1338 __le32 command;
1339 u8 packet_offset;
1340 u8 phys_txq;
1341 __le16 data_size;
1342 __le32 ptp_descriptor;
1343 __le32 reserved2;
1344 __le64 buf_dma_addr_ptp;
1345 __le64 buf_cookie_misc;
1346 };
1347
1348
1349 struct mvpp22_rx_desc {
1350 __le32 status;
1351 __le16 reserved1;
1352 __le16 data_size;
1353 __le32 reserved2;
1354 __le32 timestamp;
1355 __le64 buf_dma_addr_key_hash;
1356 __le64 buf_cookie_misc;
1357 };
1358
1359
1360
1361
1362 struct mvpp2_tx_desc {
1363 union {
1364 struct mvpp21_tx_desc pp21;
1365 struct mvpp22_tx_desc pp22;
1366 };
1367 };
1368
1369 struct mvpp2_rx_desc {
1370 union {
1371 struct mvpp21_rx_desc pp21;
1372 struct mvpp22_rx_desc pp22;
1373 };
1374 };
1375
1376 enum mvpp2_tx_buf_type {
1377 MVPP2_TYPE_SKB,
1378 MVPP2_TYPE_XDP_TX,
1379 MVPP2_TYPE_XDP_NDO,
1380 };
1381
1382 struct mvpp2_txq_pcpu_buf {
1383 enum mvpp2_tx_buf_type type;
1384
1385
1386 union {
1387 struct xdp_frame *xdpf;
1388 struct sk_buff *skb;
1389 };
1390
1391
1392 dma_addr_t dma;
1393
1394
1395 size_t size;
1396 };
1397
1398
1399 struct mvpp2_txq_pcpu {
1400 unsigned int thread;
1401
1402
1403 int size;
1404
1405
1406
1407
1408 int count;
1409
1410 int wake_threshold;
1411 int stop_threshold;
1412
1413
1414 int reserved_num;
1415
1416
1417 struct mvpp2_txq_pcpu_buf *buffs;
1418
1419
1420 int txq_put_index;
1421
1422
1423 int txq_get_index;
1424
1425
1426 char *tso_headers;
1427 dma_addr_t tso_headers_dma;
1428 };
1429
1430 struct mvpp2_tx_queue {
1431
1432 u8 id;
1433
1434
1435 u8 log_id;
1436
1437
1438 int size;
1439
1440
1441 int count;
1442
1443
1444 struct mvpp2_txq_pcpu __percpu *pcpu;
1445
1446 u32 done_pkts_coal;
1447
1448
1449 struct mvpp2_tx_desc *descs;
1450
1451
1452 dma_addr_t descs_dma;
1453
1454
1455 int last_desc;
1456
1457
1458 int next_desc_to_proc;
1459 };
1460
1461 struct mvpp2_rx_queue {
1462
1463 u8 id;
1464
1465
1466 int size;
1467
1468 u32 pkts_coal;
1469 u32 time_coal;
1470
1471
1472 struct mvpp2_rx_desc *descs;
1473
1474
1475 dma_addr_t descs_dma;
1476
1477
1478 int last_desc;
1479
1480
1481 int next_desc_to_proc;
1482
1483
1484 int port;
1485
1486
1487 int logic_rxq;
1488
1489
1490 struct xdp_rxq_info xdp_rxq_short;
1491 struct xdp_rxq_info xdp_rxq_long;
1492 };
1493
1494 struct mvpp2_bm_pool {
1495
1496 int id;
1497
1498
1499 int size;
1500
1501 int size_bytes;
1502
1503 int buf_num;
1504
1505 int buf_size;
1506
1507 int pkt_size;
1508 int frag_size;
1509
1510
1511 u32 *virt_addr;
1512
1513 dma_addr_t dma_addr;
1514
1515
1516 u32 port_map;
1517 };
1518
1519 #define IS_TSO_HEADER(txq_pcpu, addr) \
1520 ((addr) >= (txq_pcpu)->tso_headers_dma && \
1521 (addr) < (txq_pcpu)->tso_headers_dma + \
1522 (txq_pcpu)->size * TSO_HEADER_SIZE)
1523
1524 #define MVPP2_DRIVER_NAME "mvpp2"
1525 #define MVPP2_DRIVER_VERSION "1.0"
1526
1527 void mvpp2_write(struct mvpp2 *priv, u32 offset, u32 data);
1528 u32 mvpp2_read(struct mvpp2 *priv, u32 offset);
1529
1530 void mvpp2_dbgfs_init(struct mvpp2 *priv, const char *name);
1531
1532 void mvpp2_dbgfs_cleanup(struct mvpp2 *priv);
1533
1534 void mvpp23_rx_fifo_fc_en(struct mvpp2 *priv, int port, bool en);
1535
1536 #ifdef CONFIG_MVPP2_PTP
1537 int mvpp22_tai_probe(struct device *dev, struct mvpp2 *priv);
1538 void mvpp22_tai_tstamp(struct mvpp2_tai *tai, u32 tstamp,
1539 struct skb_shared_hwtstamps *hwtstamp);
1540 void mvpp22_tai_start(struct mvpp2_tai *tai);
1541 void mvpp22_tai_stop(struct mvpp2_tai *tai);
1542 int mvpp22_tai_ptp_clock_index(struct mvpp2_tai *tai);
1543 #else
1544 static inline int mvpp22_tai_probe(struct device *dev, struct mvpp2 *priv)
1545 {
1546 return 0;
1547 }
1548 static inline void mvpp22_tai_tstamp(struct mvpp2_tai *tai, u32 tstamp,
1549 struct skb_shared_hwtstamps *hwtstamp)
1550 {
1551 }
1552 static inline void mvpp22_tai_start(struct mvpp2_tai *tai)
1553 {
1554 }
1555 static inline void mvpp22_tai_stop(struct mvpp2_tai *tai)
1556 {
1557 }
1558 static inline int mvpp22_tai_ptp_clock_index(struct mvpp2_tai *tai)
1559 {
1560 return -1;
1561 }
1562 #endif
1563
1564 static inline bool mvpp22_rx_hwtstamping(struct mvpp2_port *port)
1565 {
1566 return IS_ENABLED(CONFIG_MVPP2_PTP) && port->rx_hwtstamp;
1567 }
1568
1569 #endif