1f1e37e31SAntoine Tenart /* SPDX-License-Identifier: GPL-2.0 */
2db9d7d36SMaxime Chevallier /*
3db9d7d36SMaxime Chevallier * Definitions for Marvell PPv2 network controller for Armada 375 SoC.
4db9d7d36SMaxime Chevallier *
5db9d7d36SMaxime Chevallier * Copyright (C) 2014 Marvell
6db9d7d36SMaxime Chevallier *
7db9d7d36SMaxime Chevallier * Marcin Wojtas <mw@semihalf.com>
8db9d7d36SMaxime Chevallier */
9db9d7d36SMaxime Chevallier #ifndef _MVPP2_H_
10db9d7d36SMaxime Chevallier #define _MVPP2_H_
11db9d7d36SMaxime Chevallier
12b32b0881SAntoine Tenart #include <linux/interrupt.h>
13db9d7d36SMaxime Chevallier #include <linux/kernel.h>
14db9d7d36SMaxime Chevallier #include <linux/netdevice.h>
15f5015a59SRussell King #include <linux/net_tstamp.h>
16db9d7d36SMaxime Chevallier #include <linux/phy.h>
17db9d7d36SMaxime Chevallier #include <linux/phylink.h>
1890b509b3SMaxime Chevallier #include <net/flow_offload.h>
19a9ca9f9cSYunsheng Lin #include <net/page_pool/types.h>
2007dd0a7aSMatteo Croce #include <linux/bpf.h>
2107dd0a7aSMatteo Croce #include <net/xdp.h>
2207dd0a7aSMatteo Croce
2307dd0a7aSMatteo Croce /* The PacketOffset field is measured in units of 32 bytes and is 3 bits wide,
2407dd0a7aSMatteo Croce * so the maximum offset is 7 * 32 = 224
2507dd0a7aSMatteo Croce */
2607dd0a7aSMatteo Croce #define MVPP2_SKB_HEADROOM min(max(XDP_PACKET_HEADROOM, NET_SKB_PAD), 224)
2707dd0a7aSMatteo Croce
2807dd0a7aSMatteo Croce #define MVPP2_XDP_PASS 0
2907dd0a7aSMatteo Croce #define MVPP2_XDP_DROPPED BIT(0)
3007dd0a7aSMatteo Croce #define MVPP2_XDP_TX BIT(1)
3107dd0a7aSMatteo Croce #define MVPP2_XDP_REDIR BIT(2)
32db9d7d36SMaxime Chevallier
33db9d7d36SMaxime Chevallier /* Fifo Registers */
34db9d7d36SMaxime Chevallier #define MVPP2_RX_DATA_FIFO_SIZE_REG(port) (0x00 + 4 * (port))
35db9d7d36SMaxime Chevallier #define MVPP2_RX_ATTR_FIFO_SIZE_REG(port) (0x20 + 4 * (port))
36db9d7d36SMaxime Chevallier #define MVPP2_RX_MIN_PKT_SIZE_REG 0x60
37db9d7d36SMaxime Chevallier #define MVPP2_RX_FIFO_INIT_REG 0x64
38db9d7d36SMaxime Chevallier #define MVPP22_TX_FIFO_THRESH_REG(port) (0x8840 + 4 * (port))
39db9d7d36SMaxime Chevallier #define MVPP22_TX_FIFO_SIZE_REG(port) (0x8860 + 4 * (port))
40db9d7d36SMaxime Chevallier
41db9d7d36SMaxime Chevallier /* RX DMA Top Registers */
42db9d7d36SMaxime Chevallier #define MVPP2_RX_CTRL_REG(port) (0x140 + 4 * (port))
43db9d7d36SMaxime Chevallier #define MVPP2_RX_LOW_LATENCY_PKT_SIZE(s) (((s) & 0xfff) << 16)
44db9d7d36SMaxime Chevallier #define MVPP2_RX_USE_PSEUDO_FOR_CSUM_MASK BIT(31)
45db9d7d36SMaxime Chevallier #define MVPP2_POOL_BUF_SIZE_REG(pool) (0x180 + 4 * (pool))
46db9d7d36SMaxime Chevallier #define MVPP2_POOL_BUF_SIZE_OFFSET 5
47db9d7d36SMaxime Chevallier #define MVPP2_RXQ_CONFIG_REG(rxq) (0x800 + 4 * (rxq))
48db9d7d36SMaxime Chevallier #define MVPP2_SNOOP_PKT_SIZE_MASK 0x1ff
49db9d7d36SMaxime Chevallier #define MVPP2_SNOOP_BUF_HDR_MASK BIT(9)
50db9d7d36SMaxime Chevallier #define MVPP2_RXQ_POOL_SHORT_OFFS 20
51db9d7d36SMaxime Chevallier #define MVPP21_RXQ_POOL_SHORT_MASK 0x700000
52db9d7d36SMaxime Chevallier #define MVPP22_RXQ_POOL_SHORT_MASK 0xf00000
53db9d7d36SMaxime Chevallier #define MVPP2_RXQ_POOL_LONG_OFFS 24
54db9d7d36SMaxime Chevallier #define MVPP21_RXQ_POOL_LONG_MASK 0x7000000
55db9d7d36SMaxime Chevallier #define MVPP22_RXQ_POOL_LONG_MASK 0xf000000
56db9d7d36SMaxime Chevallier #define MVPP2_RXQ_PACKET_OFFSET_OFFS 28
57db9d7d36SMaxime Chevallier #define MVPP2_RXQ_PACKET_OFFSET_MASK 0x70000000
58db9d7d36SMaxime Chevallier #define MVPP2_RXQ_DISABLE_MASK BIT(31)
59db9d7d36SMaxime Chevallier
60db9d7d36SMaxime Chevallier /* Top Registers */
61db9d7d36SMaxime Chevallier #define MVPP2_MH_REG(port) (0x5040 + 4 * (port))
62db9d7d36SMaxime Chevallier #define MVPP2_DSA_EXTENDED BIT(5)
636af27a1dSStefan Chulski #define MVPP2_VER_ID_REG 0x50b0
646af27a1dSStefan Chulski #define MVPP2_VER_PP22 0x10
656af27a1dSStefan Chulski #define MVPP2_VER_PP23 0x11
66db9d7d36SMaxime Chevallier
67db9d7d36SMaxime Chevallier /* Parser Registers */
68db9d7d36SMaxime Chevallier #define MVPP2_PRS_INIT_LOOKUP_REG 0x1000
69db9d7d36SMaxime Chevallier #define MVPP2_PRS_PORT_LU_MAX 0xf
70db9d7d36SMaxime Chevallier #define MVPP2_PRS_PORT_LU_MASK(port) (0xff << ((port) * 4))
71db9d7d36SMaxime Chevallier #define MVPP2_PRS_PORT_LU_VAL(port, val) ((val) << ((port) * 4))
72db9d7d36SMaxime Chevallier #define MVPP2_PRS_INIT_OFFS_REG(port) (0x1004 + ((port) & 4))
73db9d7d36SMaxime Chevallier #define MVPP2_PRS_INIT_OFF_MASK(port) (0x3f << (((port) % 4) * 8))
74db9d7d36SMaxime Chevallier #define MVPP2_PRS_INIT_OFF_VAL(port, val) ((val) << (((port) % 4) * 8))
75db9d7d36SMaxime Chevallier #define MVPP2_PRS_MAX_LOOP_REG(port) (0x100c + ((port) & 4))
76db9d7d36SMaxime Chevallier #define MVPP2_PRS_MAX_LOOP_MASK(port) (0xff << (((port) % 4) * 8))
77db9d7d36SMaxime Chevallier #define MVPP2_PRS_MAX_LOOP_VAL(port, val) ((val) << (((port) % 4) * 8))
78db9d7d36SMaxime Chevallier #define MVPP2_PRS_TCAM_IDX_REG 0x1100
79db9d7d36SMaxime Chevallier #define MVPP2_PRS_TCAM_DATA_REG(idx) (0x1104 + (idx) * 4)
80db9d7d36SMaxime Chevallier #define MVPP2_PRS_TCAM_INV_MASK BIT(31)
81db9d7d36SMaxime Chevallier #define MVPP2_PRS_SRAM_IDX_REG 0x1200
82db9d7d36SMaxime Chevallier #define MVPP2_PRS_SRAM_DATA_REG(idx) (0x1204 + (idx) * 4)
83db9d7d36SMaxime Chevallier #define MVPP2_PRS_TCAM_CTRL_REG 0x1230
84db9d7d36SMaxime Chevallier #define MVPP2_PRS_TCAM_EN_MASK BIT(0)
851203341cSMaxime Chevallier #define MVPP2_PRS_TCAM_HIT_IDX_REG 0x1240
861203341cSMaxime Chevallier #define MVPP2_PRS_TCAM_HIT_CNT_REG 0x1244
871203341cSMaxime Chevallier #define MVPP2_PRS_TCAM_HIT_CNT_MASK GENMASK(15, 0)
88db9d7d36SMaxime Chevallier
89db9d7d36SMaxime Chevallier /* RSS Registers */
90db9d7d36SMaxime Chevallier #define MVPP22_RSS_INDEX 0x1500
91db9d7d36SMaxime Chevallier #define MVPP22_RSS_INDEX_TABLE_ENTRY(idx) (idx)
92db9d7d36SMaxime Chevallier #define MVPP22_RSS_INDEX_TABLE(idx) ((idx) << 8)
93db9d7d36SMaxime Chevallier #define MVPP22_RSS_INDEX_QUEUE(idx) ((idx) << 16)
944b86097bSMaxime Chevallier #define MVPP22_RXQ2RSS_TABLE 0x1504
95db9d7d36SMaxime Chevallier #define MVPP22_RSS_TABLE_POINTER(p) (p)
964b86097bSMaxime Chevallier #define MVPP22_RSS_TABLE_ENTRY 0x1508
97db9d7d36SMaxime Chevallier #define MVPP22_RSS_WIDTH 0x150c
98db9d7d36SMaxime Chevallier
99db9d7d36SMaxime Chevallier /* Classifier Registers */
100db9d7d36SMaxime Chevallier #define MVPP2_CLS_MODE_REG 0x1800
101db9d7d36SMaxime Chevallier #define MVPP2_CLS_MODE_ACTIVE_MASK BIT(0)
102db9d7d36SMaxime Chevallier #define MVPP2_CLS_PORT_WAY_REG 0x1810
103db9d7d36SMaxime Chevallier #define MVPP2_CLS_PORT_WAY_MASK(port) (1 << (port))
104db9d7d36SMaxime Chevallier #define MVPP2_CLS_LKP_INDEX_REG 0x1814
105db9d7d36SMaxime Chevallier #define MVPP2_CLS_LKP_INDEX_WAY_OFFS 6
106db9d7d36SMaxime Chevallier #define MVPP2_CLS_LKP_TBL_REG 0x1818
107db9d7d36SMaxime Chevallier #define MVPP2_CLS_LKP_TBL_RXQ_MASK 0xff
108b1a962c6SMaxime Chevallier #define MVPP2_CLS_LKP_FLOW_PTR(flow) ((flow) << 16)
109db9d7d36SMaxime Chevallier #define MVPP2_CLS_LKP_TBL_LOOKUP_EN_MASK BIT(25)
110db9d7d36SMaxime Chevallier #define MVPP2_CLS_FLOW_INDEX_REG 0x1820
111db9d7d36SMaxime Chevallier #define MVPP2_CLS_FLOW_TBL0_REG 0x1824
112b1a962c6SMaxime Chevallier #define MVPP2_CLS_FLOW_TBL0_LAST BIT(0)
113b1a962c6SMaxime Chevallier #define MVPP2_CLS_FLOW_TBL0_ENG_MASK 0x7
114b1a962c6SMaxime Chevallier #define MVPP2_CLS_FLOW_TBL0_OFFS 1
115b1a962c6SMaxime Chevallier #define MVPP2_CLS_FLOW_TBL0_ENG(x) ((x) << 1)
116b1a962c6SMaxime Chevallier #define MVPP2_CLS_FLOW_TBL0_PORT_ID_MASK 0xff
117b1a962c6SMaxime Chevallier #define MVPP2_CLS_FLOW_TBL0_PORT_ID(port) ((port) << 4)
118b1a962c6SMaxime Chevallier #define MVPP2_CLS_FLOW_TBL0_PORT_ID_SEL BIT(23)
119db9d7d36SMaxime Chevallier #define MVPP2_CLS_FLOW_TBL1_REG 0x1828
120b1a962c6SMaxime Chevallier #define MVPP2_CLS_FLOW_TBL1_N_FIELDS_MASK 0x7
121b1a962c6SMaxime Chevallier #define MVPP2_CLS_FLOW_TBL1_N_FIELDS(x) (x)
12232f1a672SMaxime Chevallier #define MVPP2_CLS_FLOW_TBL1_LU_TYPE(lu) (((lu) & 0x3f) << 3)
123b1a962c6SMaxime Chevallier #define MVPP2_CLS_FLOW_TBL1_PRIO_MASK 0x3f
124b1a962c6SMaxime Chevallier #define MVPP2_CLS_FLOW_TBL1_PRIO(x) ((x) << 9)
125b1a962c6SMaxime Chevallier #define MVPP2_CLS_FLOW_TBL1_SEQ_MASK 0x7
126b1a962c6SMaxime Chevallier #define MVPP2_CLS_FLOW_TBL1_SEQ(x) ((x) << 15)
127db9d7d36SMaxime Chevallier #define MVPP2_CLS_FLOW_TBL2_REG 0x182c
128b1a962c6SMaxime Chevallier #define MVPP2_CLS_FLOW_TBL2_FLD_MASK 0x3f
129b1a962c6SMaxime Chevallier #define MVPP2_CLS_FLOW_TBL2_FLD_OFFS(n) ((n) * 6)
130b1a962c6SMaxime Chevallier #define MVPP2_CLS_FLOW_TBL2_FLD(n, x) ((x) << ((n) * 6))
131db9d7d36SMaxime Chevallier #define MVPP2_CLS_OVERSIZE_RXQ_LOW_REG(port) (0x1980 + ((port) * 4))
132db9d7d36SMaxime Chevallier #define MVPP2_CLS_OVERSIZE_RXQ_LOW_BITS 3
133db9d7d36SMaxime Chevallier #define MVPP2_CLS_OVERSIZE_RXQ_LOW_MASK 0x7
134db9d7d36SMaxime Chevallier #define MVPP2_CLS_SWFWD_P2HQ_REG(port) (0x19b0 + ((port) * 4))
135db9d7d36SMaxime Chevallier #define MVPP2_CLS_SWFWD_PCTRL_REG 0x19d0
136db9d7d36SMaxime Chevallier #define MVPP2_CLS_SWFWD_PCTRL_MASK(port) (1 << (port))
137db9d7d36SMaxime Chevallier
138b1a962c6SMaxime Chevallier /* Classifier C2 engine Registers */
139b1a962c6SMaxime Chevallier #define MVPP22_CLS_C2_TCAM_IDX 0x1b00
140b1a962c6SMaxime Chevallier #define MVPP22_CLS_C2_TCAM_DATA0 0x1b10
141b1a962c6SMaxime Chevallier #define MVPP22_CLS_C2_TCAM_DATA1 0x1b14
142b1a962c6SMaxime Chevallier #define MVPP22_CLS_C2_TCAM_DATA2 0x1b18
143b1a962c6SMaxime Chevallier #define MVPP22_CLS_C2_TCAM_DATA3 0x1b1c
144b1a962c6SMaxime Chevallier #define MVPP22_CLS_C2_TCAM_DATA4 0x1b20
14532f1a672SMaxime Chevallier #define MVPP22_CLS_C2_LU_TYPE(lu) ((lu) & 0x3f)
146b1a962c6SMaxime Chevallier #define MVPP22_CLS_C2_PORT_ID(port) ((port) << 8)
14790b509b3SMaxime Chevallier #define MVPP22_CLS_C2_PORT_MASK (0xff << 8)
1488d2847d9SMaxime Chevallier #define MVPP22_CLS_C2_TCAM_INV 0x1b24
1498d2847d9SMaxime Chevallier #define MVPP22_CLS_C2_TCAM_INV_BIT BIT(31)
150f9d30d5bSMaxime Chevallier #define MVPP22_CLS_C2_HIT_CTR 0x1b50
151b1a962c6SMaxime Chevallier #define MVPP22_CLS_C2_ACT 0x1b60
152b1a962c6SMaxime Chevallier #define MVPP22_CLS_C2_ACT_RSS_EN(act) (((act) & 0x3) << 19)
153b1a962c6SMaxime Chevallier #define MVPP22_CLS_C2_ACT_FWD(act) (((act) & 0x7) << 13)
154b1a962c6SMaxime Chevallier #define MVPP22_CLS_C2_ACT_QHIGH(act) (((act) & 0x3) << 11)
155b1a962c6SMaxime Chevallier #define MVPP22_CLS_C2_ACT_QLOW(act) (((act) & 0x3) << 9)
156bec2d46dSMaxime Chevallier #define MVPP22_CLS_C2_ACT_COLOR(act) ((act) & 0x7)
157b1a962c6SMaxime Chevallier #define MVPP22_CLS_C2_ATTR0 0x1b64
158b1a962c6SMaxime Chevallier #define MVPP22_CLS_C2_ATTR0_QHIGH(qh) (((qh) & 0x1f) << 24)
159b1a962c6SMaxime Chevallier #define MVPP22_CLS_C2_ATTR0_QHIGH_MASK 0x1f
160dba1d918SMaxime Chevallier #define MVPP22_CLS_C2_ATTR0_QHIGH_OFFS 24
161b1a962c6SMaxime Chevallier #define MVPP22_CLS_C2_ATTR0_QLOW(ql) (((ql) & 0x7) << 21)
162b1a962c6SMaxime Chevallier #define MVPP22_CLS_C2_ATTR0_QLOW_MASK 0x7
163dba1d918SMaxime Chevallier #define MVPP22_CLS_C2_ATTR0_QLOW_OFFS 21
164b1a962c6SMaxime Chevallier #define MVPP22_CLS_C2_ATTR1 0x1b68
165b1a962c6SMaxime Chevallier #define MVPP22_CLS_C2_ATTR2 0x1b6c
166b1a962c6SMaxime Chevallier #define MVPP22_CLS_C2_ATTR2_RSS_EN BIT(30)
167b1a962c6SMaxime Chevallier #define MVPP22_CLS_C2_ATTR3 0x1b70
168e8486ca9SMaxime Chevallier #define MVPP22_CLS_C2_TCAM_CTRL 0x1b90
169e8486ca9SMaxime Chevallier #define MVPP22_CLS_C2_TCAM_BYPASS_FIFO BIT(0)
170b1a962c6SMaxime Chevallier
171db9d7d36SMaxime Chevallier /* Descriptor Manager Top Registers */
172db9d7d36SMaxime Chevallier #define MVPP2_RXQ_NUM_REG 0x2040
173db9d7d36SMaxime Chevallier #define MVPP2_RXQ_DESC_ADDR_REG 0x2044
174db9d7d36SMaxime Chevallier #define MVPP22_DESC_ADDR_OFFS 8
175db9d7d36SMaxime Chevallier #define MVPP2_RXQ_DESC_SIZE_REG 0x2048
176db9d7d36SMaxime Chevallier #define MVPP2_RXQ_DESC_SIZE_MASK 0x3ff0
177db9d7d36SMaxime Chevallier #define MVPP2_RXQ_STATUS_UPDATE_REG(rxq) (0x3000 + 4 * (rxq))
178db9d7d36SMaxime Chevallier #define MVPP2_RXQ_NUM_PROCESSED_OFFSET 0
179db9d7d36SMaxime Chevallier #define MVPP2_RXQ_NUM_NEW_OFFSET 16
180db9d7d36SMaxime Chevallier #define MVPP2_RXQ_STATUS_REG(rxq) (0x3400 + 4 * (rxq))
181db9d7d36SMaxime Chevallier #define MVPP2_RXQ_OCCUPIED_MASK 0x3fff
182db9d7d36SMaxime Chevallier #define MVPP2_RXQ_NON_OCCUPIED_OFFSET 16
183db9d7d36SMaxime Chevallier #define MVPP2_RXQ_NON_OCCUPIED_MASK 0x3fff0000
184db9d7d36SMaxime Chevallier #define MVPP2_RXQ_THRESH_REG 0x204c
185db9d7d36SMaxime Chevallier #define MVPP2_OCCUPIED_THRESH_OFFSET 0
186db9d7d36SMaxime Chevallier #define MVPP2_OCCUPIED_THRESH_MASK 0x3fff
187db9d7d36SMaxime Chevallier #define MVPP2_RXQ_INDEX_REG 0x2050
188db9d7d36SMaxime Chevallier #define MVPP2_TXQ_NUM_REG 0x2080
189db9d7d36SMaxime Chevallier #define MVPP2_TXQ_DESC_ADDR_REG 0x2084
190db9d7d36SMaxime Chevallier #define MVPP2_TXQ_DESC_SIZE_REG 0x2088
191db9d7d36SMaxime Chevallier #define MVPP2_TXQ_DESC_SIZE_MASK 0x3ff0
192db9d7d36SMaxime Chevallier #define MVPP2_TXQ_THRESH_REG 0x2094
193db9d7d36SMaxime Chevallier #define MVPP2_TXQ_THRESH_OFFSET 16
194db9d7d36SMaxime Chevallier #define MVPP2_TXQ_THRESH_MASK 0x3fff
195db9d7d36SMaxime Chevallier #define MVPP2_AGGR_TXQ_UPDATE_REG 0x2090
196db9d7d36SMaxime Chevallier #define MVPP2_TXQ_INDEX_REG 0x2098
197db9d7d36SMaxime Chevallier #define MVPP2_TXQ_PREF_BUF_REG 0x209c
198db9d7d36SMaxime Chevallier #define MVPP2_PREF_BUF_PTR(desc) ((desc) & 0xfff)
199db9d7d36SMaxime Chevallier #define MVPP2_PREF_BUF_SIZE_4 (BIT(12) | BIT(13))
200db9d7d36SMaxime Chevallier #define MVPP2_PREF_BUF_SIZE_16 (BIT(12) | BIT(14))
201db9d7d36SMaxime Chevallier #define MVPP2_PREF_BUF_THRESH(val) ((val) << 17)
202db9d7d36SMaxime Chevallier #define MVPP2_TXQ_DRAIN_EN_MASK BIT(31)
203db9d7d36SMaxime Chevallier #define MVPP2_TXQ_PENDING_REG 0x20a0
204db9d7d36SMaxime Chevallier #define MVPP2_TXQ_PENDING_MASK 0x3fff
205db9d7d36SMaxime Chevallier #define MVPP2_TXQ_INT_STATUS_REG 0x20a4
206db9d7d36SMaxime Chevallier #define MVPP2_TXQ_SENT_REG(txq) (0x3c00 + 4 * (txq))
207db9d7d36SMaxime Chevallier #define MVPP2_TRANSMITTED_COUNT_OFFSET 16
208db9d7d36SMaxime Chevallier #define MVPP2_TRANSMITTED_COUNT_MASK 0x3fff0000
209db9d7d36SMaxime Chevallier #define MVPP2_TXQ_RSVD_REQ_REG 0x20b0
210db9d7d36SMaxime Chevallier #define MVPP2_TXQ_RSVD_REQ_Q_OFFSET 16
211db9d7d36SMaxime Chevallier #define MVPP2_TXQ_RSVD_RSLT_REG 0x20b4
212db9d7d36SMaxime Chevallier #define MVPP2_TXQ_RSVD_RSLT_MASK 0x3fff
213db9d7d36SMaxime Chevallier #define MVPP2_TXQ_RSVD_CLR_REG 0x20b8
214db9d7d36SMaxime Chevallier #define MVPP2_TXQ_RSVD_CLR_OFFSET 16
215db9d7d36SMaxime Chevallier #define MVPP2_AGGR_TXQ_DESC_ADDR_REG(cpu) (0x2100 + 4 * (cpu))
216db9d7d36SMaxime Chevallier #define MVPP22_AGGR_TXQ_DESC_ADDR_OFFS 8
217db9d7d36SMaxime Chevallier #define MVPP2_AGGR_TXQ_DESC_SIZE_REG(cpu) (0x2140 + 4 * (cpu))
218db9d7d36SMaxime Chevallier #define MVPP2_AGGR_TXQ_DESC_SIZE_MASK 0x3ff0
219db9d7d36SMaxime Chevallier #define MVPP2_AGGR_TXQ_STATUS_REG(cpu) (0x2180 + 4 * (cpu))
220db9d7d36SMaxime Chevallier #define MVPP2_AGGR_TXQ_PENDING_MASK 0x3fff
221db9d7d36SMaxime Chevallier #define MVPP2_AGGR_TXQ_INDEX_REG(cpu) (0x21c0 + 4 * (cpu))
222db9d7d36SMaxime Chevallier
223db9d7d36SMaxime Chevallier /* MBUS bridge registers */
224db9d7d36SMaxime Chevallier #define MVPP2_WIN_BASE(w) (0x4000 + ((w) << 2))
225db9d7d36SMaxime Chevallier #define MVPP2_WIN_SIZE(w) (0x4020 + ((w) << 2))
226db9d7d36SMaxime Chevallier #define MVPP2_WIN_REMAP(w) (0x4040 + ((w) << 2))
227db9d7d36SMaxime Chevallier #define MVPP2_BASE_ADDR_ENABLE 0x4060
228db9d7d36SMaxime Chevallier
229db9d7d36SMaxime Chevallier /* AXI Bridge Registers */
230db9d7d36SMaxime Chevallier #define MVPP22_AXI_BM_WR_ATTR_REG 0x4100
231db9d7d36SMaxime Chevallier #define MVPP22_AXI_BM_RD_ATTR_REG 0x4104
232db9d7d36SMaxime Chevallier #define MVPP22_AXI_AGGRQ_DESCR_RD_ATTR_REG 0x4110
233db9d7d36SMaxime Chevallier #define MVPP22_AXI_TXQ_DESCR_WR_ATTR_REG 0x4114
234db9d7d36SMaxime Chevallier #define MVPP22_AXI_TXQ_DESCR_RD_ATTR_REG 0x4118
235db9d7d36SMaxime Chevallier #define MVPP22_AXI_RXQ_DESCR_WR_ATTR_REG 0x411c
236db9d7d36SMaxime Chevallier #define MVPP22_AXI_RX_DATA_WR_ATTR_REG 0x4120
237db9d7d36SMaxime Chevallier #define MVPP22_AXI_TX_DATA_RD_ATTR_REG 0x4130
238db9d7d36SMaxime Chevallier #define MVPP22_AXI_RD_NORMAL_CODE_REG 0x4150
239db9d7d36SMaxime Chevallier #define MVPP22_AXI_RD_SNOOP_CODE_REG 0x4154
240db9d7d36SMaxime Chevallier #define MVPP22_AXI_WR_NORMAL_CODE_REG 0x4160
241db9d7d36SMaxime Chevallier #define MVPP22_AXI_WR_SNOOP_CODE_REG 0x4164
242db9d7d36SMaxime Chevallier
243db9d7d36SMaxime Chevallier /* Values for AXI Bridge registers */
244db9d7d36SMaxime Chevallier #define MVPP22_AXI_ATTR_CACHE_OFFS 0
245db9d7d36SMaxime Chevallier #define MVPP22_AXI_ATTR_DOMAIN_OFFS 12
246db9d7d36SMaxime Chevallier
247db9d7d36SMaxime Chevallier #define MVPP22_AXI_CODE_CACHE_OFFS 0
248db9d7d36SMaxime Chevallier #define MVPP22_AXI_CODE_DOMAIN_OFFS 4
249db9d7d36SMaxime Chevallier
250db9d7d36SMaxime Chevallier #define MVPP22_AXI_CODE_CACHE_NON_CACHE 0x3
251db9d7d36SMaxime Chevallier #define MVPP22_AXI_CODE_CACHE_WR_CACHE 0x7
252db9d7d36SMaxime Chevallier #define MVPP22_AXI_CODE_CACHE_RD_CACHE 0xb
253db9d7d36SMaxime Chevallier
254db9d7d36SMaxime Chevallier #define MVPP22_AXI_CODE_DOMAIN_OUTER_DOM 2
255db9d7d36SMaxime Chevallier #define MVPP22_AXI_CODE_DOMAIN_SYSTEM 3
256db9d7d36SMaxime Chevallier
257db9d7d36SMaxime Chevallier /* Interrupt Cause and Mask registers */
258db9d7d36SMaxime Chevallier #define MVPP2_ISR_TX_THRESHOLD_REG(port) (0x5140 + 4 * (port))
259db9d7d36SMaxime Chevallier #define MVPP2_MAX_ISR_TX_THRESHOLD 0xfffff0
260db9d7d36SMaxime Chevallier
261db9d7d36SMaxime Chevallier #define MVPP2_ISR_RX_THRESHOLD_REG(rxq) (0x5200 + 4 * (rxq))
262db9d7d36SMaxime Chevallier #define MVPP2_MAX_ISR_RX_THRESHOLD 0xfffff0
263db9d7d36SMaxime Chevallier #define MVPP21_ISR_RXQ_GROUP_REG(port) (0x5400 + 4 * (port))
264db9d7d36SMaxime Chevallier
265db9d7d36SMaxime Chevallier #define MVPP22_ISR_RXQ_GROUP_INDEX_REG 0x5400
266db9d7d36SMaxime Chevallier #define MVPP22_ISR_RXQ_GROUP_INDEX_SUBGROUP_MASK 0xf
267db9d7d36SMaxime Chevallier #define MVPP22_ISR_RXQ_GROUP_INDEX_GROUP_MASK 0x380
268db9d7d36SMaxime Chevallier #define MVPP22_ISR_RXQ_GROUP_INDEX_GROUP_OFFSET 7
269db9d7d36SMaxime Chevallier
270db9d7d36SMaxime Chevallier #define MVPP22_ISR_RXQ_GROUP_INDEX_SUBGROUP_MASK 0xf
271db9d7d36SMaxime Chevallier #define MVPP22_ISR_RXQ_GROUP_INDEX_GROUP_MASK 0x380
272db9d7d36SMaxime Chevallier
273db9d7d36SMaxime Chevallier #define MVPP22_ISR_RXQ_SUB_GROUP_CONFIG_REG 0x5404
274db9d7d36SMaxime Chevallier #define MVPP22_ISR_RXQ_SUB_GROUP_STARTQ_MASK 0x1f
275db9d7d36SMaxime Chevallier #define MVPP22_ISR_RXQ_SUB_GROUP_SIZE_MASK 0xf00
276db9d7d36SMaxime Chevallier #define MVPP22_ISR_RXQ_SUB_GROUP_SIZE_OFFSET 8
277db9d7d36SMaxime Chevallier
278db9d7d36SMaxime Chevallier #define MVPP2_ISR_ENABLE_REG(port) (0x5420 + 4 * (port))
279db9d7d36SMaxime Chevallier #define MVPP2_ISR_ENABLE_INTERRUPT(mask) ((mask) & 0xffff)
280db9d7d36SMaxime Chevallier #define MVPP2_ISR_DISABLE_INTERRUPT(mask) (((mask) << 16) & 0xffff0000)
281db9d7d36SMaxime Chevallier #define MVPP2_ISR_RX_TX_CAUSE_REG(port) (0x5480 + 4 * (port))
28270afb58eSAntoine Tenart #define MVPP2_CAUSE_RXQ_OCCUP_DESC_ALL_MASK(version) \
28370afb58eSAntoine Tenart ((version) == MVPP21 ? 0xffff : 0xff)
284db9d7d36SMaxime Chevallier #define MVPP2_CAUSE_TXQ_OCCUP_DESC_ALL_MASK 0xff0000
285db9d7d36SMaxime Chevallier #define MVPP2_CAUSE_TXQ_OCCUP_DESC_ALL_OFFSET 16
286db9d7d36SMaxime Chevallier #define MVPP2_CAUSE_RX_FIFO_OVERRUN_MASK BIT(24)
287db9d7d36SMaxime Chevallier #define MVPP2_CAUSE_FCS_ERR_MASK BIT(25)
288db9d7d36SMaxime Chevallier #define MVPP2_CAUSE_TX_FIFO_UNDERRUN_MASK BIT(26)
289db9d7d36SMaxime Chevallier #define MVPP2_CAUSE_TX_EXCEPTION_SUM_MASK BIT(29)
290db9d7d36SMaxime Chevallier #define MVPP2_CAUSE_RX_EXCEPTION_SUM_MASK BIT(30)
291db9d7d36SMaxime Chevallier #define MVPP2_CAUSE_MISC_SUM_MASK BIT(31)
292db9d7d36SMaxime Chevallier #define MVPP2_ISR_RX_TX_MASK_REG(port) (0x54a0 + 4 * (port))
293db9d7d36SMaxime Chevallier #define MVPP2_ISR_PON_RX_TX_MASK_REG 0x54bc
294db9d7d36SMaxime Chevallier #define MVPP2_PON_CAUSE_RXQ_OCCUP_DESC_ALL_MASK 0xffff
295db9d7d36SMaxime Chevallier #define MVPP2_PON_CAUSE_TXP_OCCUP_DESC_ALL_MASK 0x3fc00000
296db9d7d36SMaxime Chevallier #define MVPP2_PON_CAUSE_MISC_SUM_MASK BIT(31)
297db9d7d36SMaxime Chevallier #define MVPP2_ISR_MISC_CAUSE_REG 0x55b0
298bf270fa3SStefan Chulski #define MVPP2_ISR_RX_ERR_CAUSE_REG(port) (0x5520 + 4 * (port))
299bf270fa3SStefan Chulski #define MVPP2_ISR_RX_ERR_CAUSE_NONOCC_MASK 0x00ff
300db9d7d36SMaxime Chevallier
301db9d7d36SMaxime Chevallier /* Buffer Manager registers */
302db9d7d36SMaxime Chevallier #define MVPP2_BM_POOL_BASE_REG(pool) (0x6000 + ((pool) * 4))
303db9d7d36SMaxime Chevallier #define MVPP2_BM_POOL_BASE_ADDR_MASK 0xfffff80
304db9d7d36SMaxime Chevallier #define MVPP2_BM_POOL_SIZE_REG(pool) (0x6040 + ((pool) * 4))
305db9d7d36SMaxime Chevallier #define MVPP2_BM_POOL_SIZE_MASK 0xfff0
306db9d7d36SMaxime Chevallier #define MVPP2_BM_POOL_READ_PTR_REG(pool) (0x6080 + ((pool) * 4))
307db9d7d36SMaxime Chevallier #define MVPP2_BM_POOL_GET_READ_PTR_MASK 0xfff0
308db9d7d36SMaxime Chevallier #define MVPP2_BM_POOL_PTRS_NUM_REG(pool) (0x60c0 + ((pool) * 4))
309db9d7d36SMaxime Chevallier #define MVPP2_BM_POOL_PTRS_NUM_MASK 0xfff0
310db9d7d36SMaxime Chevallier #define MVPP2_BM_BPPI_READ_PTR_REG(pool) (0x6100 + ((pool) * 4))
311db9d7d36SMaxime Chevallier #define MVPP2_BM_BPPI_PTRS_NUM_REG(pool) (0x6140 + ((pool) * 4))
312db9d7d36SMaxime Chevallier #define MVPP2_BM_BPPI_PTR_NUM_MASK 0x7ff
313db9d7d36SMaxime Chevallier #define MVPP22_BM_POOL_PTRS_NUM_MASK 0xfff8
314db9d7d36SMaxime Chevallier #define MVPP2_BM_BPPI_PREFETCH_FULL_MASK BIT(16)
315db9d7d36SMaxime Chevallier #define MVPP2_BM_POOL_CTRL_REG(pool) (0x6200 + ((pool) * 4))
316db9d7d36SMaxime Chevallier #define MVPP2_BM_START_MASK BIT(0)
317db9d7d36SMaxime Chevallier #define MVPP2_BM_STOP_MASK BIT(1)
318db9d7d36SMaxime Chevallier #define MVPP2_BM_STATE_MASK BIT(4)
319db9d7d36SMaxime Chevallier #define MVPP2_BM_LOW_THRESH_OFFS 8
320db9d7d36SMaxime Chevallier #define MVPP2_BM_LOW_THRESH_MASK 0x7f00
321db9d7d36SMaxime Chevallier #define MVPP2_BM_LOW_THRESH_VALUE(val) ((val) << \
322db9d7d36SMaxime Chevallier MVPP2_BM_LOW_THRESH_OFFS)
323db9d7d36SMaxime Chevallier #define MVPP2_BM_HIGH_THRESH_OFFS 16
324db9d7d36SMaxime Chevallier #define MVPP2_BM_HIGH_THRESH_MASK 0x7f0000
325db9d7d36SMaxime Chevallier #define MVPP2_BM_HIGH_THRESH_VALUE(val) ((val) << \
326db9d7d36SMaxime Chevallier MVPP2_BM_HIGH_THRESH_OFFS)
327eb30b269SStefan Chulski #define MVPP2_BM_BPPI_HIGH_THRESH 0x1E
328eb30b269SStefan Chulski #define MVPP2_BM_BPPI_LOW_THRESH 0x1C
329eb30b269SStefan Chulski #define MVPP23_BM_BPPI_HIGH_THRESH 0x34
330eb30b269SStefan Chulski #define MVPP23_BM_BPPI_LOW_THRESH 0x28
331db9d7d36SMaxime Chevallier #define MVPP2_BM_INTR_CAUSE_REG(pool) (0x6240 + ((pool) * 4))
332db9d7d36SMaxime Chevallier #define MVPP2_BM_RELEASED_DELAY_MASK BIT(0)
333db9d7d36SMaxime Chevallier #define MVPP2_BM_ALLOC_FAILED_MASK BIT(1)
334db9d7d36SMaxime Chevallier #define MVPP2_BM_BPPE_EMPTY_MASK BIT(2)
335db9d7d36SMaxime Chevallier #define MVPP2_BM_BPPE_FULL_MASK BIT(3)
336db9d7d36SMaxime Chevallier #define MVPP2_BM_AVAILABLE_BP_LOW_MASK BIT(4)
337db9d7d36SMaxime Chevallier #define MVPP2_BM_INTR_MASK_REG(pool) (0x6280 + ((pool) * 4))
338db9d7d36SMaxime Chevallier #define MVPP2_BM_PHY_ALLOC_REG(pool) (0x6400 + ((pool) * 4))
339db9d7d36SMaxime Chevallier #define MVPP2_BM_PHY_ALLOC_GRNTD_MASK BIT(0)
340db9d7d36SMaxime Chevallier #define MVPP2_BM_VIRT_ALLOC_REG 0x6440
341db9d7d36SMaxime Chevallier #define MVPP22_BM_ADDR_HIGH_ALLOC 0x6444
342db9d7d36SMaxime Chevallier #define MVPP22_BM_ADDR_HIGH_PHYS_MASK 0xff
343db9d7d36SMaxime Chevallier #define MVPP22_BM_ADDR_HIGH_VIRT_MASK 0xff00
344db9d7d36SMaxime Chevallier #define MVPP22_BM_ADDR_HIGH_VIRT_SHIFT 8
345db9d7d36SMaxime Chevallier #define MVPP2_BM_PHY_RLS_REG(pool) (0x6480 + ((pool) * 4))
346db9d7d36SMaxime Chevallier #define MVPP2_BM_PHY_RLS_MC_BUFF_MASK BIT(0)
347db9d7d36SMaxime Chevallier #define MVPP2_BM_PHY_RLS_PRIO_EN_MASK BIT(1)
348db9d7d36SMaxime Chevallier #define MVPP2_BM_PHY_RLS_GRNTD_MASK BIT(2)
349db9d7d36SMaxime Chevallier #define MVPP2_BM_VIRT_RLS_REG 0x64c0
350db9d7d36SMaxime Chevallier #define MVPP22_BM_ADDR_HIGH_RLS_REG 0x64c4
351db9d7d36SMaxime Chevallier #define MVPP22_BM_ADDR_HIGH_PHYS_RLS_MASK 0xff
352db9d7d36SMaxime Chevallier #define MVPP22_BM_ADDR_HIGH_VIRT_RLS_MASK 0xff00
353db9d7d36SMaxime Chevallier #define MVPP22_BM_ADDR_HIGH_VIRT_RLS_SHIFT 8
354db9d7d36SMaxime Chevallier
3559bea6897SMaxime Chevallier /* Packet Processor per-port counters */
3569bea6897SMaxime Chevallier #define MVPP2_OVERRUN_ETH_DROP 0x7000
3579bea6897SMaxime Chevallier #define MVPP2_CLS_ETH_DROP 0x7020
3589bea6897SMaxime Chevallier
359eb30b269SStefan Chulski #define MVPP22_BM_POOL_BASE_ADDR_HIGH_REG 0x6310
360eb30b269SStefan Chulski #define MVPP22_BM_POOL_BASE_ADDR_HIGH_MASK 0xff
361eb30b269SStefan Chulski #define MVPP23_BM_8POOL_MODE BIT(8)
362eb30b269SStefan Chulski
363f9d30d5bSMaxime Chevallier /* Hit counters registers */
364f9d30d5bSMaxime Chevallier #define MVPP2_CTRS_IDX 0x7040
3659bea6897SMaxime Chevallier #define MVPP22_CTRS_TX_CTR(port, txq) ((txq) | ((port) << 3) | BIT(7))
3669bea6897SMaxime Chevallier #define MVPP2_TX_DESC_ENQ_CTR 0x7100
3679bea6897SMaxime Chevallier #define MVPP2_TX_DESC_ENQ_TO_DDR_CTR 0x7104
3689bea6897SMaxime Chevallier #define MVPP2_TX_BUFF_ENQ_TO_DDR_CTR 0x7108
3699bea6897SMaxime Chevallier #define MVPP2_TX_DESC_ENQ_HW_FWD_CTR 0x710c
3709bea6897SMaxime Chevallier #define MVPP2_RX_DESC_ENQ_CTR 0x7120
3719bea6897SMaxime Chevallier #define MVPP2_TX_PKTS_DEQ_CTR 0x7130
3729bea6897SMaxime Chevallier #define MVPP2_TX_PKTS_FULL_QUEUE_DROP_CTR 0x7200
3739bea6897SMaxime Chevallier #define MVPP2_TX_PKTS_EARLY_DROP_CTR 0x7204
3749bea6897SMaxime Chevallier #define MVPP2_TX_PKTS_BM_DROP_CTR 0x7208
3759bea6897SMaxime Chevallier #define MVPP2_TX_PKTS_BM_MC_DROP_CTR 0x720c
3769bea6897SMaxime Chevallier #define MVPP2_RX_PKTS_FULL_QUEUE_DROP_CTR 0x7220
3779bea6897SMaxime Chevallier #define MVPP2_RX_PKTS_EARLY_DROP_CTR 0x7224
3789bea6897SMaxime Chevallier #define MVPP2_RX_PKTS_BM_DROP_CTR 0x7228
379f9d30d5bSMaxime Chevallier #define MVPP2_CLS_DEC_TBL_HIT_CTR 0x7700
380f9d30d5bSMaxime Chevallier #define MVPP2_CLS_FLOW_TBL_HIT_CTR 0x7704
381f9d30d5bSMaxime Chevallier
382db9d7d36SMaxime Chevallier /* TX Scheduler registers */
383db9d7d36SMaxime Chevallier #define MVPP2_TXP_SCHED_PORT_INDEX_REG 0x8000
384db9d7d36SMaxime Chevallier #define MVPP2_TXP_SCHED_Q_CMD_REG 0x8004
385db9d7d36SMaxime Chevallier #define MVPP2_TXP_SCHED_ENQ_MASK 0xff
386db9d7d36SMaxime Chevallier #define MVPP2_TXP_SCHED_DISQ_OFFSET 8
387db9d7d36SMaxime Chevallier #define MVPP2_TXP_SCHED_CMD_1_REG 0x8010
3884251ea5bSMaxime Chevallier #define MVPP2_TXP_SCHED_FIXED_PRIO_REG 0x8014
389db9d7d36SMaxime Chevallier #define MVPP2_TXP_SCHED_PERIOD_REG 0x8018
390db9d7d36SMaxime Chevallier #define MVPP2_TXP_SCHED_MTU_REG 0x801c
391db9d7d36SMaxime Chevallier #define MVPP2_TXP_MTU_MAX 0x7FFFF
392db9d7d36SMaxime Chevallier #define MVPP2_TXP_SCHED_REFILL_REG 0x8020
393db9d7d36SMaxime Chevallier #define MVPP2_TXP_REFILL_TOKENS_ALL_MASK 0x7ffff
394db9d7d36SMaxime Chevallier #define MVPP2_TXP_REFILL_PERIOD_ALL_MASK 0x3ff00000
395db9d7d36SMaxime Chevallier #define MVPP2_TXP_REFILL_PERIOD_MASK(v) ((v) << 20)
396db9d7d36SMaxime Chevallier #define MVPP2_TXP_SCHED_TOKEN_SIZE_REG 0x8024
397db9d7d36SMaxime Chevallier #define MVPP2_TXP_TOKEN_SIZE_MAX 0xffffffff
398db9d7d36SMaxime Chevallier #define MVPP2_TXQ_SCHED_REFILL_REG(q) (0x8040 + ((q) << 2))
399db9d7d36SMaxime Chevallier #define MVPP2_TXQ_REFILL_TOKENS_ALL_MASK 0x7ffff
400db9d7d36SMaxime Chevallier #define MVPP2_TXQ_REFILL_PERIOD_ALL_MASK 0x3ff00000
401db9d7d36SMaxime Chevallier #define MVPP2_TXQ_REFILL_PERIOD_MASK(v) ((v) << 20)
402db9d7d36SMaxime Chevallier #define MVPP2_TXQ_SCHED_TOKEN_SIZE_REG(q) (0x8060 + ((q) << 2))
403db9d7d36SMaxime Chevallier #define MVPP2_TXQ_TOKEN_SIZE_MAX 0x7fffffff
404db9d7d36SMaxime Chevallier #define MVPP2_TXQ_SCHED_TOKEN_CNTR_REG(q) (0x8080 + ((q) << 2))
405db9d7d36SMaxime Chevallier #define MVPP2_TXQ_TOKEN_CNTR_MAX 0xffffffff
406db9d7d36SMaxime Chevallier
407db9d7d36SMaxime Chevallier /* TX general registers */
408db9d7d36SMaxime Chevallier #define MVPP2_TX_SNOOP_REG 0x8800
409db9d7d36SMaxime Chevallier #define MVPP2_TX_PORT_FLUSH_REG 0x8810
410db9d7d36SMaxime Chevallier #define MVPP2_TX_PORT_FLUSH_MASK(port) (1 << (port))
411db9d7d36SMaxime Chevallier
412db9d7d36SMaxime Chevallier /* LMS registers */
413db9d7d36SMaxime Chevallier #define MVPP2_SRC_ADDR_MIDDLE 0x24
414db9d7d36SMaxime Chevallier #define MVPP2_SRC_ADDR_HIGH 0x28
415db9d7d36SMaxime Chevallier #define MVPP2_PHY_AN_CFG0_REG 0x34
416db9d7d36SMaxime Chevallier #define MVPP2_PHY_AN_STOP_SMI0_MASK BIT(7)
417db9d7d36SMaxime Chevallier #define MVPP2_MNG_EXTENDED_GLOBAL_CTRL_REG 0x305c
418db9d7d36SMaxime Chevallier #define MVPP2_EXT_GLOBAL_CTRL_DEFAULT 0x27
419db9d7d36SMaxime Chevallier
420db9d7d36SMaxime Chevallier /* Per-port registers */
421db9d7d36SMaxime Chevallier #define MVPP2_GMAC_CTRL_0_REG 0x0
422db9d7d36SMaxime Chevallier #define MVPP2_GMAC_PORT_EN_MASK BIT(0)
423db9d7d36SMaxime Chevallier #define MVPP2_GMAC_PORT_TYPE_MASK BIT(1)
424db9d7d36SMaxime Chevallier #define MVPP2_GMAC_MAX_RX_SIZE_OFFS 2
425db9d7d36SMaxime Chevallier #define MVPP2_GMAC_MAX_RX_SIZE_MASK 0x7ffc
426db9d7d36SMaxime Chevallier #define MVPP2_GMAC_MIB_CNTR_EN_MASK BIT(15)
427db9d7d36SMaxime Chevallier #define MVPP2_GMAC_CTRL_1_REG 0x4
428db9d7d36SMaxime Chevallier #define MVPP2_GMAC_PERIODIC_XON_EN_MASK BIT(1)
429db9d7d36SMaxime Chevallier #define MVPP2_GMAC_GMII_LB_EN_MASK BIT(5)
430db9d7d36SMaxime Chevallier #define MVPP2_GMAC_PCS_LB_EN_BIT 6
431db9d7d36SMaxime Chevallier #define MVPP2_GMAC_PCS_LB_EN_MASK BIT(6)
432db9d7d36SMaxime Chevallier #define MVPP2_GMAC_SA_LOW_OFFS 7
433db9d7d36SMaxime Chevallier #define MVPP2_GMAC_CTRL_2_REG 0x8
434db9d7d36SMaxime Chevallier #define MVPP2_GMAC_INBAND_AN_MASK BIT(0)
435db9d7d36SMaxime Chevallier #define MVPP2_GMAC_FLOW_CTRL_MASK GENMASK(2, 1)
436db9d7d36SMaxime Chevallier #define MVPP2_GMAC_PCS_ENABLE_MASK BIT(3)
437db9d7d36SMaxime Chevallier #define MVPP2_GMAC_INTERNAL_CLK_MASK BIT(4)
438db9d7d36SMaxime Chevallier #define MVPP2_GMAC_DISABLE_PADDING BIT(5)
439db9d7d36SMaxime Chevallier #define MVPP2_GMAC_PORT_RESET_MASK BIT(6)
440db9d7d36SMaxime Chevallier #define MVPP2_GMAC_AUTONEG_CONFIG 0xc
441db9d7d36SMaxime Chevallier #define MVPP2_GMAC_FORCE_LINK_DOWN BIT(0)
442db9d7d36SMaxime Chevallier #define MVPP2_GMAC_FORCE_LINK_PASS BIT(1)
443db9d7d36SMaxime Chevallier #define MVPP2_GMAC_IN_BAND_AUTONEG BIT(2)
444db9d7d36SMaxime Chevallier #define MVPP2_GMAC_IN_BAND_AUTONEG_BYPASS BIT(3)
445db9d7d36SMaxime Chevallier #define MVPP2_GMAC_IN_BAND_RESTART_AN BIT(4)
446db9d7d36SMaxime Chevallier #define MVPP2_GMAC_CONFIG_MII_SPEED BIT(5)
447db9d7d36SMaxime Chevallier #define MVPP2_GMAC_CONFIG_GMII_SPEED BIT(6)
448db9d7d36SMaxime Chevallier #define MVPP2_GMAC_AN_SPEED_EN BIT(7)
449db9d7d36SMaxime Chevallier #define MVPP2_GMAC_FC_ADV_EN BIT(9)
450db9d7d36SMaxime Chevallier #define MVPP2_GMAC_FC_ADV_ASM_EN BIT(10)
451db9d7d36SMaxime Chevallier #define MVPP2_GMAC_FLOW_CTRL_AUTONEG BIT(11)
452db9d7d36SMaxime Chevallier #define MVPP2_GMAC_CONFIG_FULL_DUPLEX BIT(12)
453db9d7d36SMaxime Chevallier #define MVPP2_GMAC_AN_DUPLEX_EN BIT(13)
454db9d7d36SMaxime Chevallier #define MVPP2_GMAC_STATUS0 0x10
455db9d7d36SMaxime Chevallier #define MVPP2_GMAC_STATUS0_LINK_UP BIT(0)
456db9d7d36SMaxime Chevallier #define MVPP2_GMAC_STATUS0_GMII_SPEED BIT(1)
457db9d7d36SMaxime Chevallier #define MVPP2_GMAC_STATUS0_MII_SPEED BIT(2)
458db9d7d36SMaxime Chevallier #define MVPP2_GMAC_STATUS0_FULL_DUPLEX BIT(3)
459417f3d08SRussell King #define MVPP2_GMAC_STATUS0_RX_PAUSE BIT(4)
460417f3d08SRussell King #define MVPP2_GMAC_STATUS0_TX_PAUSE BIT(5)
461db9d7d36SMaxime Chevallier #define MVPP2_GMAC_STATUS0_AN_COMPLETE BIT(11)
462db9d7d36SMaxime Chevallier #define MVPP2_GMAC_PORT_FIFO_CFG_1_REG 0x1c
463db9d7d36SMaxime Chevallier #define MVPP2_GMAC_TX_FIFO_MIN_TH_OFFS 6
464db9d7d36SMaxime Chevallier #define MVPP2_GMAC_TX_FIFO_MIN_TH_ALL_MASK 0x1fc0
465db9d7d36SMaxime Chevallier #define MVPP2_GMAC_TX_FIFO_MIN_TH_MASK(v) (((v) << 6) & \
466db9d7d36SMaxime Chevallier MVPP2_GMAC_TX_FIFO_MIN_TH_ALL_MASK)
467db9d7d36SMaxime Chevallier #define MVPP22_GMAC_INT_STAT 0x20
468db9d7d36SMaxime Chevallier #define MVPP22_GMAC_INT_STAT_LINK BIT(1)
469db9d7d36SMaxime Chevallier #define MVPP22_GMAC_INT_MASK 0x24
470db9d7d36SMaxime Chevallier #define MVPP22_GMAC_INT_MASK_LINK_STAT BIT(1)
471db9d7d36SMaxime Chevallier #define MVPP22_GMAC_CTRL_4_REG 0x90
472db9d7d36SMaxime Chevallier #define MVPP22_CTRL4_EXT_PIN_GMII_SEL BIT(0)
473db9d7d36SMaxime Chevallier #define MVPP22_CTRL4_RX_FC_EN BIT(3)
474db9d7d36SMaxime Chevallier #define MVPP22_CTRL4_TX_FC_EN BIT(4)
475db9d7d36SMaxime Chevallier #define MVPP22_CTRL4_DP_CLK_SEL BIT(5)
476db9d7d36SMaxime Chevallier #define MVPP22_CTRL4_SYNC_BYPASS_DIS BIT(6)
477db9d7d36SMaxime Chevallier #define MVPP22_CTRL4_QSGMII_BYPASS_ACTIVE BIT(7)
478b4b17714SRussell King #define MVPP22_GMAC_INT_SUM_STAT 0xa0
479b4b17714SRussell King #define MVPP22_GMAC_INT_SUM_STAT_INTERNAL BIT(1)
480f5015a59SRussell King #define MVPP22_GMAC_INT_SUM_STAT_PTP BIT(2)
481db9d7d36SMaxime Chevallier #define MVPP22_GMAC_INT_SUM_MASK 0xa4
482db9d7d36SMaxime Chevallier #define MVPP22_GMAC_INT_SUM_MASK_LINK_STAT BIT(1)
483f5015a59SRussell King #define MVPP22_GMAC_INT_SUM_MASK_PTP BIT(2)
484db9d7d36SMaxime Chevallier
4856af27a1dSStefan Chulski /* Per-port XGMAC registers. PPv2.2 and PPv2.3, only for GOP port 0,
486db9d7d36SMaxime Chevallier * relative to port->base.
487db9d7d36SMaxime Chevallier */
488db9d7d36SMaxime Chevallier #define MVPP22_XLG_CTRL0_REG 0x100
489db9d7d36SMaxime Chevallier #define MVPP22_XLG_CTRL0_PORT_EN BIT(0)
490db9d7d36SMaxime Chevallier #define MVPP22_XLG_CTRL0_MAC_RESET_DIS BIT(1)
4911970ee96SAntoine Tenart #define MVPP22_XLG_CTRL0_FORCE_LINK_DOWN BIT(2)
4921970ee96SAntoine Tenart #define MVPP22_XLG_CTRL0_FORCE_LINK_PASS BIT(3)
493db9d7d36SMaxime Chevallier #define MVPP22_XLG_CTRL0_RX_FLOW_CTRL_EN BIT(7)
494db9d7d36SMaxime Chevallier #define MVPP22_XLG_CTRL0_TX_FLOW_CTRL_EN BIT(8)
495db9d7d36SMaxime Chevallier #define MVPP22_XLG_CTRL0_MIB_CNT_DIS BIT(14)
496db9d7d36SMaxime Chevallier #define MVPP22_XLG_CTRL1_REG 0x104
497db9d7d36SMaxime Chevallier #define MVPP22_XLG_CTRL1_FRAMESIZELIMIT_OFFS 0
498db9d7d36SMaxime Chevallier #define MVPP22_XLG_CTRL1_FRAMESIZELIMIT_MASK 0x1fff
499db9d7d36SMaxime Chevallier #define MVPP22_XLG_STATUS 0x10c
500db9d7d36SMaxime Chevallier #define MVPP22_XLG_STATUS_LINK_UP BIT(0)
501db9d7d36SMaxime Chevallier #define MVPP22_XLG_INT_STAT 0x114
502db9d7d36SMaxime Chevallier #define MVPP22_XLG_INT_STAT_LINK BIT(1)
503db9d7d36SMaxime Chevallier #define MVPP22_XLG_INT_MASK 0x118
504db9d7d36SMaxime Chevallier #define MVPP22_XLG_INT_MASK_LINK BIT(1)
505db9d7d36SMaxime Chevallier #define MVPP22_XLG_CTRL3_REG 0x11c
506db9d7d36SMaxime Chevallier #define MVPP22_XLG_CTRL3_MACMODESELECT_MASK (7 << 13)
507db9d7d36SMaxime Chevallier #define MVPP22_XLG_CTRL3_MACMODESELECT_GMAC (0 << 13)
508db9d7d36SMaxime Chevallier #define MVPP22_XLG_CTRL3_MACMODESELECT_10G (1 << 13)
509b4b17714SRussell King #define MVPP22_XLG_EXT_INT_STAT 0x158
510b4b17714SRussell King #define MVPP22_XLG_EXT_INT_STAT_XLG BIT(1)
511f5015a59SRussell King #define MVPP22_XLG_EXT_INT_STAT_PTP BIT(7)
512db9d7d36SMaxime Chevallier #define MVPP22_XLG_EXT_INT_MASK 0x15c
513db9d7d36SMaxime Chevallier #define MVPP22_XLG_EXT_INT_MASK_XLG BIT(1)
514db9d7d36SMaxime Chevallier #define MVPP22_XLG_EXT_INT_MASK_GIG BIT(2)
515f5015a59SRussell King #define MVPP22_XLG_EXT_INT_MASK_PTP BIT(7)
516db9d7d36SMaxime Chevallier #define MVPP22_XLG_CTRL4_REG 0x184
517db9d7d36SMaxime Chevallier #define MVPP22_XLG_CTRL4_FWD_FC BIT(5)
518db9d7d36SMaxime Chevallier #define MVPP22_XLG_CTRL4_FWD_PFC BIT(6)
519db9d7d36SMaxime Chevallier #define MVPP22_XLG_CTRL4_MACMODSELECT_GMAC BIT(12)
520db9d7d36SMaxime Chevallier #define MVPP22_XLG_CTRL4_EN_IDLE_CHECK BIT(14)
521db9d7d36SMaxime Chevallier
5226af27a1dSStefan Chulski /* SMI registers. PPv2.2 and PPv2.3, relative to priv->iface_base. */
523db9d7d36SMaxime Chevallier #define MVPP22_SMI_MISC_CFG_REG 0x1204
524db9d7d36SMaxime Chevallier #define MVPP22_SMI_POLLING_EN BIT(10)
525db9d7d36SMaxime Chevallier
52691dd7195SRussell King /* TAI registers, PPv2.2 only, relative to priv->iface_base */
52791dd7195SRussell King #define MVPP22_TAI_INT_CAUSE 0x1400
52891dd7195SRussell King #define MVPP22_TAI_INT_MASK 0x1404
52991dd7195SRussell King #define MVPP22_TAI_CR0 0x1408
53091dd7195SRussell King #define MVPP22_TAI_CR1 0x140c
53191dd7195SRussell King #define MVPP22_TAI_TCFCR0 0x1410
53291dd7195SRussell King #define MVPP22_TAI_TCFCR1 0x1414
53391dd7195SRussell King #define MVPP22_TAI_TCFCR2 0x1418
53491dd7195SRussell King #define MVPP22_TAI_FATWR 0x141c
53591dd7195SRussell King #define MVPP22_TAI_TOD_STEP_NANO_CR 0x1420
53691dd7195SRussell King #define MVPP22_TAI_TOD_STEP_FRAC_HIGH 0x1424
53791dd7195SRussell King #define MVPP22_TAI_TOD_STEP_FRAC_LOW 0x1428
53891dd7195SRussell King #define MVPP22_TAI_TAPDC_HIGH 0x142c
53991dd7195SRussell King #define MVPP22_TAI_TAPDC_LOW 0x1430
54091dd7195SRussell King #define MVPP22_TAI_TGTOD_SEC_HIGH 0x1434
54191dd7195SRussell King #define MVPP22_TAI_TGTOD_SEC_MED 0x1438
54291dd7195SRussell King #define MVPP22_TAI_TGTOD_SEC_LOW 0x143c
54391dd7195SRussell King #define MVPP22_TAI_TGTOD_NANO_HIGH 0x1440
54491dd7195SRussell King #define MVPP22_TAI_TGTOD_NANO_LOW 0x1444
54591dd7195SRussell King #define MVPP22_TAI_TGTOD_FRAC_HIGH 0x1448
54691dd7195SRussell King #define MVPP22_TAI_TGTOD_FRAC_LOW 0x144c
54791dd7195SRussell King #define MVPP22_TAI_TLV_SEC_HIGH 0x1450
54891dd7195SRussell King #define MVPP22_TAI_TLV_SEC_MED 0x1454
54991dd7195SRussell King #define MVPP22_TAI_TLV_SEC_LOW 0x1458
55091dd7195SRussell King #define MVPP22_TAI_TLV_NANO_HIGH 0x145c
55191dd7195SRussell King #define MVPP22_TAI_TLV_NANO_LOW 0x1460
55291dd7195SRussell King #define MVPP22_TAI_TLV_FRAC_HIGH 0x1464
55391dd7195SRussell King #define MVPP22_TAI_TLV_FRAC_LOW 0x1468
55491dd7195SRussell King #define MVPP22_TAI_TCV0_SEC_HIGH 0x146c
55591dd7195SRussell King #define MVPP22_TAI_TCV0_SEC_MED 0x1470
55691dd7195SRussell King #define MVPP22_TAI_TCV0_SEC_LOW 0x1474
55791dd7195SRussell King #define MVPP22_TAI_TCV0_NANO_HIGH 0x1478
55891dd7195SRussell King #define MVPP22_TAI_TCV0_NANO_LOW 0x147c
55991dd7195SRussell King #define MVPP22_TAI_TCV0_FRAC_HIGH 0x1480
56091dd7195SRussell King #define MVPP22_TAI_TCV0_FRAC_LOW 0x1484
56191dd7195SRussell King #define MVPP22_TAI_TCV1_SEC_HIGH 0x1488
56291dd7195SRussell King #define MVPP22_TAI_TCV1_SEC_MED 0x148c
56391dd7195SRussell King #define MVPP22_TAI_TCV1_SEC_LOW 0x1490
56491dd7195SRussell King #define MVPP22_TAI_TCV1_NANO_HIGH 0x1494
56591dd7195SRussell King #define MVPP22_TAI_TCV1_NANO_LOW 0x1498
56691dd7195SRussell King #define MVPP22_TAI_TCV1_FRAC_HIGH 0x149c
56791dd7195SRussell King #define MVPP22_TAI_TCV1_FRAC_LOW 0x14a0
56891dd7195SRussell King #define MVPP22_TAI_TCSR 0x14a4
56991dd7195SRussell King #define MVPP22_TAI_TUC_LSB 0x14a8
57091dd7195SRussell King #define MVPP22_TAI_GFM_SEC_HIGH 0x14ac
57191dd7195SRussell King #define MVPP22_TAI_GFM_SEC_MED 0x14b0
57291dd7195SRussell King #define MVPP22_TAI_GFM_SEC_LOW 0x14b4
57391dd7195SRussell King #define MVPP22_TAI_GFM_NANO_HIGH 0x14b8
57491dd7195SRussell King #define MVPP22_TAI_GFM_NANO_LOW 0x14bc
57591dd7195SRussell King #define MVPP22_TAI_GFM_FRAC_HIGH 0x14c0
57691dd7195SRussell King #define MVPP22_TAI_GFM_FRAC_LOW 0x14c4
57791dd7195SRussell King #define MVPP22_TAI_PCLK_DA_HIGH 0x14c8
57891dd7195SRussell King #define MVPP22_TAI_PCLK_DA_LOW 0x14cc
57991dd7195SRussell King #define MVPP22_TAI_CTCR 0x14d0
58091dd7195SRussell King #define MVPP22_TAI_PCLK_CCC_HIGH 0x14d4
58191dd7195SRussell King #define MVPP22_TAI_PCLK_CCC_LOW 0x14d8
58291dd7195SRussell King #define MVPP22_TAI_DTC_HIGH 0x14dc
58391dd7195SRussell King #define MVPP22_TAI_DTC_LOW 0x14e0
58491dd7195SRussell King #define MVPP22_TAI_CCC_HIGH 0x14e4
58591dd7195SRussell King #define MVPP22_TAI_CCC_LOW 0x14e8
58691dd7195SRussell King #define MVPP22_TAI_ICICE 0x14f4
58791dd7195SRussell King #define MVPP22_TAI_ICICC_LOW 0x14f8
58891dd7195SRussell King #define MVPP22_TAI_TUC_MSB 0x14fc
58991dd7195SRussell King
590db9d7d36SMaxime Chevallier #define MVPP22_GMAC_BASE(port) (0x7000 + (port) * 0x1000 + 0xe00)
591db9d7d36SMaxime Chevallier
592db9d7d36SMaxime Chevallier #define MVPP2_CAUSE_TXQ_SENT_DESC_ALL_MASK 0xff
593db9d7d36SMaxime Chevallier
594db9d7d36SMaxime Chevallier /* Descriptor ring Macros */
595db9d7d36SMaxime Chevallier #define MVPP2_QUEUE_NEXT_DESC(q, index) \
596db9d7d36SMaxime Chevallier (((index) < (q)->last_desc) ? ((index) + 1) : 0)
597db9d7d36SMaxime Chevallier
5986af27a1dSStefan Chulski /* XPCS registers.PPv2.2 and PPv2.3 */
599db9d7d36SMaxime Chevallier #define MVPP22_MPCS_BASE(port) (0x7000 + (port) * 0x1000)
600db9d7d36SMaxime Chevallier #define MVPP22_MPCS_CTRL 0x14
601db9d7d36SMaxime Chevallier #define MVPP22_MPCS_CTRL_FWD_ERR_CONN BIT(10)
602db9d7d36SMaxime Chevallier #define MVPP22_MPCS_CLK_RESET 0x14c
603db9d7d36SMaxime Chevallier #define MAC_CLK_RESET_SD_TX BIT(0)
604db9d7d36SMaxime Chevallier #define MAC_CLK_RESET_SD_RX BIT(1)
605db9d7d36SMaxime Chevallier #define MAC_CLK_RESET_MAC BIT(2)
606db9d7d36SMaxime Chevallier #define MVPP22_MPCS_CLK_RESET_DIV_RATIO(n) ((n) << 4)
607db9d7d36SMaxime Chevallier #define MVPP22_MPCS_CLK_RESET_DIV_SET BIT(11)
608db9d7d36SMaxime Chevallier
6092788d841SStefan Chulski /* FCA registers. PPv2.2 and PPv2.3 */
6102788d841SStefan Chulski #define MVPP22_FCA_BASE(port) (0x7600 + (port) * 0x1000)
6112788d841SStefan Chulski #define MVPP22_FCA_REG_SIZE 16
6122788d841SStefan Chulski #define MVPP22_FCA_REG_MASK 0xFFFF
6132788d841SStefan Chulski #define MVPP22_FCA_CONTROL_REG 0x0
6142788d841SStefan Chulski #define MVPP22_FCA_ENABLE_PERIODIC BIT(11)
6152788d841SStefan Chulski #define MVPP22_PERIODIC_COUNTER_LSB_REG (0x110)
6162788d841SStefan Chulski #define MVPP22_PERIODIC_COUNTER_MSB_REG (0x114)
6172788d841SStefan Chulski
6186af27a1dSStefan Chulski /* XPCS registers. PPv2.2 and PPv2.3 */
619db9d7d36SMaxime Chevallier #define MVPP22_XPCS_BASE(port) (0x7400 + (port) * 0x1000)
620db9d7d36SMaxime Chevallier #define MVPP22_XPCS_CFG0 0x0
6217409e66eSAntoine Tenart #define MVPP22_XPCS_CFG0_RESET_DIS BIT(0)
622db9d7d36SMaxime Chevallier #define MVPP22_XPCS_CFG0_PCS_MODE(n) ((n) << 3)
623db9d7d36SMaxime Chevallier #define MVPP22_XPCS_CFG0_ACTIVE_LANE(n) ((n) << 5)
624db9d7d36SMaxime Chevallier
62591dd7195SRussell King /* PTP registers. PPv2.2 only */
62691dd7195SRussell King #define MVPP22_PTP_BASE(port) (0x7800 + (port * 0x1000))
62791dd7195SRussell King #define MVPP22_PTP_INT_CAUSE 0x00
628f5015a59SRussell King #define MVPP22_PTP_INT_CAUSE_QUEUE1 BIT(6)
629f5015a59SRussell King #define MVPP22_PTP_INT_CAUSE_QUEUE0 BIT(5)
63091dd7195SRussell King #define MVPP22_PTP_INT_MASK 0x04
631f5015a59SRussell King #define MVPP22_PTP_INT_MASK_QUEUE1 BIT(6)
632f5015a59SRussell King #define MVPP22_PTP_INT_MASK_QUEUE0 BIT(5)
63391dd7195SRussell King #define MVPP22_PTP_GCR 0x08
634ce3497e2SRussell King #define MVPP22_PTP_GCR_RX_RESET BIT(13)
635ce3497e2SRussell King #define MVPP22_PTP_GCR_TX_RESET BIT(1)
636ce3497e2SRussell King #define MVPP22_PTP_GCR_TSU_ENABLE BIT(0)
63791dd7195SRussell King #define MVPP22_PTP_TX_Q0_R0 0x0c
63891dd7195SRussell King #define MVPP22_PTP_TX_Q0_R1 0x10
63991dd7195SRussell King #define MVPP22_PTP_TX_Q0_R2 0x14
64091dd7195SRussell King #define MVPP22_PTP_TX_Q1_R0 0x18
64191dd7195SRussell King #define MVPP22_PTP_TX_Q1_R1 0x1c
64291dd7195SRussell King #define MVPP22_PTP_TX_Q1_R2 0x20
64391dd7195SRussell King #define MVPP22_PTP_TPCR 0x24
64491dd7195SRussell King #define MVPP22_PTP_V1PCR 0x28
64591dd7195SRussell King #define MVPP22_PTP_V2PCR 0x2c
64691dd7195SRussell King #define MVPP22_PTP_Y1731PCR 0x30
64791dd7195SRussell King #define MVPP22_PTP_NTPTSPCR 0x34
64891dd7195SRussell King #define MVPP22_PTP_NTPRXPCR 0x38
64991dd7195SRussell King #define MVPP22_PTP_NTPTXPCR 0x3c
65091dd7195SRussell King #define MVPP22_PTP_WAMPPCR 0x40
65191dd7195SRussell King #define MVPP22_PTP_NAPCR 0x44
65291dd7195SRussell King #define MVPP22_PTP_FAPCR 0x48
65391dd7195SRussell King #define MVPP22_PTP_CAPCR 0x50
65491dd7195SRussell King #define MVPP22_PTP_ATAPCR 0x54
65591dd7195SRussell King #define MVPP22_PTP_ACTAPCR 0x58
65691dd7195SRussell King #define MVPP22_PTP_CATAPCR 0x5c
65791dd7195SRussell King #define MVPP22_PTP_CACTAPCR 0x60
65891dd7195SRussell King #define MVPP22_PTP_AITAPCR 0x64
65991dd7195SRussell King #define MVPP22_PTP_CAITAPCR 0x68
66091dd7195SRussell King #define MVPP22_PTP_CITAPCR 0x6c
66191dd7195SRussell King #define MVPP22_PTP_NTP_OFF_HIGH 0x70
66291dd7195SRussell King #define MVPP22_PTP_NTP_OFF_LOW 0x74
66391dd7195SRussell King #define MVPP22_PTP_TX_PIPE_STATUS_DELAY 0x78
66491dd7195SRussell King
665db9d7d36SMaxime Chevallier /* System controller registers. Accessed through a regmap. */
666db9d7d36SMaxime Chevallier #define GENCONF_SOFT_RESET1 0x1108
667db9d7d36SMaxime Chevallier #define GENCONF_SOFT_RESET1_GOP BIT(6)
668db9d7d36SMaxime Chevallier #define GENCONF_PORT_CTRL0 0x1110
669db9d7d36SMaxime Chevallier #define GENCONF_PORT_CTRL0_BUS_WIDTH_SELECT BIT(1)
670db9d7d36SMaxime Chevallier #define GENCONF_PORT_CTRL0_RX_DATA_SAMPLE BIT(29)
671db9d7d36SMaxime Chevallier #define GENCONF_PORT_CTRL0_CLK_DIV_PHASE_CLR BIT(31)
672db9d7d36SMaxime Chevallier #define GENCONF_PORT_CTRL1 0x1114
673db9d7d36SMaxime Chevallier #define GENCONF_PORT_CTRL1_EN(p) BIT(p)
674db9d7d36SMaxime Chevallier #define GENCONF_PORT_CTRL1_RESET(p) (BIT(p) << 28)
675db9d7d36SMaxime Chevallier #define GENCONF_CTRL0 0x1120
676935a1184SStefan Chulski #define GENCONF_CTRL0_PORT2_RGMII BIT(0)
677935a1184SStefan Chulski #define GENCONF_CTRL0_PORT3_RGMII_MII BIT(1)
678935a1184SStefan Chulski #define GENCONF_CTRL0_PORT3_RGMII BIT(2)
679db9d7d36SMaxime Chevallier
680db9d7d36SMaxime Chevallier /* Various constants */
681db9d7d36SMaxime Chevallier
682db9d7d36SMaxime Chevallier /* Coalescing */
683db9d7d36SMaxime Chevallier #define MVPP2_TXDONE_COAL_PKTS_THRESH 64
684db9d7d36SMaxime Chevallier #define MVPP2_TXDONE_HRTIMER_PERIOD_NS 1000000UL
685db9d7d36SMaxime Chevallier #define MVPP2_TXDONE_COAL_USEC 1000
686db9d7d36SMaxime Chevallier #define MVPP2_RX_COAL_PKTS 32
687db9d7d36SMaxime Chevallier #define MVPP2_RX_COAL_USEC 64
688db9d7d36SMaxime Chevallier
689db9d7d36SMaxime Chevallier /* The two bytes Marvell header. Either contains a special value used
690db9d7d36SMaxime Chevallier * by Marvell switches when a specific hardware mode is enabled (not
691db9d7d36SMaxime Chevallier * supported by this driver) or is filled automatically by zeroes on
692db9d7d36SMaxime Chevallier * the RX side. Those two bytes being at the front of the Ethernet
693db9d7d36SMaxime Chevallier * header, they allow to have the IP header aligned on a 4 bytes
694db9d7d36SMaxime Chevallier * boundary automatically: the hardware skips those two bytes on its
695db9d7d36SMaxime Chevallier * own.
696db9d7d36SMaxime Chevallier */
697db9d7d36SMaxime Chevallier #define MVPP2_MH_SIZE 2
698db9d7d36SMaxime Chevallier #define MVPP2_ETH_TYPE_LEN 2
699db9d7d36SMaxime Chevallier #define MVPP2_PPPOE_HDR_SIZE 8
700db9d7d36SMaxime Chevallier #define MVPP2_VLAN_TAG_LEN 4
701db9d7d36SMaxime Chevallier #define MVPP2_VLAN_TAG_EDSA_LEN 8
702db9d7d36SMaxime Chevallier
703db9d7d36SMaxime Chevallier /* Lbtd 802.3 type */
704db9d7d36SMaxime Chevallier #define MVPP2_IP_LBDT_TYPE 0xfffa
705db9d7d36SMaxime Chevallier
706db9d7d36SMaxime Chevallier #define MVPP2_TX_CSUM_MAX_SIZE 9800
707db9d7d36SMaxime Chevallier
708db9d7d36SMaxime Chevallier /* Timeout constants */
709db9d7d36SMaxime Chevallier #define MVPP2_TX_DISABLE_TIMEOUT_MSEC 1000
710db9d7d36SMaxime Chevallier #define MVPP2_TX_PENDING_TIMEOUT_MSEC 1000
711db9d7d36SMaxime Chevallier
712db9d7d36SMaxime Chevallier #define MVPP2_TX_MTU_MAX 0x7ffff
713db9d7d36SMaxime Chevallier
714db9d7d36SMaxime Chevallier /* Maximum number of T-CONTs of PON port */
715db9d7d36SMaxime Chevallier #define MVPP2_MAX_TCONT 16
716db9d7d36SMaxime Chevallier
717db9d7d36SMaxime Chevallier /* Maximum number of supported ports */
718db9d7d36SMaxime Chevallier #define MVPP2_MAX_PORTS 4
719db9d7d36SMaxime Chevallier
7209a71baf7SStefan Chulski /* Loopback port index */
7219a71baf7SStefan Chulski #define MVPP2_LOOPBACK_PORT_INDEX 3
7229a71baf7SStefan Chulski
723db9d7d36SMaxime Chevallier /* Maximum number of TXQs used by single port */
724db9d7d36SMaxime Chevallier #define MVPP2_MAX_TXQ 8
725db9d7d36SMaxime Chevallier
726db9d7d36SMaxime Chevallier /* MVPP2_MAX_TSO_SEGS is the maximum number of fragments to allow in the GSO
727db9d7d36SMaxime Chevallier * skb. As we need a maxium of two descriptors per fragments (1 header, 1 data),
728db9d7d36SMaxime Chevallier * multiply this value by two to count the maximum number of skb descs needed.
729db9d7d36SMaxime Chevallier */
730db9d7d36SMaxime Chevallier #define MVPP2_MAX_TSO_SEGS 300
731db9d7d36SMaxime Chevallier #define MVPP2_MAX_SKB_DESCS (MVPP2_MAX_TSO_SEGS * 2 + MAX_SKB_FRAGS)
732db9d7d36SMaxime Chevallier
7333f136849SAntoine Tenart /* Max number of RXQs per port */
7343f136849SAntoine Tenart #define MVPP2_PORT_MAX_RXQ 32
735db9d7d36SMaxime Chevallier
736db9d7d36SMaxime Chevallier /* Max number of Rx descriptors */
737d07ea73fSStefan Chulski #define MVPP2_MAX_RXD_MAX 2048
738d07ea73fSStefan Chulski #define MVPP2_MAX_RXD_DFLT 1024
739db9d7d36SMaxime Chevallier
740db9d7d36SMaxime Chevallier /* Max number of Tx descriptors */
741db9d7d36SMaxime Chevallier #define MVPP2_MAX_TXD_MAX 2048
742db9d7d36SMaxime Chevallier #define MVPP2_MAX_TXD_DFLT 1024
743db9d7d36SMaxime Chevallier
744db9d7d36SMaxime Chevallier /* Amount of Tx descriptors that can be reserved at once by CPU */
745db9d7d36SMaxime Chevallier #define MVPP2_CPU_DESC_CHUNK 64
746db9d7d36SMaxime Chevallier
747db9d7d36SMaxime Chevallier /* Max number of Tx descriptors in each aggregated queue */
748db9d7d36SMaxime Chevallier #define MVPP2_AGGR_TXQ_SIZE 256
749db9d7d36SMaxime Chevallier
750db9d7d36SMaxime Chevallier /* Descriptor aligned size */
751db9d7d36SMaxime Chevallier #define MVPP2_DESC_ALIGNED_SIZE 32
752db9d7d36SMaxime Chevallier
753db9d7d36SMaxime Chevallier /* Descriptor alignment mask */
754db9d7d36SMaxime Chevallier #define MVPP2_TX_DESC_ALIGN (MVPP2_DESC_ALIGNED_SIZE - 1)
755db9d7d36SMaxime Chevallier
756db9d7d36SMaxime Chevallier /* RX FIFO constants */
7579a71baf7SStefan Chulski #define MVPP2_RX_FIFO_PORT_DATA_SIZE_44KB 0xb000
758db9d7d36SMaxime Chevallier #define MVPP2_RX_FIFO_PORT_DATA_SIZE_32KB 0x8000
759db9d7d36SMaxime Chevallier #define MVPP2_RX_FIFO_PORT_DATA_SIZE_8KB 0x2000
760db9d7d36SMaxime Chevallier #define MVPP2_RX_FIFO_PORT_DATA_SIZE_4KB 0x1000
7619a71baf7SStefan Chulski #define MVPP2_RX_FIFO_PORT_ATTR_SIZE(data_size) ((data_size) >> 6)
762db9d7d36SMaxime Chevallier #define MVPP2_RX_FIFO_PORT_ATTR_SIZE_4KB 0x40
763db9d7d36SMaxime Chevallier #define MVPP2_RX_FIFO_PORT_MIN_PKT 0x80
764db9d7d36SMaxime Chevallier
765db9d7d36SMaxime Chevallier /* TX FIFO constants */
7667c294515SStefan Chulski #define MVPP22_TX_FIFO_DATA_SIZE_18KB 18
7679a71baf7SStefan Chulski #define MVPP22_TX_FIFO_DATA_SIZE_10KB 10
7687c294515SStefan Chulski #define MVPP22_TX_FIFO_DATA_SIZE_1KB 1
7699a71baf7SStefan Chulski #define MVPP2_TX_FIFO_THRESHOLD_MIN 256 /* Bytes */
7709a71baf7SStefan Chulski #define MVPP2_TX_FIFO_THRESHOLD(kb) \
7719a71baf7SStefan Chulski ((kb) * 1024 - MVPP2_TX_FIFO_THRESHOLD_MIN)
772db9d7d36SMaxime Chevallier
773aca0e235SStefan Chulski /* RX FIFO threshold in 1KB granularity */
774aca0e235SStefan Chulski #define MVPP23_PORT0_FIFO_TRSH (9 * 1024)
775aca0e235SStefan Chulski #define MVPP23_PORT1_FIFO_TRSH (4 * 1024)
776aca0e235SStefan Chulski #define MVPP23_PORT2_FIFO_TRSH (2 * 1024)
777aca0e235SStefan Chulski
778aca0e235SStefan Chulski /* RX Flow Control Registers */
779aca0e235SStefan Chulski #define MVPP2_RX_FC_REG(port) (0x150 + 4 * (port))
780aca0e235SStefan Chulski #define MVPP2_RX_FC_EN BIT(24)
781aca0e235SStefan Chulski #define MVPP2_RX_FC_TRSH_OFFS 16
782aca0e235SStefan Chulski #define MVPP2_RX_FC_TRSH_MASK (0xFF << MVPP2_RX_FC_TRSH_OFFS)
783aca0e235SStefan Chulski #define MVPP2_RX_FC_TRSH_UNIT 256
784aca0e235SStefan Chulski
7852788d841SStefan Chulski /* MSS Flow control */
786a59d3542SStefan Chulski #define MSS_FC_COM_REG 0
787a59d3542SStefan Chulski #define FLOW_CONTROL_ENABLE_BIT BIT(0)
7883bd17fdcSStefan Chulski #define FLOW_CONTROL_UPDATE_COMMAND_BIT BIT(31)
7892788d841SStefan Chulski #define FC_QUANTA 0xFFFF
7902788d841SStefan Chulski #define FC_CLK_DIVIDER 100
7913bd17fdcSStefan Chulski
7923bd17fdcSStefan Chulski #define MSS_RXQ_TRESH_BASE 0x200
7933bd17fdcSStefan Chulski #define MSS_RXQ_TRESH_OFFS 4
7943bd17fdcSStefan Chulski #define MSS_RXQ_TRESH_REG(q, fq) (MSS_RXQ_TRESH_BASE + (((q) + (fq)) \
7953bd17fdcSStefan Chulski * MSS_RXQ_TRESH_OFFS))
7963bd17fdcSStefan Chulski
79776055831SStefan Chulski #define MSS_BUF_POOL_BASE 0x40
79876055831SStefan Chulski #define MSS_BUF_POOL_OFFS 4
79976055831SStefan Chulski #define MSS_BUF_POOL_REG(id) (MSS_BUF_POOL_BASE \
80076055831SStefan Chulski + (id) * MSS_BUF_POOL_OFFS)
80176055831SStefan Chulski
80276055831SStefan Chulski #define MSS_BUF_POOL_STOP_MASK 0xFFF
80376055831SStefan Chulski #define MSS_BUF_POOL_START_MASK (0xFFF << MSS_BUF_POOL_START_OFFS)
80476055831SStefan Chulski #define MSS_BUF_POOL_START_OFFS 12
80576055831SStefan Chulski #define MSS_BUF_POOL_PORTS_MASK (0xF << MSS_BUF_POOL_PORTS_OFFS)
80676055831SStefan Chulski #define MSS_BUF_POOL_PORTS_OFFS 24
80776055831SStefan Chulski #define MSS_BUF_POOL_PORT_OFFS(id) (0x1 << \
80876055831SStefan Chulski ((id) + MSS_BUF_POOL_PORTS_OFFS))
80976055831SStefan Chulski
8103bd17fdcSStefan Chulski #define MSS_RXQ_TRESH_START_MASK 0xFFFF
8113bd17fdcSStefan Chulski #define MSS_RXQ_TRESH_STOP_MASK (0xFFFF << MSS_RXQ_TRESH_STOP_OFFS)
8123bd17fdcSStefan Chulski #define MSS_RXQ_TRESH_STOP_OFFS 16
8133bd17fdcSStefan Chulski
8143bd17fdcSStefan Chulski #define MSS_RXQ_ASS_BASE 0x80
8153bd17fdcSStefan Chulski #define MSS_RXQ_ASS_OFFS 4
8163bd17fdcSStefan Chulski #define MSS_RXQ_ASS_PER_REG 4
8173bd17fdcSStefan Chulski #define MSS_RXQ_ASS_PER_OFFS 8
8183bd17fdcSStefan Chulski #define MSS_RXQ_ASS_PORTID_OFFS 0
8193bd17fdcSStefan Chulski #define MSS_RXQ_ASS_PORTID_MASK 0x3
8203bd17fdcSStefan Chulski #define MSS_RXQ_ASS_HOSTID_OFFS 2
8213bd17fdcSStefan Chulski #define MSS_RXQ_ASS_HOSTID_MASK 0x3F
8223bd17fdcSStefan Chulski
8233bd17fdcSStefan Chulski #define MSS_RXQ_ASS_Q_BASE(q, fq) ((((q) + (fq)) % MSS_RXQ_ASS_PER_REG) \
8243bd17fdcSStefan Chulski * MSS_RXQ_ASS_PER_OFFS)
8253bd17fdcSStefan Chulski #define MSS_RXQ_ASS_PQ_BASE(q, fq) ((((q) + (fq)) / MSS_RXQ_ASS_PER_REG) \
8263bd17fdcSStefan Chulski * MSS_RXQ_ASS_OFFS)
8273bd17fdcSStefan Chulski #define MSS_RXQ_ASS_REG(q, fq) (MSS_RXQ_ASS_BASE + MSS_RXQ_ASS_PQ_BASE(q, fq))
8283bd17fdcSStefan Chulski
829bf270fa3SStefan Chulski #define MSS_THRESHOLD_STOP 768
8303bd17fdcSStefan Chulski #define MSS_THRESHOLD_START 1024
8319ca5e767SStefan Chulski #define MSS_FC_MAX_TIMEOUT 5000
8322788d841SStefan Chulski
833db9d7d36SMaxime Chevallier /* RX buffer constants */
834db9d7d36SMaxime Chevallier #define MVPP2_SKB_SHINFO_SIZE \
835db9d7d36SMaxime Chevallier SKB_DATA_ALIGN(sizeof(struct skb_shared_info))
836db9d7d36SMaxime Chevallier
837db9d7d36SMaxime Chevallier #define MVPP2_RX_PKT_SIZE(mtu) \
838db9d7d36SMaxime Chevallier ALIGN((mtu) + MVPP2_MH_SIZE + MVPP2_VLAN_TAG_LEN + \
839db9d7d36SMaxime Chevallier ETH_HLEN + ETH_FCS_LEN, cache_line_size())
840db9d7d36SMaxime Chevallier
84107dd0a7aSMatteo Croce #define MVPP2_RX_BUF_SIZE(pkt_size) ((pkt_size) + MVPP2_SKB_HEADROOM)
842db9d7d36SMaxime Chevallier #define MVPP2_RX_TOTAL_SIZE(buf_size) ((buf_size) + MVPP2_SKB_SHINFO_SIZE)
843db9d7d36SMaxime Chevallier #define MVPP2_RX_MAX_PKT_SIZE(total_size) \
84407dd0a7aSMatteo Croce ((total_size) - MVPP2_SKB_HEADROOM - MVPP2_SKB_SHINFO_SIZE)
84507dd0a7aSMatteo Croce
84607dd0a7aSMatteo Croce #define MVPP2_MAX_RX_BUF_SIZE (PAGE_SIZE - MVPP2_SKB_SHINFO_SIZE - MVPP2_SKB_HEADROOM)
847db9d7d36SMaxime Chevallier
848db9d7d36SMaxime Chevallier #define MVPP2_BIT_TO_BYTE(bit) ((bit) / 8)
849bd43d1baSMaxime Chevallier #define MVPP2_BIT_TO_WORD(bit) ((bit) / 32)
850bd43d1baSMaxime Chevallier #define MVPP2_BIT_IN_WORD(bit) ((bit) % 32)
851db9d7d36SMaxime Chevallier
85293c2589cSMaxime Chevallier #define MVPP2_N_PRS_FLOWS 52
85390b509b3SMaxime Chevallier #define MVPP2_N_RFS_ENTRIES_PER_FLOW 4
85490b509b3SMaxime Chevallier
85590b509b3SMaxime Chevallier /* There are 7 supported high-level flows */
85690b509b3SMaxime Chevallier #define MVPP2_N_RFS_RULES (MVPP2_N_RFS_ENTRIES_PER_FLOW * 7)
85793c2589cSMaxime Chevallier
8580ad2f539SMaxime Chevallier /* RSS constants */
859895586d5SMaxime Chevallier #define MVPP22_N_RSS_TABLES 8
8600ad2f539SMaxime Chevallier #define MVPP22_RSS_TABLE_ENTRIES 32
8610ad2f539SMaxime Chevallier
862db9d7d36SMaxime Chevallier /* IPv6 max L3 address size */
863db9d7d36SMaxime Chevallier #define MVPP2_MAX_L3_ADDR_SIZE 16
864db9d7d36SMaxime Chevallier
865db9d7d36SMaxime Chevallier /* Port flags */
866db9d7d36SMaxime Chevallier #define MVPP2_F_LOOPBACK BIT(0)
867a9aac385SAntoine Tenart #define MVPP2_F_DT_COMPAT BIT(1)
868db9d7d36SMaxime Chevallier
869db9d7d36SMaxime Chevallier /* Marvell tag types */
870db9d7d36SMaxime Chevallier enum mvpp2_tag_type {
871db9d7d36SMaxime Chevallier MVPP2_TAG_TYPE_NONE = 0,
872db9d7d36SMaxime Chevallier MVPP2_TAG_TYPE_MH = 1,
873db9d7d36SMaxime Chevallier MVPP2_TAG_TYPE_DSA = 2,
874db9d7d36SMaxime Chevallier MVPP2_TAG_TYPE_EDSA = 3,
875db9d7d36SMaxime Chevallier MVPP2_TAG_TYPE_VLAN = 4,
876db9d7d36SMaxime Chevallier MVPP2_TAG_TYPE_LAST = 5
877db9d7d36SMaxime Chevallier };
878db9d7d36SMaxime Chevallier
879db9d7d36SMaxime Chevallier /* L2 cast enum */
880db9d7d36SMaxime Chevallier enum mvpp2_prs_l2_cast {
881db9d7d36SMaxime Chevallier MVPP2_PRS_L2_UNI_CAST,
882db9d7d36SMaxime Chevallier MVPP2_PRS_L2_MULTI_CAST,
883db9d7d36SMaxime Chevallier };
884db9d7d36SMaxime Chevallier
885db9d7d36SMaxime Chevallier /* L3 cast enum */
886db9d7d36SMaxime Chevallier enum mvpp2_prs_l3_cast {
887db9d7d36SMaxime Chevallier MVPP2_PRS_L3_UNI_CAST,
888db9d7d36SMaxime Chevallier MVPP2_PRS_L3_MULTI_CAST,
889db9d7d36SMaxime Chevallier MVPP2_PRS_L3_BROAD_CAST
890db9d7d36SMaxime Chevallier };
891db9d7d36SMaxime Chevallier
892f5015a59SRussell King /* PTP descriptor constants. The low bits of the descriptor are stored
893f5015a59SRussell King * separately from the high bits.
894f5015a59SRussell King */
895f5015a59SRussell King #define MVPP22_PTP_DESC_MASK_LOW 0xfff
896f5015a59SRussell King
897f5015a59SRussell King /* PTPAction */
898f5015a59SRussell King enum mvpp22_ptp_action {
899f5015a59SRussell King MVPP22_PTP_ACTION_NONE = 0,
900f5015a59SRussell King MVPP22_PTP_ACTION_FORWARD = 1,
901f5015a59SRussell King MVPP22_PTP_ACTION_CAPTURE = 3,
902f5015a59SRussell King /* The following have not been verified */
903f5015a59SRussell King MVPP22_PTP_ACTION_ADDTIME = 4,
904f5015a59SRussell King MVPP22_PTP_ACTION_ADDCORRECTEDTIME = 5,
905f5015a59SRussell King MVPP22_PTP_ACTION_CAPTUREADDTIME = 6,
906f5015a59SRussell King MVPP22_PTP_ACTION_CAPTUREADDCORRECTEDTIME = 7,
907f5015a59SRussell King MVPP22_PTP_ACTION_ADDINGRESSTIME = 8,
908f5015a59SRussell King MVPP22_PTP_ACTION_CAPTUREADDINGRESSTIME = 9,
909f5015a59SRussell King MVPP22_PTP_ACTION_CAPTUREINGRESSTIME = 10,
910f5015a59SRussell King };
911f5015a59SRussell King
912f5015a59SRussell King /* PTPPacketFormat */
913f5015a59SRussell King enum mvpp22_ptp_packet_format {
914f5015a59SRussell King MVPP22_PTP_PKT_FMT_PTPV2 = 0,
915f5015a59SRussell King MVPP22_PTP_PKT_FMT_PTPV1 = 1,
916f5015a59SRussell King MVPP22_PTP_PKT_FMT_Y1731 = 2,
917f5015a59SRussell King MVPP22_PTP_PKT_FMT_NTPTS = 3,
918f5015a59SRussell King MVPP22_PTP_PKT_FMT_NTPRX = 4,
919f5015a59SRussell King MVPP22_PTP_PKT_FMT_NTPTX = 5,
920f5015a59SRussell King MVPP22_PTP_PKT_FMT_TWAMP = 6,
921f5015a59SRussell King };
922f5015a59SRussell King
923f5015a59SRussell King #define MVPP22_PTP_ACTION(x) (((x) & 15) << 0)
924f5015a59SRussell King #define MVPP22_PTP_PACKETFORMAT(x) (((x) & 7) << 4)
925f5015a59SRussell King #define MVPP22_PTP_MACTIMESTAMPINGEN BIT(11)
926f5015a59SRussell King #define MVPP22_PTP_TIMESTAMPENTRYID(x) (((x) & 31) << 12)
927f5015a59SRussell King #define MVPP22_PTP_TIMESTAMPQUEUESELECT BIT(18)
928f5015a59SRussell King
929db9d7d36SMaxime Chevallier /* BM constants */
930d07ea73fSStefan Chulski #define MVPP2_BM_JUMBO_BUF_NUM 2048
931d07ea73fSStefan Chulski #define MVPP2_BM_LONG_BUF_NUM 2048
932db9d7d36SMaxime Chevallier #define MVPP2_BM_SHORT_BUF_NUM 2048
933db9d7d36SMaxime Chevallier #define MVPP2_BM_POOL_SIZE_MAX (16*1024 - MVPP2_BM_POOL_PTR_ALIGN/4)
934db9d7d36SMaxime Chevallier #define MVPP2_BM_POOL_PTR_ALIGN 128
9357d04b0b1SMatteo Croce #define MVPP2_BM_MAX_POOLS 8
936db9d7d36SMaxime Chevallier
937db9d7d36SMaxime Chevallier /* BM cookie (32 bits) definition */
938db9d7d36SMaxime Chevallier #define MVPP2_BM_COOKIE_POOL_OFFS 8
939db9d7d36SMaxime Chevallier #define MVPP2_BM_COOKIE_CPU_OFFS 24
940db9d7d36SMaxime Chevallier
941704e624fSJohn Hubbard #define MVPP2_BM_SHORT_FRAME_SIZE 736 /* frame size 128 */
94207dd0a7aSMatteo Croce #define MVPP2_BM_LONG_FRAME_SIZE 2240 /* frame size 1664 */
94307dd0a7aSMatteo Croce #define MVPP2_BM_JUMBO_FRAME_SIZE 10432 /* frame size 9856 */
944db9d7d36SMaxime Chevallier /* BM short pool packet size
945db9d7d36SMaxime Chevallier * These value assure that for SWF the total number
946db9d7d36SMaxime Chevallier * of bytes allocated for each buffer will be 512
947db9d7d36SMaxime Chevallier */
948db9d7d36SMaxime Chevallier #define MVPP2_BM_SHORT_PKT_SIZE MVPP2_RX_MAX_PKT_SIZE(MVPP2_BM_SHORT_FRAME_SIZE)
949db9d7d36SMaxime Chevallier #define MVPP2_BM_LONG_PKT_SIZE MVPP2_RX_MAX_PKT_SIZE(MVPP2_BM_LONG_FRAME_SIZE)
950db9d7d36SMaxime Chevallier #define MVPP2_BM_JUMBO_PKT_SIZE MVPP2_RX_MAX_PKT_SIZE(MVPP2_BM_JUMBO_FRAME_SIZE)
951db9d7d36SMaxime Chevallier
952db9d7d36SMaxime Chevallier #define MVPP21_ADDR_SPACE_SZ 0
953db9d7d36SMaxime Chevallier #define MVPP22_ADDR_SPACE_SZ SZ_64K
954db9d7d36SMaxime Chevallier
955cf55ace4SAntoine Tenart #define MVPP2_MAX_THREADS 9
956db9d7d36SMaxime Chevallier #define MVPP2_MAX_QVECS MVPP2_MAX_THREADS
957db9d7d36SMaxime Chevallier
958db9d7d36SMaxime Chevallier /* GMAC MIB Counters register definitions */
959db9d7d36SMaxime Chevallier #define MVPP21_MIB_COUNTERS_OFFSET 0x1000
960db9d7d36SMaxime Chevallier #define MVPP21_MIB_COUNTERS_PORT_SZ 0x400
961db9d7d36SMaxime Chevallier #define MVPP22_MIB_COUNTERS_OFFSET 0x0
962db9d7d36SMaxime Chevallier #define MVPP22_MIB_COUNTERS_PORT_SZ 0x100
963db9d7d36SMaxime Chevallier
964db9d7d36SMaxime Chevallier #define MVPP2_MIB_GOOD_OCTETS_RCVD 0x0
965db9d7d36SMaxime Chevallier #define MVPP2_MIB_BAD_OCTETS_RCVD 0x8
966db9d7d36SMaxime Chevallier #define MVPP2_MIB_CRC_ERRORS_SENT 0xc
967db9d7d36SMaxime Chevallier #define MVPP2_MIB_UNICAST_FRAMES_RCVD 0x10
968db9d7d36SMaxime Chevallier #define MVPP2_MIB_BROADCAST_FRAMES_RCVD 0x18
969db9d7d36SMaxime Chevallier #define MVPP2_MIB_MULTICAST_FRAMES_RCVD 0x1c
970db9d7d36SMaxime Chevallier #define MVPP2_MIB_FRAMES_64_OCTETS 0x20
971db9d7d36SMaxime Chevallier #define MVPP2_MIB_FRAMES_65_TO_127_OCTETS 0x24
972db9d7d36SMaxime Chevallier #define MVPP2_MIB_FRAMES_128_TO_255_OCTETS 0x28
973db9d7d36SMaxime Chevallier #define MVPP2_MIB_FRAMES_256_TO_511_OCTETS 0x2c
974db9d7d36SMaxime Chevallier #define MVPP2_MIB_FRAMES_512_TO_1023_OCTETS 0x30
975db9d7d36SMaxime Chevallier #define MVPP2_MIB_FRAMES_1024_TO_MAX_OCTETS 0x34
976db9d7d36SMaxime Chevallier #define MVPP2_MIB_GOOD_OCTETS_SENT 0x38
977db9d7d36SMaxime Chevallier #define MVPP2_MIB_UNICAST_FRAMES_SENT 0x40
978db9d7d36SMaxime Chevallier #define MVPP2_MIB_MULTICAST_FRAMES_SENT 0x48
979db9d7d36SMaxime Chevallier #define MVPP2_MIB_BROADCAST_FRAMES_SENT 0x4c
980db9d7d36SMaxime Chevallier #define MVPP2_MIB_FC_SENT 0x54
981db9d7d36SMaxime Chevallier #define MVPP2_MIB_FC_RCVD 0x58
982db9d7d36SMaxime Chevallier #define MVPP2_MIB_RX_FIFO_OVERRUN 0x5c
983db9d7d36SMaxime Chevallier #define MVPP2_MIB_UNDERSIZE_RCVD 0x60
984db9d7d36SMaxime Chevallier #define MVPP2_MIB_FRAGMENTS_RCVD 0x64
985db9d7d36SMaxime Chevallier #define MVPP2_MIB_OVERSIZE_RCVD 0x68
986db9d7d36SMaxime Chevallier #define MVPP2_MIB_JABBER_RCVD 0x6c
987db9d7d36SMaxime Chevallier #define MVPP2_MIB_MAC_RCV_ERROR 0x70
988db9d7d36SMaxime Chevallier #define MVPP2_MIB_BAD_CRC_EVENT 0x74
989db9d7d36SMaxime Chevallier #define MVPP2_MIB_COLLISION 0x78
990db9d7d36SMaxime Chevallier #define MVPP2_MIB_LATE_COLLISION 0x7c
991db9d7d36SMaxime Chevallier
992db9d7d36SMaxime Chevallier #define MVPP2_MIB_COUNTERS_STATS_DELAY (1 * HZ)
993db9d7d36SMaxime Chevallier
994db9d7d36SMaxime Chevallier #define MVPP2_DESC_DMA_MASK DMA_BIT_MASK(40)
995db9d7d36SMaxime Chevallier
99617f9c1b6SStefan Chulski /* Buffer header info bits */
99717f9c1b6SStefan Chulski #define MVPP2_B_HDR_INFO_MC_ID_MASK 0xfff
99817f9c1b6SStefan Chulski #define MVPP2_B_HDR_INFO_MC_ID(info) ((info) & MVPP2_B_HDR_INFO_MC_ID_MASK)
99917f9c1b6SStefan Chulski #define MVPP2_B_HDR_INFO_LAST_OFFS 12
100017f9c1b6SStefan Chulski #define MVPP2_B_HDR_INFO_LAST_MASK BIT(12)
100117f9c1b6SStefan Chulski #define MVPP2_B_HDR_INFO_IS_LAST(info) \
100217f9c1b6SStefan Chulski (((info) & MVPP2_B_HDR_INFO_LAST_MASK) >> MVPP2_B_HDR_INFO_LAST_OFFS)
100317f9c1b6SStefan Chulski
100491dd7195SRussell King struct mvpp2_tai;
100591dd7195SRussell King
1006db9d7d36SMaxime Chevallier /* Definitions */
10077cb5e368SMaxime Chevallier struct mvpp2_dbgfs_entries;
1008db9d7d36SMaxime Chevallier
1009895586d5SMaxime Chevallier struct mvpp2_rss_table {
1010895586d5SMaxime Chevallier u32 indir[MVPP22_RSS_TABLE_ENTRIES];
1011895586d5SMaxime Chevallier };
1012895586d5SMaxime Chevallier
101317f9c1b6SStefan Chulski struct mvpp2_buff_hdr {
101417f9c1b6SStefan Chulski __le32 next_phys_addr;
101517f9c1b6SStefan Chulski __le32 next_dma_addr;
101617f9c1b6SStefan Chulski __le16 byte_count;
101717f9c1b6SStefan Chulski __le16 info;
101817f9c1b6SStefan Chulski __le16 reserved1; /* bm_qset (for future use, BM) */
101917f9c1b6SStefan Chulski u8 next_phys_addr_high;
102017f9c1b6SStefan Chulski u8 next_dma_addr_high;
102117f9c1b6SStefan Chulski __le16 reserved2;
102217f9c1b6SStefan Chulski __le16 reserved3;
102317f9c1b6SStefan Chulski __le16 reserved4;
102417f9c1b6SStefan Chulski __le16 reserved5;
102517f9c1b6SStefan Chulski };
102617f9c1b6SStefan Chulski
1027db9d7d36SMaxime Chevallier /* Shared Packet Processor resources */
1028db9d7d36SMaxime Chevallier struct mvpp2 {
1029db9d7d36SMaxime Chevallier /* Shared registers' base addresses */
1030db9d7d36SMaxime Chevallier void __iomem *lms_base;
1031db9d7d36SMaxime Chevallier void __iomem *iface_base;
1032e54ad1e0SStefan Chulski void __iomem *cm3_base;
1033db9d7d36SMaxime Chevallier
10346af27a1dSStefan Chulski /* On PPv2.2 and PPv2.3, each "software thread" can access the base
1035db9d7d36SMaxime Chevallier * register through a separate address space, each 64 KB apart
1036db9d7d36SMaxime Chevallier * from each other. Typically, such address spaces will be
1037db9d7d36SMaxime Chevallier * used per CPU.
1038db9d7d36SMaxime Chevallier */
1039db9d7d36SMaxime Chevallier void __iomem *swth_base[MVPP2_MAX_THREADS];
1040db9d7d36SMaxime Chevallier
10416af27a1dSStefan Chulski /* On PPv2.2 and PPv2.3, some port control registers are located into
10426af27a1dSStefan Chulski * the system controller space. These registers are accessible
10436af27a1dSStefan Chulski * through a regmap.
1044db9d7d36SMaxime Chevallier */
1045db9d7d36SMaxime Chevallier struct regmap *sysctrl_base;
1046db9d7d36SMaxime Chevallier
1047db9d7d36SMaxime Chevallier /* Common clocks */
1048db9d7d36SMaxime Chevallier struct clk *pp_clk;
1049db9d7d36SMaxime Chevallier struct clk *gop_clk;
1050db9d7d36SMaxime Chevallier struct clk *mg_clk;
1051db9d7d36SMaxime Chevallier struct clk *mg_core_clk;
1052db9d7d36SMaxime Chevallier struct clk *axi_clk;
1053db9d7d36SMaxime Chevallier
1054db9d7d36SMaxime Chevallier /* List of pointers to port structures */
1055db9d7d36SMaxime Chevallier int port_count;
1056db9d7d36SMaxime Chevallier struct mvpp2_port *port_list[MVPP2_MAX_PORTS];
10579a71baf7SStefan Chulski /* Map of enabled ports */
10589a71baf7SStefan Chulski unsigned long port_map;
10599a71baf7SStefan Chulski
106091dd7195SRussell King struct mvpp2_tai *tai;
1061db9d7d36SMaxime Chevallier
1062e531f767SAntoine Tenart /* Number of Tx threads used */
1063e531f767SAntoine Tenart unsigned int nthreads;
1064e531f767SAntoine Tenart /* Map of threads needing locking */
1065e531f767SAntoine Tenart unsigned long lock_map;
1066e531f767SAntoine Tenart
1067db9d7d36SMaxime Chevallier /* Aggregated TXQs */
1068db9d7d36SMaxime Chevallier struct mvpp2_tx_queue *aggr_txqs;
1069db9d7d36SMaxime Chevallier
10707d04b0b1SMatteo Croce /* Are we using page_pool with per-cpu pools? */
10717d04b0b1SMatteo Croce int percpu_pools;
10727d04b0b1SMatteo Croce
1073db9d7d36SMaxime Chevallier /* BM pools */
1074db9d7d36SMaxime Chevallier struct mvpp2_bm_pool *bm_pools;
1075db9d7d36SMaxime Chevallier
1076db9d7d36SMaxime Chevallier /* PRS shadow table */
1077db9d7d36SMaxime Chevallier struct mvpp2_prs_shadow *prs_shadow;
1078db9d7d36SMaxime Chevallier /* PRS auxiliary table for double vlan entries control */
1079db9d7d36SMaxime Chevallier bool *prs_double_vlans;
1080db9d7d36SMaxime Chevallier
1081db9d7d36SMaxime Chevallier /* Tclk value */
1082db9d7d36SMaxime Chevallier u32 tclk;
1083db9d7d36SMaxime Chevallier
1084db9d7d36SMaxime Chevallier /* HW version */
10856af27a1dSStefan Chulski enum { MVPP21, MVPP22, MVPP23 } hw_version;
1086db9d7d36SMaxime Chevallier
1087db9d7d36SMaxime Chevallier /* Maximum number of RXQs per port */
1088db9d7d36SMaxime Chevallier unsigned int max_port_rxqs;
1089db9d7d36SMaxime Chevallier
1090db9d7d36SMaxime Chevallier /* Workqueue to gather hardware statistics */
1091*74834f4aSSimon Horman char queue_name[31];
1092db9d7d36SMaxime Chevallier struct workqueue_struct *stats_queue;
109321da57a2SMaxime Chevallier
109421da57a2SMaxime Chevallier /* Debugfs root entry */
109521da57a2SMaxime Chevallier struct dentry *dbgfs_dir;
10967cb5e368SMaxime Chevallier
10977cb5e368SMaxime Chevallier /* Debugfs entries private data */
10987cb5e368SMaxime Chevallier struct mvpp2_dbgfs_entries *dbgfs_entries;
1099895586d5SMaxime Chevallier
1100895586d5SMaxime Chevallier /* RSS Indirection tables */
1101895586d5SMaxime Chevallier struct mvpp2_rss_table *rss_tables[MVPP22_N_RSS_TABLES];
1102b27db227SMatteo Croce
1103b27db227SMatteo Croce /* page_pool allocator */
1104b27db227SMatteo Croce struct page_pool *page_pool[MVPP2_PORT_MAX_RXQ];
1105a59d3542SStefan Chulski
1106a59d3542SStefan Chulski /* Global TX Flow Control config */
1107a59d3542SStefan Chulski bool global_tx_fc;
11083bd17fdcSStefan Chulski
11093bd17fdcSStefan Chulski /* Spinlocks for CM3 shared memory configuration */
11103bd17fdcSStefan Chulski spinlock_t mss_spinlock;
1111db9d7d36SMaxime Chevallier };
1112db9d7d36SMaxime Chevallier
1113db9d7d36SMaxime Chevallier struct mvpp2_pcpu_stats {
1114db9d7d36SMaxime Chevallier struct u64_stats_sync syncp;
1115db9d7d36SMaxime Chevallier u64 rx_packets;
1116db9d7d36SMaxime Chevallier u64 rx_bytes;
1117db9d7d36SMaxime Chevallier u64 tx_packets;
1118db9d7d36SMaxime Chevallier u64 tx_bytes;
111939b96315SSven Auhagen /* XDP */
112039b96315SSven Auhagen u64 xdp_redirect;
112139b96315SSven Auhagen u64 xdp_pass;
112239b96315SSven Auhagen u64 xdp_drop;
112339b96315SSven Auhagen u64 xdp_xmit;
112439b96315SSven Auhagen u64 xdp_xmit_err;
112539b96315SSven Auhagen u64 xdp_tx;
112639b96315SSven Auhagen u64 xdp_tx_err;
1127db9d7d36SMaxime Chevallier };
1128db9d7d36SMaxime Chevallier
1129db9d7d36SMaxime Chevallier /* Per-CPU port control */
1130db9d7d36SMaxime Chevallier struct mvpp2_port_pcpu {
1131db9d7d36SMaxime Chevallier struct hrtimer tx_done_timer;
1132ecb9f80dSThomas Gleixner struct net_device *dev;
1133db9d7d36SMaxime Chevallier bool timer_scheduled;
1134db9d7d36SMaxime Chevallier };
1135db9d7d36SMaxime Chevallier
1136db9d7d36SMaxime Chevallier struct mvpp2_queue_vector {
1137db9d7d36SMaxime Chevallier int irq;
1138db9d7d36SMaxime Chevallier struct napi_struct napi;
1139db9d7d36SMaxime Chevallier enum { MVPP2_QUEUE_VECTOR_SHARED, MVPP2_QUEUE_VECTOR_PRIVATE } type;
1140db9d7d36SMaxime Chevallier int sw_thread_id;
1141db9d7d36SMaxime Chevallier u16 sw_thread_mask;
1142db9d7d36SMaxime Chevallier int first_rxq;
1143db9d7d36SMaxime Chevallier int nrxqs;
1144db9d7d36SMaxime Chevallier u32 pending_cause_rx;
1145db9d7d36SMaxime Chevallier struct mvpp2_port *port;
1146a6b3a3faSMarc Zyngier struct cpumask *mask;
1147db9d7d36SMaxime Chevallier };
1148db9d7d36SMaxime Chevallier
114990b509b3SMaxime Chevallier /* Internal represention of a Flow Steering rule */
115090b509b3SMaxime Chevallier struct mvpp2_rfs_rule {
115190b509b3SMaxime Chevallier /* Rule location inside the flow*/
115290b509b3SMaxime Chevallier int loc;
115390b509b3SMaxime Chevallier
115490b509b3SMaxime Chevallier /* Flow type, such as TCP_V4_FLOW, IP6_FLOW, etc. */
115590b509b3SMaxime Chevallier int flow_type;
115690b509b3SMaxime Chevallier
115790b509b3SMaxime Chevallier /* Index of the C2 TCAM entry handling this rule */
115890b509b3SMaxime Chevallier int c2_index;
115990b509b3SMaxime Chevallier
116090b509b3SMaxime Chevallier /* Header fields that needs to be extracted to match this flow */
116190b509b3SMaxime Chevallier u16 hek_fields;
116290b509b3SMaxime Chevallier
116390b509b3SMaxime Chevallier /* CLS engine : only c2 is supported for now. */
116490b509b3SMaxime Chevallier u8 engine;
116590b509b3SMaxime Chevallier
116690b509b3SMaxime Chevallier /* TCAM key and mask for C2-based steering. These fields should be
116790b509b3SMaxime Chevallier * encapsulated in a union should we add more engines.
116890b509b3SMaxime Chevallier */
116990b509b3SMaxime Chevallier u64 c2_tcam;
117090b509b3SMaxime Chevallier u64 c2_tcam_mask;
117190b509b3SMaxime Chevallier
117290b509b3SMaxime Chevallier struct flow_rule *flow;
117390b509b3SMaxime Chevallier };
117490b509b3SMaxime Chevallier
117590b509b3SMaxime Chevallier struct mvpp2_ethtool_fs {
117690b509b3SMaxime Chevallier struct mvpp2_rfs_rule rule;
117790b509b3SMaxime Chevallier struct ethtool_rxnfc rxnfc;
117890b509b3SMaxime Chevallier };
117990b509b3SMaxime Chevallier
1180f5015a59SRussell King struct mvpp2_hwtstamp_queue {
1181f5015a59SRussell King struct sk_buff *skb[32];
1182f5015a59SRussell King u8 next;
1183f5015a59SRussell King };
1184f5015a59SRussell King
1185db9d7d36SMaxime Chevallier struct mvpp2_port {
1186db9d7d36SMaxime Chevallier u8 id;
1187db9d7d36SMaxime Chevallier
1188db9d7d36SMaxime Chevallier /* Index of the port from the "group of ports" complex point
118931383c03SAntoine Tenart * of view. This is specific to PPv2.2.
1190db9d7d36SMaxime Chevallier */
1191db9d7d36SMaxime Chevallier int gop_id;
1192db9d7d36SMaxime Chevallier
119389141972SRussell King int port_irq;
1194db9d7d36SMaxime Chevallier
1195db9d7d36SMaxime Chevallier struct mvpp2 *priv;
1196db9d7d36SMaxime Chevallier
1197db9d7d36SMaxime Chevallier /* Firmware node associated to the port */
1198db9d7d36SMaxime Chevallier struct fwnode_handle *fwnode;
1199db9d7d36SMaxime Chevallier
1200db9d7d36SMaxime Chevallier /* Per-port registers' base address */
1201db9d7d36SMaxime Chevallier void __iomem *base;
1202db9d7d36SMaxime Chevallier void __iomem *stats_base;
1203db9d7d36SMaxime Chevallier
1204db9d7d36SMaxime Chevallier struct mvpp2_rx_queue **rxqs;
1205db9d7d36SMaxime Chevallier unsigned int nrxqs;
1206db9d7d36SMaxime Chevallier struct mvpp2_tx_queue **txqs;
1207db9d7d36SMaxime Chevallier unsigned int ntxqs;
1208db9d7d36SMaxime Chevallier struct net_device *dev;
1209db9d7d36SMaxime Chevallier
121007dd0a7aSMatteo Croce struct bpf_prog *xdp_prog;
121107dd0a7aSMatteo Croce
1212db9d7d36SMaxime Chevallier int pkt_size;
1213db9d7d36SMaxime Chevallier
1214db9d7d36SMaxime Chevallier /* Per-CPU port control */
1215db9d7d36SMaxime Chevallier struct mvpp2_port_pcpu __percpu *pcpu;
1216db9d7d36SMaxime Chevallier
1217e531f767SAntoine Tenart /* Protect the BM refills and the Tx paths when a thread is used on more
1218e531f767SAntoine Tenart * than a single CPU.
1219e531f767SAntoine Tenart */
1220e531f767SAntoine Tenart spinlock_t bm_lock[MVPP2_MAX_THREADS];
1221e531f767SAntoine Tenart spinlock_t tx_lock[MVPP2_MAX_THREADS];
1222e531f767SAntoine Tenart
1223db9d7d36SMaxime Chevallier /* Flags */
1224db9d7d36SMaxime Chevallier unsigned long flags;
1225db9d7d36SMaxime Chevallier
1226db9d7d36SMaxime Chevallier u16 tx_ring_size;
1227db9d7d36SMaxime Chevallier u16 rx_ring_size;
1228db9d7d36SMaxime Chevallier struct mvpp2_pcpu_stats __percpu *stats;
1229db9d7d36SMaxime Chevallier u64 *ethtool_stats;
1230db9d7d36SMaxime Chevallier
123107dd0a7aSMatteo Croce unsigned long state;
123207dd0a7aSMatteo Croce
1233db9d7d36SMaxime Chevallier /* Per-port work and its lock to gather hardware statistics */
1234db9d7d36SMaxime Chevallier struct mutex gather_stats_lock;
1235db9d7d36SMaxime Chevallier struct delayed_work stats_work;
1236db9d7d36SMaxime Chevallier
1237db9d7d36SMaxime Chevallier struct device_node *of_node;
1238db9d7d36SMaxime Chevallier
1239db9d7d36SMaxime Chevallier phy_interface_t phy_interface;
1240db9d7d36SMaxime Chevallier struct phylink *phylink;
124144cc27e4SIoana Ciornei struct phylink_config phylink_config;
1242cff05632SRussell King (Oracle) struct phylink_pcs pcs_gmac;
1243cff05632SRussell King (Oracle) struct phylink_pcs pcs_xlg;
1244db9d7d36SMaxime Chevallier struct phy *comphy;
1245db9d7d36SMaxime Chevallier
1246db9d7d36SMaxime Chevallier struct mvpp2_bm_pool *pool_long;
1247db9d7d36SMaxime Chevallier struct mvpp2_bm_pool *pool_short;
1248db9d7d36SMaxime Chevallier
1249db9d7d36SMaxime Chevallier /* Index of first port's physical RXQ */
1250db9d7d36SMaxime Chevallier u8 first_rxq;
1251db9d7d36SMaxime Chevallier
1252db9d7d36SMaxime Chevallier struct mvpp2_queue_vector qvecs[MVPP2_MAX_QVECS];
1253db9d7d36SMaxime Chevallier unsigned int nqvecs;
1254db9d7d36SMaxime Chevallier bool has_tx_irqs;
1255db9d7d36SMaxime Chevallier
1256db9d7d36SMaxime Chevallier u32 tx_time_coal;
12578179642bSAntoine Tenart
125890b509b3SMaxime Chevallier /* List of steering rules active on that port */
1259ae8e1d5eSMaxime Chevallier struct mvpp2_ethtool_fs *rfs_rules[MVPP2_N_RFS_ENTRIES_PER_FLOW];
126090b509b3SMaxime Chevallier int n_rfs_rules;
1261895586d5SMaxime Chevallier
1262895586d5SMaxime Chevallier /* Each port has its own view of the rss contexts, so that it can number
1263895586d5SMaxime Chevallier * them from 0
1264895586d5SMaxime Chevallier */
1265895586d5SMaxime Chevallier int rss_ctx[MVPP22_N_RSS_TABLES];
1266ce3497e2SRussell King
1267ce3497e2SRussell King bool hwtstamp;
1268ce3497e2SRussell King bool rx_hwtstamp;
1269f5015a59SRussell King enum hwtstamp_tx_types tx_hwtstamp_type;
1270f5015a59SRussell King struct mvpp2_hwtstamp_queue tx_hwtstamp_queue[2];
12713bd17fdcSStefan Chulski
12723bd17fdcSStefan Chulski /* Firmware TX flow control */
12733bd17fdcSStefan Chulski bool tx_fc;
1274db9d7d36SMaxime Chevallier };
1275db9d7d36SMaxime Chevallier
1276db9d7d36SMaxime Chevallier /* The mvpp2_tx_desc and mvpp2_rx_desc structures describe the
1277db9d7d36SMaxime Chevallier * layout of the transmit and reception DMA descriptors, and their
1278db9d7d36SMaxime Chevallier * layout is therefore defined by the hardware design
1279db9d7d36SMaxime Chevallier */
1280db9d7d36SMaxime Chevallier
1281db9d7d36SMaxime Chevallier #define MVPP2_TXD_L3_OFF_SHIFT 0
1282db9d7d36SMaxime Chevallier #define MVPP2_TXD_IP_HLEN_SHIFT 8
1283db9d7d36SMaxime Chevallier #define MVPP2_TXD_L4_CSUM_FRAG BIT(13)
1284db9d7d36SMaxime Chevallier #define MVPP2_TXD_L4_CSUM_NOT BIT(14)
1285db9d7d36SMaxime Chevallier #define MVPP2_TXD_IP_CSUM_DISABLE BIT(15)
1286db9d7d36SMaxime Chevallier #define MVPP2_TXD_PADDING_DISABLE BIT(23)
1287db9d7d36SMaxime Chevallier #define MVPP2_TXD_L4_UDP BIT(24)
1288db9d7d36SMaxime Chevallier #define MVPP2_TXD_L3_IP6 BIT(26)
1289db9d7d36SMaxime Chevallier #define MVPP2_TXD_L_DESC BIT(28)
1290db9d7d36SMaxime Chevallier #define MVPP2_TXD_F_DESC BIT(29)
1291db9d7d36SMaxime Chevallier
1292db9d7d36SMaxime Chevallier #define MVPP2_RXD_ERR_SUMMARY BIT(15)
1293db9d7d36SMaxime Chevallier #define MVPP2_RXD_ERR_CODE_MASK (BIT(13) | BIT(14))
1294db9d7d36SMaxime Chevallier #define MVPP2_RXD_ERR_CRC 0x0
1295db9d7d36SMaxime Chevallier #define MVPP2_RXD_ERR_OVERRUN BIT(13)
1296db9d7d36SMaxime Chevallier #define MVPP2_RXD_ERR_RESOURCE (BIT(13) | BIT(14))
1297db9d7d36SMaxime Chevallier #define MVPP2_RXD_BM_POOL_ID_OFFS 16
1298db9d7d36SMaxime Chevallier #define MVPP2_RXD_BM_POOL_ID_MASK (BIT(16) | BIT(17) | BIT(18))
1299db9d7d36SMaxime Chevallier #define MVPP2_RXD_HWF_SYNC BIT(21)
1300db9d7d36SMaxime Chevallier #define MVPP2_RXD_L4_CSUM_OK BIT(22)
1301db9d7d36SMaxime Chevallier #define MVPP2_RXD_IP4_HEADER_ERR BIT(24)
1302db9d7d36SMaxime Chevallier #define MVPP2_RXD_L4_TCP BIT(25)
1303db9d7d36SMaxime Chevallier #define MVPP2_RXD_L4_UDP BIT(26)
1304db9d7d36SMaxime Chevallier #define MVPP2_RXD_L3_IP4 BIT(28)
1305db9d7d36SMaxime Chevallier #define MVPP2_RXD_L3_IP6 BIT(30)
1306db9d7d36SMaxime Chevallier #define MVPP2_RXD_BUF_HDR BIT(31)
1307db9d7d36SMaxime Chevallier
1308db9d7d36SMaxime Chevallier /* HW TX descriptor for PPv2.1 */
1309db9d7d36SMaxime Chevallier struct mvpp21_tx_desc {
13107b9c7d7dSMaxime Chevallier __le32 command; /* Options used by HW for packet transmitting.*/
1311db9d7d36SMaxime Chevallier u8 packet_offset; /* the offset from the buffer beginning */
1312db9d7d36SMaxime Chevallier u8 phys_txq; /* destination queue ID */
13137b9c7d7dSMaxime Chevallier __le16 data_size; /* data size of transmitted packet in bytes */
13147b9c7d7dSMaxime Chevallier __le32 buf_dma_addr; /* physical addr of transmitted buffer */
13157b9c7d7dSMaxime Chevallier __le32 buf_cookie; /* cookie for access to TX buffer in tx path */
13167b9c7d7dSMaxime Chevallier __le32 reserved1[3]; /* hw_cmd (for future use, BM, PON, PNC) */
13177b9c7d7dSMaxime Chevallier __le32 reserved2; /* reserved (for future use) */
1318db9d7d36SMaxime Chevallier };
1319db9d7d36SMaxime Chevallier
1320db9d7d36SMaxime Chevallier /* HW RX descriptor for PPv2.1 */
1321db9d7d36SMaxime Chevallier struct mvpp21_rx_desc {
13227b9c7d7dSMaxime Chevallier __le32 status; /* info about received packet */
13237b9c7d7dSMaxime Chevallier __le16 reserved1; /* parser_info (for future use, PnC) */
13247b9c7d7dSMaxime Chevallier __le16 data_size; /* size of received packet in bytes */
13257b9c7d7dSMaxime Chevallier __le32 buf_dma_addr; /* physical address of the buffer */
13267b9c7d7dSMaxime Chevallier __le32 buf_cookie; /* cookie for access to RX buffer in rx path */
13277b9c7d7dSMaxime Chevallier __le16 reserved2; /* gem_port_id (for future use, PON) */
13287b9c7d7dSMaxime Chevallier __le16 reserved3; /* csum_l4 (for future use, PnC) */
1329db9d7d36SMaxime Chevallier u8 reserved4; /* bm_qset (for future use, BM) */
1330db9d7d36SMaxime Chevallier u8 reserved5;
13317b9c7d7dSMaxime Chevallier __le16 reserved6; /* classify_info (for future use, PnC) */
13327b9c7d7dSMaxime Chevallier __le32 reserved7; /* flow_id (for future use, PnC) */
13337b9c7d7dSMaxime Chevallier __le32 reserved8;
1334db9d7d36SMaxime Chevallier };
1335db9d7d36SMaxime Chevallier
13366af27a1dSStefan Chulski /* HW TX descriptor for PPv2.2 and PPv2.3 */
1337db9d7d36SMaxime Chevallier struct mvpp22_tx_desc {
13387b9c7d7dSMaxime Chevallier __le32 command;
1339db9d7d36SMaxime Chevallier u8 packet_offset;
1340db9d7d36SMaxime Chevallier u8 phys_txq;
13417b9c7d7dSMaxime Chevallier __le16 data_size;
1342f5015a59SRussell King __le32 ptp_descriptor;
1343f5015a59SRussell King __le32 reserved2;
13447b9c7d7dSMaxime Chevallier __le64 buf_dma_addr_ptp;
13457b9c7d7dSMaxime Chevallier __le64 buf_cookie_misc;
1346db9d7d36SMaxime Chevallier };
1347db9d7d36SMaxime Chevallier
13486af27a1dSStefan Chulski /* HW RX descriptor for PPv2.2 and PPv2.3 */
1349db9d7d36SMaxime Chevallier struct mvpp22_rx_desc {
13507b9c7d7dSMaxime Chevallier __le32 status;
13517b9c7d7dSMaxime Chevallier __le16 reserved1;
13527b9c7d7dSMaxime Chevallier __le16 data_size;
13537b9c7d7dSMaxime Chevallier __le32 reserved2;
1354ce3497e2SRussell King __le32 timestamp;
13557b9c7d7dSMaxime Chevallier __le64 buf_dma_addr_key_hash;
13567b9c7d7dSMaxime Chevallier __le64 buf_cookie_misc;
1357db9d7d36SMaxime Chevallier };
1358db9d7d36SMaxime Chevallier
1359db9d7d36SMaxime Chevallier /* Opaque type used by the driver to manipulate the HW TX and RX
1360db9d7d36SMaxime Chevallier * descriptors
1361db9d7d36SMaxime Chevallier */
1362db9d7d36SMaxime Chevallier struct mvpp2_tx_desc {
1363db9d7d36SMaxime Chevallier union {
1364db9d7d36SMaxime Chevallier struct mvpp21_tx_desc pp21;
1365db9d7d36SMaxime Chevallier struct mvpp22_tx_desc pp22;
1366db9d7d36SMaxime Chevallier };
1367db9d7d36SMaxime Chevallier };
1368db9d7d36SMaxime Chevallier
1369db9d7d36SMaxime Chevallier struct mvpp2_rx_desc {
1370db9d7d36SMaxime Chevallier union {
1371db9d7d36SMaxime Chevallier struct mvpp21_rx_desc pp21;
1372db9d7d36SMaxime Chevallier struct mvpp22_rx_desc pp22;
1373db9d7d36SMaxime Chevallier };
1374db9d7d36SMaxime Chevallier };
1375db9d7d36SMaxime Chevallier
1376c2d6fe61SMatteo Croce enum mvpp2_tx_buf_type {
1377c2d6fe61SMatteo Croce MVPP2_TYPE_SKB,
1378c2d6fe61SMatteo Croce MVPP2_TYPE_XDP_TX,
1379c2d6fe61SMatteo Croce MVPP2_TYPE_XDP_NDO,
1380c2d6fe61SMatteo Croce };
1381c2d6fe61SMatteo Croce
1382db9d7d36SMaxime Chevallier struct mvpp2_txq_pcpu_buf {
1383c2d6fe61SMatteo Croce enum mvpp2_tx_buf_type type;
1384c2d6fe61SMatteo Croce
1385db9d7d36SMaxime Chevallier /* Transmitted SKB */
1386c2d6fe61SMatteo Croce union {
1387c2d6fe61SMatteo Croce struct xdp_frame *xdpf;
1388db9d7d36SMaxime Chevallier struct sk_buff *skb;
1389c2d6fe61SMatteo Croce };
1390db9d7d36SMaxime Chevallier
1391db9d7d36SMaxime Chevallier /* Physical address of transmitted buffer */
1392db9d7d36SMaxime Chevallier dma_addr_t dma;
1393db9d7d36SMaxime Chevallier
1394db9d7d36SMaxime Chevallier /* Size transmitted */
1395db9d7d36SMaxime Chevallier size_t size;
1396db9d7d36SMaxime Chevallier };
1397db9d7d36SMaxime Chevallier
1398db9d7d36SMaxime Chevallier /* Per-CPU Tx queue control */
1399db9d7d36SMaxime Chevallier struct mvpp2_txq_pcpu {
1400074c74dfSAntoine Tenart unsigned int thread;
1401db9d7d36SMaxime Chevallier
1402db9d7d36SMaxime Chevallier /* Number of Tx DMA descriptors in the descriptor ring */
1403db9d7d36SMaxime Chevallier int size;
1404db9d7d36SMaxime Chevallier
1405db9d7d36SMaxime Chevallier /* Number of currently used Tx DMA descriptor in the
1406db9d7d36SMaxime Chevallier * descriptor ring
1407db9d7d36SMaxime Chevallier */
1408db9d7d36SMaxime Chevallier int count;
1409db9d7d36SMaxime Chevallier
1410db9d7d36SMaxime Chevallier int wake_threshold;
1411db9d7d36SMaxime Chevallier int stop_threshold;
1412db9d7d36SMaxime Chevallier
1413db9d7d36SMaxime Chevallier /* Number of Tx DMA descriptors reserved for each CPU */
1414db9d7d36SMaxime Chevallier int reserved_num;
1415db9d7d36SMaxime Chevallier
1416db9d7d36SMaxime Chevallier /* Infos about transmitted buffers */
1417db9d7d36SMaxime Chevallier struct mvpp2_txq_pcpu_buf *buffs;
1418db9d7d36SMaxime Chevallier
1419db9d7d36SMaxime Chevallier /* Index of last TX DMA descriptor that was inserted */
1420db9d7d36SMaxime Chevallier int txq_put_index;
1421db9d7d36SMaxime Chevallier
1422db9d7d36SMaxime Chevallier /* Index of the TX DMA descriptor to be cleaned up */
1423db9d7d36SMaxime Chevallier int txq_get_index;
1424db9d7d36SMaxime Chevallier
1425db9d7d36SMaxime Chevallier /* DMA buffer for TSO headers */
1426db9d7d36SMaxime Chevallier char *tso_headers;
1427db9d7d36SMaxime Chevallier dma_addr_t tso_headers_dma;
1428db9d7d36SMaxime Chevallier };
1429db9d7d36SMaxime Chevallier
1430db9d7d36SMaxime Chevallier struct mvpp2_tx_queue {
1431db9d7d36SMaxime Chevallier /* Physical number of this Tx queue */
1432db9d7d36SMaxime Chevallier u8 id;
1433db9d7d36SMaxime Chevallier
1434db9d7d36SMaxime Chevallier /* Logical number of this Tx queue */
1435db9d7d36SMaxime Chevallier u8 log_id;
1436db9d7d36SMaxime Chevallier
1437db9d7d36SMaxime Chevallier /* Number of Tx DMA descriptors in the descriptor ring */
1438db9d7d36SMaxime Chevallier int size;
1439db9d7d36SMaxime Chevallier
1440db9d7d36SMaxime Chevallier /* Number of currently used Tx DMA descriptor in the descriptor ring */
1441db9d7d36SMaxime Chevallier int count;
1442db9d7d36SMaxime Chevallier
1443db9d7d36SMaxime Chevallier /* Per-CPU control of physical Tx queues */
1444db9d7d36SMaxime Chevallier struct mvpp2_txq_pcpu __percpu *pcpu;
1445db9d7d36SMaxime Chevallier
1446db9d7d36SMaxime Chevallier u32 done_pkts_coal;
1447db9d7d36SMaxime Chevallier
1448db9d7d36SMaxime Chevallier /* Virtual address of thex Tx DMA descriptors array */
1449db9d7d36SMaxime Chevallier struct mvpp2_tx_desc *descs;
1450db9d7d36SMaxime Chevallier
1451db9d7d36SMaxime Chevallier /* DMA address of the Tx DMA descriptors array */
1452db9d7d36SMaxime Chevallier dma_addr_t descs_dma;
1453db9d7d36SMaxime Chevallier
1454db9d7d36SMaxime Chevallier /* Index of the last Tx DMA descriptor */
1455db9d7d36SMaxime Chevallier int last_desc;
1456db9d7d36SMaxime Chevallier
1457db9d7d36SMaxime Chevallier /* Index of the next Tx DMA descriptor to process */
1458db9d7d36SMaxime Chevallier int next_desc_to_proc;
1459db9d7d36SMaxime Chevallier };
1460db9d7d36SMaxime Chevallier
1461db9d7d36SMaxime Chevallier struct mvpp2_rx_queue {
1462db9d7d36SMaxime Chevallier /* RX queue number, in the range 0-31 for physical RXQs */
1463db9d7d36SMaxime Chevallier u8 id;
1464db9d7d36SMaxime Chevallier
1465db9d7d36SMaxime Chevallier /* Num of rx descriptors in the rx descriptor ring */
1466db9d7d36SMaxime Chevallier int size;
1467db9d7d36SMaxime Chevallier
1468db9d7d36SMaxime Chevallier u32 pkts_coal;
1469db9d7d36SMaxime Chevallier u32 time_coal;
1470db9d7d36SMaxime Chevallier
1471db9d7d36SMaxime Chevallier /* Virtual address of the RX DMA descriptors array */
1472db9d7d36SMaxime Chevallier struct mvpp2_rx_desc *descs;
1473db9d7d36SMaxime Chevallier
1474db9d7d36SMaxime Chevallier /* DMA address of the RX DMA descriptors array */
1475db9d7d36SMaxime Chevallier dma_addr_t descs_dma;
1476db9d7d36SMaxime Chevallier
1477db9d7d36SMaxime Chevallier /* Index of the last RX DMA descriptor */
1478db9d7d36SMaxime Chevallier int last_desc;
1479db9d7d36SMaxime Chevallier
1480db9d7d36SMaxime Chevallier /* Index of the next RX DMA descriptor to process */
1481db9d7d36SMaxime Chevallier int next_desc_to_proc;
1482db9d7d36SMaxime Chevallier
1483db9d7d36SMaxime Chevallier /* ID of port to which physical RXQ is mapped */
1484db9d7d36SMaxime Chevallier int port;
1485db9d7d36SMaxime Chevallier
1486db9d7d36SMaxime Chevallier /* Port's logic RXQ number to which physical RXQ is mapped */
1487db9d7d36SMaxime Chevallier int logic_rxq;
1488b27db227SMatteo Croce
1489b27db227SMatteo Croce /* XDP memory accounting */
1490b27db227SMatteo Croce struct xdp_rxq_info xdp_rxq_short;
1491b27db227SMatteo Croce struct xdp_rxq_info xdp_rxq_long;
1492db9d7d36SMaxime Chevallier };
1493db9d7d36SMaxime Chevallier
1494db9d7d36SMaxime Chevallier struct mvpp2_bm_pool {
1495db9d7d36SMaxime Chevallier /* Pool number in the range 0-7 */
1496db9d7d36SMaxime Chevallier int id;
1497db9d7d36SMaxime Chevallier
1498db9d7d36SMaxime Chevallier /* Buffer Pointers Pool External (BPPE) size */
1499db9d7d36SMaxime Chevallier int size;
1500db9d7d36SMaxime Chevallier /* BPPE size in bytes */
1501db9d7d36SMaxime Chevallier int size_bytes;
1502db9d7d36SMaxime Chevallier /* Number of buffers for this pool */
1503db9d7d36SMaxime Chevallier int buf_num;
1504db9d7d36SMaxime Chevallier /* Pool buffer size */
1505db9d7d36SMaxime Chevallier int buf_size;
1506db9d7d36SMaxime Chevallier /* Packet size */
1507db9d7d36SMaxime Chevallier int pkt_size;
1508db9d7d36SMaxime Chevallier int frag_size;
1509db9d7d36SMaxime Chevallier
1510db9d7d36SMaxime Chevallier /* BPPE virtual base address */
1511db9d7d36SMaxime Chevallier u32 *virt_addr;
1512db9d7d36SMaxime Chevallier /* BPPE DMA base address */
1513db9d7d36SMaxime Chevallier dma_addr_t dma_addr;
1514db9d7d36SMaxime Chevallier
1515db9d7d36SMaxime Chevallier /* Ports using BM pool */
1516db9d7d36SMaxime Chevallier u32 port_map;
1517db9d7d36SMaxime Chevallier };
1518db9d7d36SMaxime Chevallier
1519db9d7d36SMaxime Chevallier #define IS_TSO_HEADER(txq_pcpu, addr) \
1520db9d7d36SMaxime Chevallier ((addr) >= (txq_pcpu)->tso_headers_dma && \
1521db9d7d36SMaxime Chevallier (addr) < (txq_pcpu)->tso_headers_dma + \
1522db9d7d36SMaxime Chevallier (txq_pcpu)->size * TSO_HEADER_SIZE)
1523db9d7d36SMaxime Chevallier
1524db9d7d36SMaxime Chevallier #define MVPP2_DRIVER_NAME "mvpp2"
1525db9d7d36SMaxime Chevallier #define MVPP2_DRIVER_VERSION "1.0"
1526db9d7d36SMaxime Chevallier
1527db9d7d36SMaxime Chevallier void mvpp2_write(struct mvpp2 *priv, u32 offset, u32 data);
1528db9d7d36SMaxime Chevallier u32 mvpp2_read(struct mvpp2 *priv, u32 offset);
1529db9d7d36SMaxime Chevallier
153021da57a2SMaxime Chevallier void mvpp2_dbgfs_init(struct mvpp2 *priv, const char *name);
153121da57a2SMaxime Chevallier
153221da57a2SMaxime Chevallier void mvpp2_dbgfs_cleanup(struct mvpp2 *priv);
15330152dfeeSRussell King (Oracle) void mvpp2_dbgfs_exit(void);
153421da57a2SMaxime Chevallier
1535aca0e235SStefan Chulski void mvpp23_rx_fifo_fc_en(struct mvpp2 *priv, int port, bool en);
1536aca0e235SStefan Chulski
153791dd7195SRussell King #ifdef CONFIG_MVPP2_PTP
153891dd7195SRussell King int mvpp22_tai_probe(struct device *dev, struct mvpp2 *priv);
1539ce3497e2SRussell King void mvpp22_tai_tstamp(struct mvpp2_tai *tai, u32 tstamp,
1540ce3497e2SRussell King struct skb_shared_hwtstamps *hwtstamp);
1541ce3497e2SRussell King void mvpp22_tai_start(struct mvpp2_tai *tai);
1542ce3497e2SRussell King void mvpp22_tai_stop(struct mvpp2_tai *tai);
1543ce3497e2SRussell King int mvpp22_tai_ptp_clock_index(struct mvpp2_tai *tai);
154491dd7195SRussell King #else
mvpp22_tai_probe(struct device * dev,struct mvpp2 * priv)154591dd7195SRussell King static inline int mvpp22_tai_probe(struct device *dev, struct mvpp2 *priv)
154691dd7195SRussell King {
154791dd7195SRussell King return 0;
154891dd7195SRussell King }
mvpp22_tai_tstamp(struct mvpp2_tai * tai,u32 tstamp,struct skb_shared_hwtstamps * hwtstamp)1549ce3497e2SRussell King static inline void mvpp22_tai_tstamp(struct mvpp2_tai *tai, u32 tstamp,
1550ce3497e2SRussell King struct skb_shared_hwtstamps *hwtstamp)
1551ce3497e2SRussell King {
1552ce3497e2SRussell King }
mvpp22_tai_start(struct mvpp2_tai * tai)1553ce3497e2SRussell King static inline void mvpp22_tai_start(struct mvpp2_tai *tai)
1554ce3497e2SRussell King {
1555ce3497e2SRussell King }
mvpp22_tai_stop(struct mvpp2_tai * tai)1556ce3497e2SRussell King static inline void mvpp22_tai_stop(struct mvpp2_tai *tai)
1557ce3497e2SRussell King {
1558ce3497e2SRussell King }
mvpp22_tai_ptp_clock_index(struct mvpp2_tai * tai)1559ce3497e2SRussell King static inline int mvpp22_tai_ptp_clock_index(struct mvpp2_tai *tai)
1560ce3497e2SRussell King {
1561ce3497e2SRussell King return -1;
1562ce3497e2SRussell King }
156391dd7195SRussell King #endif
156491dd7195SRussell King
mvpp22_rx_hwtstamping(struct mvpp2_port * port)1565ce3497e2SRussell King static inline bool mvpp22_rx_hwtstamping(struct mvpp2_port *port)
1566ce3497e2SRussell King {
1567ce3497e2SRussell King return IS_ENABLED(CONFIG_MVPP2_PTP) && port->rx_hwtstamp;
1568ce3497e2SRussell King }
1569aca0e235SStefan Chulski
1570db9d7d36SMaxime Chevallier #endif
1571