1 /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
2 /* Copyright 2017-2019 NXP */
3 #ifndef _ENETC_HW_H_
4 #define _ENETC_HW_H_
5
6 #include <sys/cdefs.h>
7
8 #include <sys/param.h>
9
10 #define BIT(x) (1UL << (x))
11 #define GENMASK(h, l) (((~0U) - (1U << (l)) + 1) & (~0U >> (32 - 1 - (h))))
12
13 #define PCI_VENDOR_FREESCALE 0x1957
14
15 /* ENETC device IDs */
16 #define ENETC_DEV_ID_PF 0xe100
17 #define ENETC_DEV_ID_VF 0xef00
18 #define ENETC_DEV_ID_PTP 0xee02
19
20 /* ENETC register block BAR */
21 #define ENETC_BAR_REGS 0
22
23 /** SI regs, offset: 0h */
24 #define ENETC_SIMR 0
25 #define ENETC_SIMR_EN BIT(31)
26 #define ENETC_SIMR_DRXG BIT(16)
27 #define ENETC_SIMR_RSSE BIT(0)
28 #define ENETC_SICTR0 0x18
29 #define ENETC_SICTR1 0x1c
30 #define ENETC_SIPCAPR0 0x20
31 #define ENETC_SIPCAPR0_QBV BIT(4)
32 #define ENETC_SIPCAPR0_PSFP BIT(9)
33 #define ENETC_SIPCAPR0_RSS BIT(8)
34 #define ENETC_SIPCAPR1 0x24
35 #define ENETC_SITGTGR 0x30
36 #define ENETC_SIRBGCR 0x38
37 /* cache attribute registers for transactions initiated by ENETC */
38 #define ENETC_SICAR0 0x40
39 #define ENETC_SICAR1 0x44
40 #define ENETC_SICAR2 0x48
41 /* rd snoop, no alloc
42 * wr snoop, no alloc, partial cache line update for BDs and full cache line
43 * update for data
44 */
45 #define ENETC_SICAR_RD_COHERENT 0x2b2b0000
46 #define ENETC_SICAR_WR_COHERENT 0x00006727
47 #define ENETC_SICAR_MSI 0x00300030 /* rd/wr device, no snoop, no alloc */
48
49 #define ENETC_SIPMAR0 0x80
50 #define ENETC_SIPMAR1 0x84
51
52 /* VF-PF Message passing */
53 #define ENETC_DEFAULT_MSG_SIZE 1024 /* and max size */
54
55 #define ENETC_PSIMSGRR 0x204
56 #define ENETC_PSIMSGRR_MR_MASK GENMASK(2, 1)
57 #define ENETC_PSIMSGRR_MR(n) BIT((n) + 1) /* n = VSI index */
58 #define ENETC_PSIVMSGRCVAR0(n) (0x210 + (n) * 0x8) /* n = VSI index */
59 #define ENETC_PSIVMSGRCVAR1(n) (0x214 + (n) * 0x8)
60
61 #define ENETC_VSIMSGSR 0x204 /* RO */
62 #define ENETC_VSIMSGSR_MB BIT(0)
63 #define ENETC_VSIMSGSR_MS BIT(1)
64 #define ENETC_VSIMSGSNDAR0 0x210
65 #define ENETC_VSIMSGSNDAR1 0x214
66
67 #define ENETC_SIMSGSR_SET_MC(val) ((val) << 16)
68 #define ENETC_SIMSGSR_GET_MC(val) ((val) >> 16)
69
70 /* SI statistics */
71 #define ENETC_SIROCT 0x300
72 #define ENETC_SIRFRM 0x308
73 #define ENETC_SIRUCA 0x310
74 #define ENETC_SIRMCA 0x318
75 #define ENETC_SITOCT 0x320
76 #define ENETC_SITFRM 0x328
77 #define ENETC_SITUCA 0x330
78 #define ENETC_SITMCA 0x338
79 #define ENETC_RBDCR(n) (0x8180 + (n) * 0x200)
80
81 /* Control BDR regs */
82 #define ENETC_SICBDRMR 0x800
83 #define ENETC_SICBDRMR_EN BIT(31)
84 #define ENETC_SICBDRSR 0x804 /* RO */
85 #define ENETC_SICBDRBAR0 0x810
86 #define ENETC_SICBDRBAR1 0x814
87 #define ENETC_SICBDRPIR 0x818
88 #define ENETC_SICBDRCIR 0x81c
89 #define ENETC_SICBDRLENR 0x820
90
91 #define ENETC_SICAPR0 0x900
92 #define ENETC_SICAPR1 0x904
93
94 #define ENETC_PSIIER 0xa00
95 #define ENETC_PSIIER_MR_MASK GENMASK(2, 1)
96 #define ENETC_PSIIDR 0xa08
97 #define ENETC_SITXIDR 0xa18
98 #define ENETC_SIRXIDR 0xa28
99 #define ENETC_SIMSIVR 0xa30
100
101 #define ENETC_SIMSITRV(n) (0xB00 + (n) * 0x4)
102 #define ENETC_SIMSIRRV(n) (0xB80 + (n) * 0x4)
103
104 #define ENETC_SIUEFDCR 0xe28
105
106 #define ENETC_SIRFSCAPR 0x1200
107 #define ENETC_SIRFSCAPR_GET_NUM_RFS(val) ((val) & 0x7f)
108 #define ENETC_SIRSSCAPR 0x1600
109 #define ENETC_SIRSSCAPR_GET_NUM_RSS(val) (BIT((val) & 0xf) * 32)
110
111 /** SI BDR sub-blocks, n = 0..7 */
112 enum enetc_bdr_type {TX, RX};
113 #define ENETC_BDR_OFF(i) ((i) * 0x200)
114 #define ENETC_BDR(t, i, r) (0x8000 + (t) * 0x100 + ENETC_BDR_OFF(i) + (r))
115 /* RX BDR reg offsets */
116 #define ENETC_RBMR 0
117 #define ENETC_RBMR_AL BIT(0)
118 #define ENETC_RBMR_BDS BIT(2)
119 #define ENETC_RBMR_VTE BIT(5)
120 #define ENETC_RBMR_EN BIT(31)
121 #define ENETC_RBSR 0x4
122 #define ENETC_RBBSR 0x8
123 #define ENETC_RBCIR 0xc
124 #define ENETC_RBBAR0 0x10
125 #define ENETC_RBBAR1 0x14
126 #define ENETC_RBPIR 0x18
127 #define ENETC_RBLENR 0x20
128 #define ENETC_RBIER 0xa0
129 #define ENETC_RBIER_RXTIE BIT(0)
130 #define ENETC_RBIDR 0xa4
131 #define ENETC_RBICR0 0xa8
132 #define ENETC_RBICR0_ICEN BIT(31)
133 #define ENETC_RBICR0_ICPT_MASK 0x1ff
134 #define ENETC_RBICR0_SET_ICPT(n) ((n) & ENETC_RBICR0_ICPT_MASK)
135 #define ENETC_RBICR1 0xac
136
137 /* TX BDR reg offsets */
138 #define ENETC_TBMR 0
139 #define ENETC_TBSR_BUSY BIT(0)
140 #define ENETC_TBMR_VIH BIT(9)
141 #define ENETC_TBMR_PRIO_MASK GENMASK(2, 0)
142 #define ENETC_TBMR_SET_PRIO(val) ((val) & ENETC_TBMR_PRIO_MASK)
143 #define ENETC_TBMR_EN BIT(31)
144 #define ENETC_TBSR 0x4
145 #define ENETC_TBBAR0 0x10
146 #define ENETC_TBBAR1 0x14
147 #define ENETC_TBPIR 0x18
148 #define ENETC_TBCIR 0x1c
149 #define ENETC_TBCIR_IDX_MASK 0xffff
150 #define ENETC_TBLENR 0x20
151 #define ENETC_TBIER 0xa0
152 #define ENETC_TBIER_TXT BIT(0)
153 #define ENETC_TBIER_TXF BIT(1)
154 #define ENETC_TBIDR 0xa4
155 #define ENETC_TBICR0 0xa8
156 #define ENETC_TBICR0_ICEN BIT(31)
157 #define ENETC_TBICR0_ICPT_MASK 0xf
158 #define ENETC_TBICR0_SET_ICPT(n) ((ilog2(n) + 1) & ENETC_TBICR0_ICPT_MASK)
159 #define ENETC_TBICR1 0xac
160
161 #define ENETC_RTBLENR_LEN(n) ((n) & ~0x7)
162
163 /* Port regs, offset: 1_0000h */
164 #define ENETC_PORT_BASE 0x10000
165 #define ENETC_PMR 0x0000
166 #define ENETC_PMR_SI0EN BIT(16)
167 #define ENETC_PMR_EN GENMASK(18, 16)
168 #define ENETC_PMR_PSPEED_MASK GENMASK(11, 8)
169 #define ENETC_PMR_PSPEED_10M 0
170 #define ENETC_PMR_PSPEED_100M BIT(8)
171 #define ENETC_PMR_PSPEED_1000M BIT(9)
172 #define ENETC_PMR_PSPEED_2500M BIT(10)
173 #define ENETC_PSR 0x0004 /* RO */
174 #define ENETC_PSIPMR 0x0018
175 #define ENETC_PSIPMR_SET_UP(n) BIT(n) /* n = SI index */
176 #define ENETC_PSIPMR_SET_MP(n) BIT((n) + 16)
177 #define ENETC_PSIPVMR 0x001c
178 #define ENETC_VLAN_PROMISC_MAP_ALL 0x7
179 #define ENETC_PSIPVMR_SET_VP(simap) ((simap) & 0x7)
180 #define ENETC_PSIPVMR_SET_VUTA(simap) (((simap) & 0x7) << 16)
181 #define ENETC_PSIPMAR0(n) (0x0100 + (n) * 0x8) /* n = SI index */
182 #define ENETC_PSIPMAR1(n) (0x0104 + (n) * 0x8)
183 #define ENETC_PVCLCTR 0x0208
184 #define ENETC_PCVLANR1 0x0210
185 #define ENETC_PCVLANR2 0x0214
186 #define ENETC_VLAN_TYPE_C BIT(0)
187 #define ENETC_VLAN_TYPE_S BIT(1)
188 #define ENETC_PVCLCTR_OVTPIDL(bmp) ((bmp) & 0xff) /* VLAN_TYPE */
189 #define ENETC_PSIVLANR(n) (0x0240 + (n) * 4) /* n = SI index */
190 #define ENETC_PSIVLAN_EN BIT(31)
191 #define ENETC_PSIVLAN_SET_QOS(val) ((uint32_t)(val) << 12)
192 #define ENETC_PTXMBAR 0x0608
193 #define ENETC_PCAPR0 0x0900
194 #define ENETC_PCAPR0_RXBDR(val) ((val) >> 24)
195 #define ENETC_PCAPR0_TXBDR(val) (((val) >> 16) & 0xff)
196 #define ENETC_PCAPR1 0x0904
197 #define ENETC_PSICFGR0(n) (0x0940 + (n) * 0xc) /* n = SI index */
198 #define ENETC_PSICFGR0_SET_TXBDR(val) ((val) & 0xff)
199 #define ENETC_PSICFGR0_SET_RXBDR(val) (((val) & 0xff) << 16)
200 #define ENETC_PSICFGR0_VTE BIT(12)
201 #define ENETC_PSICFGR0_SIVIE BIT(14)
202 #define ENETC_PSICFGR0_ASE BIT(15)
203 #define ENETC_PSICFGR0_SIVC(bmp) (((bmp) & 0xff) << 24) /* VLAN_TYPE */
204
205 #define ENETC_PTCCBSR0(n) (0x1110 + (n) * 8) /* n = 0 to 7*/
206 #define ENETC_CBSE BIT(31)
207 #define ENETC_CBS_BW_MASK GENMASK(6, 0)
208 #define ENETC_PTCCBSR1(n) (0x1114 + (n) * 8) /* n = 0 to 7*/
209 #define ENETC_RSSHASH_KEY_SIZE 40
210 #define ENETC_PRSSCAPR 0x1404
211 #define ENETC_PRSSCAPR_GET_NUM_RSS(val) (BIT((val) & 0xf) * 32)
212 #define ENETC_PRSSK(n) (0x1410 + (n) * 4) /* n = [0..9] */
213 #define ENETC_PSIVLANFMR 0x1700
214 #define ENETC_PSIVLANFMR_VS BIT(0)
215 #define ENETC_PRFSMR 0x1800
216 #define ENETC_PRFSMR_RFSE BIT(31)
217 #define ENETC_PRFSCAPR 0x1804
218 #define ENETC_PRFSCAPR_GET_NUM_RFS(val) ((((val) & 0xf) + 1) * 16)
219 #define ENETC_PSIRFSCFGR(n) (0x1814 + (n) * 4) /* n = SI index */
220 #define ENETC_PFPMR 0x1900
221 #define ENETC_PFPMR_PMACE BIT(1)
222 #define ENETC_PFPMR_MWLM BIT(0)
223 #define ENETC_EMDIO_BASE 0x1c00
224 #define ENETC_PSIUMHFR0(n, err) (((err) ? 0x1d08 : 0x1d00) + (n) * 0x10)
225 #define ENETC_PSIUMHFR1(n) (0x1d04 + (n) * 0x10)
226 #define ENETC_PSIMMHFR0(n, err) (((err) ? 0x1d00 : 0x1d08) + (n) * 0x10)
227 #define ENETC_PSIMMHFR1(n) (0x1d0c + (n) * 0x10)
228 #define ENETC_PSIVHFR0(n) (0x1e00 + (n) * 8) /* n = SI index */
229 #define ENETC_PSIVHFR1(n) (0x1e04 + (n) * 8) /* n = SI index */
230 #define ENETC_MMCSR 0x1f00
231 #define ENETC_MMCSR_ME BIT(16)
232 #define ENETC_PTCMSDUR(n) (0x2020 + (n) * 4) /* n = TC index [0..7] */
233
234 #define ENETC_PAR_PORT_CFG 0x3050
235 #define ENETC_PAR_PORT_L4CD BIT(0)
236 #define ENETC_PAR_PORT_L3CD BIT(1)
237
238 #define ENETC_PM0_CMD_CFG 0x8008
239 #define ENETC_PM1_CMD_CFG 0x9008
240 #define ENETC_PM0_TX_EN BIT(0)
241 #define ENETC_PM0_RX_EN BIT(1)
242 #define ENETC_PM0_PROMISC BIT(4)
243 #define ENETC_PM0_CMD_XGLP BIT(10)
244 #define ENETC_PM0_CMD_TXP BIT(11)
245 #define ENETC_PM0_CMD_PHY_TX_EN BIT(15)
246 #define ENETC_PM0_CMD_SFD BIT(21)
247 #define ENETC_PM0_MAXFRM 0x8014
248 #define ENETC_SET_TX_MTU(val) ((val) << 16)
249 #define ENETC_SET_MAXFRM(val) ((val) & 0xffff)
250 #define ENETC_PM0_RX_FIFO 0x801c
251 #define ENETC_PM0_RX_FIFO_VAL 1
252
253 #define ENETC_PM_IMDIO_BASE 0x8030
254
255 #define ENETC_PM0_IF_MODE 0x8300
256 #define ENETC_PM0_IFM_RG BIT(2)
257 #define ENETC_PM0_IFM_RLP (BIT(5) | BIT(11))
258 #define ENETC_PM0_IFM_EN_AUTO BIT(15)
259 #define ENETC_PM0_IFM_SSP_MASK GENMASK(14, 13)
260 #define ENETC_PM0_IFM_SSP_1000 (2 << 13)
261 #define ENETC_PM0_IFM_SSP_100 (0 << 13)
262 #define ENETC_PM0_IFM_SSP_10 (1 << 13)
263 #define ENETC_PM0_IFM_FULL_DPX BIT(12)
264 #define ENETC_PM0_IFM_IFMODE_MASK GENMASK(1, 0)
265 #define ENETC_PM0_IFM_IFMODE_XGMII 0
266 #define ENETC_PM0_IFM_IFMODE_GMII 2
267 #define ENETC_PSIDCAPR 0x1b08
268 #define ENETC_PSIDCAPR_MSK GENMASK(15, 0)
269 #define ENETC_PSFCAPR 0x1b18
270 #define ENETC_PSFCAPR_MSK GENMASK(15, 0)
271 #define ENETC_PSGCAPR 0x1b28
272 #define ENETC_PSGCAPR_GCL_MSK GENMASK(18, 16)
273 #define ENETC_PSGCAPR_SGIT_MSK GENMASK(15, 0)
274 #define ENETC_PFMCAPR 0x1b38
275 #define ENETC_PFMCAPR_MSK GENMASK(15, 0)
276
277 /* MAC counters */
278 #define ENETC_PM0_REOCT 0x8100
279 #define ENETC_PM0_RALN 0x8110
280 #define ENETC_PM0_RXPF 0x8118
281 #define ENETC_PM0_RFRM 0x8120
282 #define ENETC_PM0_RFCS 0x8128
283 #define ENETC_PM0_RVLAN 0x8130
284 #define ENETC_PM0_RERR 0x8138
285 #define ENETC_PM0_RUCA 0x8140
286 #define ENETC_PM0_RMCA 0x8148
287 #define ENETC_PM0_RBCA 0x8150
288 #define ENETC_PM0_RDRP 0x8158
289 #define ENETC_PM0_RPKT 0x8160
290 #define ENETC_PM0_RUND 0x8168
291 #define ENETC_PM0_R64 0x8170
292 #define ENETC_PM0_R127 0x8178
293 #define ENETC_PM0_R255 0x8180
294 #define ENETC_PM0_R511 0x8188
295 #define ENETC_PM0_R1023 0x8190
296 #define ENETC_PM0_R1522 0x8198
297 #define ENETC_PM0_R1523X 0x81A0
298 #define ENETC_PM0_ROVR 0x81A8
299 #define ENETC_PM0_RJBR 0x81B0
300 #define ENETC_PM0_RFRG 0x81B8
301 #define ENETC_PM0_RCNP 0x81C0
302 #define ENETC_PM0_RDRNTP 0x81C8
303 #define ENETC_PM0_TEOCT 0x8200
304 #define ENETC_PM0_TOCT 0x8208
305 #define ENETC_PM0_TCRSE 0x8210
306 #define ENETC_PM0_TXPF 0x8218
307 #define ENETC_PM0_TFRM 0x8220
308 #define ENETC_PM0_TFCS 0x8228
309 #define ENETC_PM0_TVLAN 0x8230
310 #define ENETC_PM0_TERR 0x8238
311 #define ENETC_PM0_TUCA 0x8240
312 #define ENETC_PM0_TMCA 0x8248
313 #define ENETC_PM0_TBCA 0x8250
314 #define ENETC_PM0_TPKT 0x8260
315 #define ENETC_PM0_TUND 0x8268
316 #define ENETC_PM0_T64 0x8270
317 #define ENETC_PM0_T127 0x8278
318 #define ENETC_PM0_T255 0x8280
319 #define ENETC_PM0_T511 0x8288
320 #define ENETC_PM0_T1023 0x8290
321 #define ENETC_PM0_T1522 0x8298
322 #define ENETC_PM0_T1523X 0x82A0
323 #define ENETC_PM0_TCNP 0x82C0
324 #define ENETC_PM0_TDFR 0x82D0
325 #define ENETC_PM0_TMCOL 0x82D8
326 #define ENETC_PM0_TSCOL 0x82E0
327 #define ENETC_PM0_TLCOL 0x82E8
328 #define ENETC_PM0_TECOL 0x82F0
329
330 /* Port counters */
331 #define ENETC_PICDR(n) (0x0700 + (n) * 8) /* n = [0..3] */
332 #define ENETC_PBFDSIR 0x0810
333 #define ENETC_PFDMSAPR 0x0814
334 #define ENETC_UFDMF 0x1680
335 #define ENETC_MFDMF 0x1684
336 #define ENETC_PUFDVFR 0x1780
337 #define ENETC_PMFDVFR 0x1784
338 #define ENETC_PBFDVFR 0x1788
339
340 /** Global regs, offset: 2_0000h */
341 #define ENETC_GLOBAL_BASE 0x20000
342 #define ENETC_G_EIPBRR0 0x0bf8
343 #define ENETC_G_EIPBRR1 0x0bfc
344 #define ENETC_G_EPFBLPR(n) (0xd00 + 4 * (n))
345 #define ENETC_G_EPFBLPR1_XGMII 0x80000000
346
347 /* Buffer Descriptors (BD) */
348 union enetc_tx_bd {
349 struct {
350 uint64_t addr;
351 uint16_t buf_len;
352 uint16_t frm_len;
353 union {
354 struct {
355 uint8_t reserved[3];
356 uint8_t flags;
357 }; /* default layout */
358 uint32_t txstart;
359 uint32_t lstatus;
360 };
361 };
362 struct {
363 uint32_t tstamp;
364 uint16_t tpid;
365 uint16_t vid;
366 uint8_t reserved[6];
367 uint8_t e_flags;
368 uint8_t flags;
369 } ext; /* Tx BD extension */
370 struct {
371 uint32_t tstamp;
372 uint8_t reserved[10];
373 uint8_t status;
374 uint8_t flags;
375 } wb; /* writeback descriptor */
376 };
377
378 enum enetc_txbd_flags {
379 ENETC_TXBD_FLAGS_RES0 = BIT(0), /* reserved */
380 ENETC_TXBD_FLAGS_TSE = BIT(1),
381 ENETC_TXBD_FLAGS_W = BIT(2),
382 ENETC_TXBD_FLAGS_RES3 = BIT(3), /* reserved */
383 ENETC_TXBD_FLAGS_TXSTART = BIT(4),
384 ENETC_TXBD_FLAGS_FI = BIT(5),
385 ENETC_TXBD_FLAGS_EX = BIT(6),
386 ENETC_TXBD_FLAGS_F = BIT(7)
387 };
388 #define ENETC_TXBD_TXSTART_MASK GENMASK(24, 0)
389 #define ENETC_TXBD_FLAGS_OFFSET 24
390
enetc_clear_tx_bd(union enetc_tx_bd * txbd)391 static inline void enetc_clear_tx_bd(union enetc_tx_bd *txbd)
392 {
393 memset(txbd, 0, sizeof(*txbd));
394 }
395
396 /* Extension flags */
397 #define ENETC_TXBD_E_FLAGS_VLAN_INS BIT(0)
398 #define ENETC_TXBD_E_FLAGS_TWO_STEP_PTP BIT(2)
399
400 union enetc_rx_bd {
401 struct {
402 uint64_t addr;
403 uint8_t reserved[8];
404 } w;
405 struct {
406 uint16_t inet_csum;
407 uint16_t parse_summary;
408 uint32_t rss_hash;
409 uint16_t buf_len;
410 uint16_t vlan_opt;
411 union {
412 struct {
413 uint16_t flags;
414 uint16_t error;
415 };
416 uint32_t lstatus;
417 };
418 } r;
419 struct {
420 uint32_t tstamp;
421 uint8_t reserved[12];
422 } ext;
423 };
424
425 #define ENETC_RXBD_PARSER_ERROR BIT(15)
426
427 #define ENETC_RXBD_LSTATUS_R BIT(30)
428 #define ENETC_RXBD_LSTATUS_F BIT(31)
429 #define ENETC_RXBD_ERR_MASK 0xff
430 #define ENETC_RXBD_LSTATUS(flags) ((flags) << 16)
431 #define ENETC_RXBD_FLAG_RSSV BIT(8)
432 #define ENETC_RXBD_FLAG_VLAN BIT(9)
433 #define ENETC_RXBD_FLAG_TSTMP BIT(10)
434 #define ENETC_RXBD_FLAG_TPID GENMASK(1, 0)
435
436 #define ENETC_MAC_ADDR_FILT_CNT 8 /* # of supported entries per port */
437 #define EMETC_MAC_ADDR_FILT_RES 3 /* # of reserved entries at the beginning */
438 #define ENETC_MAX_NUM_VFS 2
439
440 #define ENETC_CBD_FLAGS_SF BIT(7) /* short format */
441 #define ENETC_CBD_STATUS_MASK 0xf
442
443 struct enetc_cmd_rfse {
444 uint8_t smac_h[6];
445 uint8_t smac_m[6];
446 uint8_t dmac_h[6];
447 uint8_t dmac_m[6];
448 uint32_t sip_h[4]; /* Big-endian */
449 uint32_t sip_m[4]; /* Big-endian */
450 uint32_t dip_h[4]; /* Big-endian */
451 uint32_t dip_m[4]; /* Big-endian */
452 uint16_t ethtype_h;
453 uint16_t ethtype_m;
454 uint16_t ethtype4_h;
455 uint16_t ethtype4_m;
456 uint16_t sport_h;
457 uint16_t sport_m;
458 uint16_t dport_h;
459 uint16_t dport_m;
460 uint16_t vlan_h;
461 uint16_t vlan_m;
462 uint8_t proto_h;
463 uint8_t proto_m;
464 uint16_t flags;
465 uint16_t result;
466 uint16_t mode;
467 };
468
469 #define ENETC_RFSE_EN BIT(15)
470 #define ENETC_RFSE_MODE_BD 2
471
472 #define ENETC_SI_INT_IDX 0
473 /* base index for Rx/Tx interrupts */
474 #define ENETC_BDR_INT_BASE_IDX 1
475
476 /* Messaging */
477
478 /* Command completion status */
479 enum enetc_msg_cmd_status {
480 ENETC_MSG_CMD_STATUS_OK,
481 ENETC_MSG_CMD_STATUS_FAIL
482 };
483
484 /* VSI-PSI command message types */
485 enum enetc_msg_cmd_type {
486 ENETC_MSG_CMD_MNG_MAC = 1, /* manage MAC address */
487 ENETC_MSG_CMD_MNG_RX_MAC_FILTER,/* manage RX MAC table */
488 ENETC_MSG_CMD_MNG_RX_VLAN_FILTER /* manage RX VLAN table */
489 };
490
491 /* VSI-PSI command action types */
492 enum enetc_msg_cmd_action_type {
493 ENETC_MSG_CMD_MNG_ADD = 1,
494 ENETC_MSG_CMD_MNG_REMOVE
495 };
496
497 /* PSI-VSI command header format */
498 struct enetc_msg_cmd_header {
499 uint16_t type; /* command class type */
500 uint16_t id; /* denotes the specific required action */
501 };
502
503 enum bdcr_cmd_class {
504 BDCR_CMD_UNSPEC = 0,
505 BDCR_CMD_MAC_FILTER,
506 BDCR_CMD_VLAN_FILTER,
507 BDCR_CMD_RSS,
508 BDCR_CMD_RFS,
509 BDCR_CMD_PORT_GCL,
510 BDCR_CMD_RECV_CLASSIFIER,
511 BDCR_CMD_STREAM_IDENTIFY,
512 BDCR_CMD_STREAM_FILTER,
513 BDCR_CMD_STREAM_GCL,
514 BDCR_CMD_FLOW_METER,
515 __BDCR_CMD_MAX_LEN,
516 BDCR_CMD_MAX_LEN = __BDCR_CMD_MAX_LEN - 1,
517 };
518
519 enum bdcr_cmd_rss {
520 BDCR_CMD_RSS_WRITE = 1,
521 BDCR_CMD_RSS_READ = 2,
522 };
523
524 /* class 5, command 0 */
525 struct tgs_gcl_conf {
526 uint8_t atc; /* init gate value */
527 uint8_t res[7];
528 struct {
529 uint8_t res1[4];
530 uint16_t acl_len;
531 uint8_t res2[2];
532 };
533 };
534
535 /* gate control list entry */
536 struct gce {
537 uint32_t period;
538 uint8_t gate;
539 uint8_t res[3];
540 };
541
542 /* tgs_gcl_conf address point to this data space */
543 struct tgs_gcl_data {
544 uint32_t btl;
545 uint32_t bth;
546 uint32_t ct;
547 uint32_t cte;
548 struct gce entry[];
549 };
550
551 /* class 7, command 0, Stream Identity Entry Configuration */
552 struct streamid_conf {
553 uint32_t stream_handle; /* init gate value */
554 uint32_t iports;
555 uint8_t id_type;
556 uint8_t oui[3];
557 uint8_t res[3];
558 uint8_t en;
559 };
560
561 #define ENETC_CBDR_SID_VID_MASK 0xfff
562 #define ENETC_CBDR_SID_VIDM BIT(12)
563 #define ENETC_CBDR_SID_TG_MASK 0xc000
564 /* streamid_conf address point to this data space */
565 struct streamid_data {
566 union {
567 uint8_t dmac[6];
568 uint8_t smac[6];
569 };
570 uint16_t vid_vidm_tg;
571 };
572
573 #define ENETC_CBDR_SFI_PRI_MASK 0x7
574 #define ENETC_CBDR_SFI_PRIM BIT(3)
575 #define ENETC_CBDR_SFI_BLOV BIT(4)
576 #define ENETC_CBDR_SFI_BLEN BIT(5)
577 #define ENETC_CBDR_SFI_MSDUEN BIT(6)
578 #define ENETC_CBDR_SFI_FMITEN BIT(7)
579 #define ENETC_CBDR_SFI_ENABLE BIT(7)
580 /* class 8, command 0, Stream Filter Instance, Short Format */
581 struct sfi_conf {
582 uint32_t stream_handle;
583 uint8_t multi;
584 uint8_t res[2];
585 uint8_t sthm;
586 /* Max Service Data Unit or Flow Meter Instance Table index.
587 * Depending on the value of FLT this represents either Max
588 * Service Data Unit (max frame size) allowed by the filter
589 * entry or is an index into the Flow Meter Instance table
590 * index identifying the policer which will be used to police
591 * it.
592 */
593 uint16_t fm_inst_table_index;
594 uint16_t msdu;
595 uint16_t sg_inst_table_index;
596 uint8_t res1[2];
597 uint32_t input_ports;
598 uint8_t res2[3];
599 uint8_t en;
600 };
601
602 /* class 8, command 2 stream Filter Instance status query short format
603 * command no need structure define
604 * Stream Filter Instance Query Statistics Response data
605 */
606 struct sfi_counter_data {
607 uint32_t matchl;
608 uint32_t matchh;
609 uint32_t msdu_dropl;
610 uint32_t msdu_droph;
611 uint32_t stream_gate_dropl;
612 uint32_t stream_gate_droph;
613 uint32_t flow_meter_dropl;
614 uint32_t flow_meter_droph;
615 };
616
617 #define ENETC_CBDR_SGI_OIPV_MASK 0x7
618 #define ENETC_CBDR_SGI_OIPV_EN BIT(3)
619 #define ENETC_CBDR_SGI_CGTST BIT(6)
620 #define ENETC_CBDR_SGI_OGTST BIT(7)
621 #define ENETC_CBDR_SGI_CFG_CHG BIT(1)
622 #define ENETC_CBDR_SGI_CFG_PND BIT(2)
623 #define ENETC_CBDR_SGI_OEX BIT(4)
624 #define ENETC_CBDR_SGI_OEXEN BIT(5)
625 #define ENETC_CBDR_SGI_IRX BIT(6)
626 #define ENETC_CBDR_SGI_IRXEN BIT(7)
627 #define ENETC_CBDR_SGI_ACLLEN_MASK 0x3
628 #define ENETC_CBDR_SGI_OCLLEN_MASK 0xc
629 #define ENETC_CBDR_SGI_EN BIT(7)
630 /* class 9, command 0, Stream Gate Instance Table, Short Format
631 * class 9, command 2, Stream Gate Instance Table entry query write back
632 * Short Format
633 */
634 struct sgi_table {
635 uint8_t res[8];
636 uint8_t oipv;
637 uint8_t res0[2];
638 uint8_t ocgtst;
639 uint8_t res1[7];
640 uint8_t gset;
641 uint8_t oacl_len;
642 uint8_t res2[2];
643 uint8_t en;
644 };
645
646 #define ENETC_CBDR_SGI_AIPV_MASK 0x7
647 #define ENETC_CBDR_SGI_AIPV_EN BIT(3)
648 #define ENETC_CBDR_SGI_AGTST BIT(7)
649
650 /* class 9, command 1, Stream Gate Control List, Long Format */
651 struct sgcl_conf {
652 uint8_t aipv;
653 uint8_t res[2];
654 uint8_t agtst;
655 uint8_t res1[4];
656 union {
657 struct {
658 uint8_t res2[4];
659 uint8_t acl_len;
660 uint8_t res3[3];
661 };
662 uint8_t cct[8]; /* Config change time */
663 };
664 };
665
666 #define ENETC_CBDR_SGL_IOMEN BIT(0)
667 #define ENETC_CBDR_SGL_IPVEN BIT(3)
668 #define ENETC_CBDR_SGL_GTST BIT(4)
669 #define ENETC_CBDR_SGL_IPV_MASK 0xe
670 /* Stream Gate Control List Entry */
671 struct sgce {
672 uint32_t interval;
673 uint8_t msdu[3];
674 uint8_t multi;
675 };
676
677 /* stream control list class 9 , cmd 1 data buffer */
678 struct sgcl_data {
679 uint32_t btl;
680 uint32_t bth;
681 uint32_t ct;
682 uint32_t cte;
683 struct sgce sgcl[0];
684 };
685
686 #define ENETC_CBDR_FMI_MR BIT(0)
687 #define ENETC_CBDR_FMI_MREN BIT(1)
688 #define ENETC_CBDR_FMI_DOY BIT(2)
689 #define ENETC_CBDR_FMI_CM BIT(3)
690 #define ENETC_CBDR_FMI_CF BIT(4)
691 #define ENETC_CBDR_FMI_NDOR BIT(5)
692 #define ENETC_CBDR_FMI_OALEN BIT(6)
693 #define ENETC_CBDR_FMI_IRFPP_MASK GENMASK(4, 0)
694
695 /* class 10: command 0/1, Flow Meter Instance Set, short Format */
696 struct fmi_conf {
697 uint32_t cir;
698 uint32_t cbs;
699 uint32_t eir;
700 uint32_t ebs;
701 uint8_t conf;
702 uint8_t res1;
703 uint8_t ir_fpp;
704 uint8_t res2[4];
705 uint8_t en;
706 };
707
708 struct enetc_cbd {
709 union{
710 struct sfi_conf sfi_conf;
711 struct sgi_table sgi_table;
712 struct fmi_conf fmi_conf;
713 struct {
714 uint32_t addr[2];
715 union {
716 uint32_t opt[4];
717 struct tgs_gcl_conf gcl_conf;
718 struct streamid_conf sid_set;
719 struct sgcl_conf sgcl_conf;
720 };
721 }; /* Long format */
722 uint32_t data[6];
723 };
724 uint16_t index;
725 uint16_t length;
726 uint8_t cmd;
727 uint8_t cls;
728 uint8_t _res;
729 uint8_t status_flags;
730 };
731
732 #define ENETC_CLK 400000000ULL
733
734 /* port time gating control register */
735 #define ENETC_QBV_PTGCR_OFFSET 0x11a00
736 #define ENETC_QBV_TGE BIT(31)
737 #define ENETC_QBV_TGPE BIT(30)
738
739 /* Port time gating capability register */
740 #define ENETC_QBV_PTGCAPR_OFFSET 0x11a08
741 #define ENETC_QBV_MAX_GCL_LEN_MASK GENMASK(15, 0)
742
743 /* Port time specific departure */
744 #define ENETC_PTCTSDR(n) (0x1210 + 4 * (n))
745 #define ENETC_TSDE BIT(31)
746
747 /* PSFP setting */
748 #define ENETC_PPSFPMR 0x11b00
749 #define ENETC_PPSFPMR_PSFPEN BIT(0)
750 #define ENETC_PPSFPMR_VS BIT(1)
751 #define ENETC_PPSFPMR_PVC BIT(2)
752 #define ENETC_PPSFPMR_PVZC BIT(3)
753
754 #endif
755