xref: /openbmc/linux/include/soc/mscc/ocelot.h (revision df291e54)
15e256365SVladimir Oltean /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
25e256365SVladimir Oltean /* Copyright (c) 2017 Microsemi Corporation
35e256365SVladimir Oltean  */
45e256365SVladimir Oltean 
55e256365SVladimir Oltean #ifndef _SOC_MSCC_OCELOT_H
65e256365SVladimir Oltean #define _SOC_MSCC_OCELOT_H
75e256365SVladimir Oltean 
85e256365SVladimir Oltean #include <linux/ptp_clock_kernel.h>
95e256365SVladimir Oltean #include <linux/net_tstamp.h>
105e256365SVladimir Oltean #include <linux/if_vlan.h>
115e256365SVladimir Oltean #include <linux/regmap.h>
125e256365SVladimir Oltean #include <net/dsa.h>
135e256365SVladimir Oltean 
141cf3299bSVladimir Oltean /* Port Group IDs (PGID) are masks of destination ports.
151cf3299bSVladimir Oltean  *
161cf3299bSVladimir Oltean  * For L2 forwarding, the switch performs 3 lookups in the PGID table for each
171cf3299bSVladimir Oltean  * frame, and forwards the frame to the ports that are present in the logical
181cf3299bSVladimir Oltean  * AND of all 3 PGIDs.
191cf3299bSVladimir Oltean  *
201cf3299bSVladimir Oltean  * These PGID lookups are:
211cf3299bSVladimir Oltean  * - In one of PGID[0-63]: for the destination masks. There are 2 paths by
221cf3299bSVladimir Oltean  *   which the switch selects a destination PGID:
231cf3299bSVladimir Oltean  *     - The {DMAC, VID} is present in the MAC table. In that case, the
241cf3299bSVladimir Oltean  *       destination PGID is given by the DEST_IDX field of the MAC table entry
251cf3299bSVladimir Oltean  *       that matched.
261cf3299bSVladimir Oltean  *     - The {DMAC, VID} is not present in the MAC table (it is unknown). The
271cf3299bSVladimir Oltean  *       frame is disseminated as being either unicast, multicast or broadcast,
281cf3299bSVladimir Oltean  *       and according to that, the destination PGID is chosen as being the
291cf3299bSVladimir Oltean  *       value contained by ANA_FLOODING_FLD_UNICAST,
301cf3299bSVladimir Oltean  *       ANA_FLOODING_FLD_MULTICAST or ANA_FLOODING_FLD_BROADCAST.
311cf3299bSVladimir Oltean  *   The destination PGID can be an unicast set: the first PGIDs, 0 to
321cf3299bSVladimir Oltean  *   ocelot->num_phys_ports - 1, or a multicast set: the PGIDs from
331cf3299bSVladimir Oltean  *   ocelot->num_phys_ports to 63. By convention, a unicast PGID corresponds to
341cf3299bSVladimir Oltean  *   a physical port and has a single bit set in the destination ports mask:
351cf3299bSVladimir Oltean  *   that corresponding to the port number itself. In contrast, a multicast
361cf3299bSVladimir Oltean  *   PGID will have potentially more than one single bit set in the destination
371cf3299bSVladimir Oltean  *   ports mask.
381cf3299bSVladimir Oltean  * - In one of PGID[64-79]: for the aggregation mask. The switch classifier
391cf3299bSVladimir Oltean  *   dissects each frame and generates a 4-bit Link Aggregation Code which is
401cf3299bSVladimir Oltean  *   used for this second PGID table lookup. The goal of link aggregation is to
411cf3299bSVladimir Oltean  *   hash multiple flows within the same LAG on to different destination ports.
421cf3299bSVladimir Oltean  *   The first lookup will result in a PGID with all the LAG members present in
431cf3299bSVladimir Oltean  *   the destination ports mask, and the second lookup, by Link Aggregation
441cf3299bSVladimir Oltean  *   Code, will ensure that each flow gets forwarded only to a single port out
451cf3299bSVladimir Oltean  *   of that mask (there are no duplicates).
461cf3299bSVladimir Oltean  * - In one of PGID[80-90]: for the source mask. The third time, the PGID table
471cf3299bSVladimir Oltean  *   is indexed with the ingress port (plus 80). These PGIDs answer the
481cf3299bSVladimir Oltean  *   question "is port i allowed to forward traffic to port j?" If yes, then
491cf3299bSVladimir Oltean  *   BIT(j) of PGID 80+i will be found set. The third PGID lookup can be used
501cf3299bSVladimir Oltean  *   to enforce the L2 forwarding matrix imposed by e.g. a Linux bridge.
511cf3299bSVladimir Oltean  */
521cf3299bSVladimir Oltean 
531cf3299bSVladimir Oltean /* Reserve some destination PGIDs at the end of the range:
54ebb1bb40SHoratiu Vultur  * PGID_BLACKHOLE: used for not forwarding the frames
551cf3299bSVladimir Oltean  * PGID_CPU: used for whitelisting certain MAC addresses, such as the addresses
561cf3299bSVladimir Oltean  *           of the switch port net devices, towards the CPU port module.
571cf3299bSVladimir Oltean  * PGID_UC: the flooding destinations for unknown unicast traffic.
58b360d94fSVladimir Oltean  * PGID_MC: the flooding destinations for non-IP multicast traffic.
591cf3299bSVladimir Oltean  * PGID_MCIPV4: the flooding destinations for IPv4 multicast traffic.
601cf3299bSVladimir Oltean  * PGID_MCIPV6: the flooding destinations for IPv6 multicast traffic.
61b360d94fSVladimir Oltean  * PGID_BC: the flooding destinations for broadcast traffic.
621cf3299bSVladimir Oltean  */
63ebb1bb40SHoratiu Vultur #define PGID_BLACKHOLE			57
64b360d94fSVladimir Oltean #define PGID_CPU			58
65b360d94fSVladimir Oltean #define PGID_UC				59
66b360d94fSVladimir Oltean #define PGID_MC				60
67b360d94fSVladimir Oltean #define PGID_MCIPV4			61
68b360d94fSVladimir Oltean #define PGID_MCIPV6			62
69b360d94fSVladimir Oltean #define PGID_BC				63
701cf3299bSVladimir Oltean 
7196b029b0SVladimir Oltean #define for_each_unicast_dest_pgid(ocelot, pgid)		\
7296b029b0SVladimir Oltean 	for ((pgid) = 0;					\
7396b029b0SVladimir Oltean 	     (pgid) < (ocelot)->num_phys_ports;			\
7496b029b0SVladimir Oltean 	     (pgid)++)
7596b029b0SVladimir Oltean 
7696b029b0SVladimir Oltean #define for_each_nonreserved_multicast_dest_pgid(ocelot, pgid)	\
7796b029b0SVladimir Oltean 	for ((pgid) = (ocelot)->num_phys_ports + 1;		\
78ebb1bb40SHoratiu Vultur 	     (pgid) < PGID_BLACKHOLE;				\
7996b029b0SVladimir Oltean 	     (pgid)++)
8096b029b0SVladimir Oltean 
8196b029b0SVladimir Oltean #define for_each_aggr_pgid(ocelot, pgid)			\
8296b029b0SVladimir Oltean 	for ((pgid) = PGID_AGGR;				\
8396b029b0SVladimir Oltean 	     (pgid) < PGID_SRC;					\
8496b029b0SVladimir Oltean 	     (pgid)++)
8596b029b0SVladimir Oltean 
861cf3299bSVladimir Oltean /* Aggregation PGIDs, one per Link Aggregation Code */
871cf3299bSVladimir Oltean #define PGID_AGGR			64
881cf3299bSVladimir Oltean 
891cf3299bSVladimir Oltean /* Source PGIDs, one per physical port */
901cf3299bSVladimir Oltean #define PGID_SRC			80
911cf3299bSVladimir Oltean 
925e256365SVladimir Oltean #define IFH_TAG_TYPE_C			0
935e256365SVladimir Oltean #define IFH_TAG_TYPE_S			1
945e256365SVladimir Oltean 
955e256365SVladimir Oltean #define IFH_REW_OP_NOOP			0x0
965e256365SVladimir Oltean #define IFH_REW_OP_DSCP			0x1
975e256365SVladimir Oltean #define IFH_REW_OP_ONE_STEP_PTP		0x2
985e256365SVladimir Oltean #define IFH_REW_OP_TWO_STEP_PTP		0x3
995e256365SVladimir Oltean #define IFH_REW_OP_ORIGIN_PTP		0x5
1005e256365SVladimir Oltean 
10170d39a6eSVladimir Oltean #define OCELOT_NUM_TC			8
1025e256365SVladimir Oltean 
1035e256365SVladimir Oltean #define OCELOT_SPEED_2500		0
1045e256365SVladimir Oltean #define OCELOT_SPEED_1000		1
1055e256365SVladimir Oltean #define OCELOT_SPEED_100		2
1065e256365SVladimir Oltean #define OCELOT_SPEED_10			3
1075e256365SVladimir Oltean 
108cc2d87bbSYangbo Lu #define OCELOT_PTP_PINS_NUM		4
109cc2d87bbSYangbo Lu 
1105e256365SVladimir Oltean #define TARGET_OFFSET			24
1115e256365SVladimir Oltean #define REG_MASK			GENMASK(TARGET_OFFSET - 1, 0)
1125e256365SVladimir Oltean #define REG(reg, offset)		[reg & REG_MASK] = offset
1135e256365SVladimir Oltean 
1145e256365SVladimir Oltean #define REG_RESERVED_ADDR		0xffffffff
1155e256365SVladimir Oltean #define REG_RESERVED(reg)		REG(reg, REG_RESERVED_ADDR)
1165e256365SVladimir Oltean 
117d8ea7ff3SHoratiu Vultur #define OCELOT_MRP_CPUQ			7
118d8ea7ff3SHoratiu Vultur 
1195e256365SVladimir Oltean enum ocelot_target {
1205e256365SVladimir Oltean 	ANA = 1,
1215e256365SVladimir Oltean 	QS,
1225e256365SVladimir Oltean 	QSYS,
1235e256365SVladimir Oltean 	REW,
1245e256365SVladimir Oltean 	SYS,
125e3aea296SVladimir Oltean 	S0,
126a61e365dSVladimir Oltean 	S1,
1275e256365SVladimir Oltean 	S2,
1285e256365SVladimir Oltean 	HSIO,
1295e256365SVladimir Oltean 	PTP,
1305e256365SVladimir Oltean 	GCB,
13191c724cfSVladimir Oltean 	DEV_GMII,
1325e256365SVladimir Oltean 	TARGET_MAX,
1335e256365SVladimir Oltean };
1345e256365SVladimir Oltean 
1355e256365SVladimir Oltean enum ocelot_reg {
1365e256365SVladimir Oltean 	ANA_ADVLEARN = ANA << TARGET_OFFSET,
1375e256365SVladimir Oltean 	ANA_VLANMASK,
1385e256365SVladimir Oltean 	ANA_PORT_B_DOMAIN,
1395e256365SVladimir Oltean 	ANA_ANAGEFIL,
1405e256365SVladimir Oltean 	ANA_ANEVENTS,
1415e256365SVladimir Oltean 	ANA_STORMLIMIT_BURST,
1425e256365SVladimir Oltean 	ANA_STORMLIMIT_CFG,
1435e256365SVladimir Oltean 	ANA_ISOLATED_PORTS,
1445e256365SVladimir Oltean 	ANA_COMMUNITY_PORTS,
1455e256365SVladimir Oltean 	ANA_AUTOAGE,
1465e256365SVladimir Oltean 	ANA_MACTOPTIONS,
1475e256365SVladimir Oltean 	ANA_LEARNDISC,
1485e256365SVladimir Oltean 	ANA_AGENCTRL,
1495e256365SVladimir Oltean 	ANA_MIRRORPORTS,
1505e256365SVladimir Oltean 	ANA_EMIRRORPORTS,
1515e256365SVladimir Oltean 	ANA_FLOODING,
1525e256365SVladimir Oltean 	ANA_FLOODING_IPMC,
1535e256365SVladimir Oltean 	ANA_SFLOW_CFG,
1545e256365SVladimir Oltean 	ANA_PORT_MODE,
1555e256365SVladimir Oltean 	ANA_CUT_THRU_CFG,
1565e256365SVladimir Oltean 	ANA_PGID_PGID,
1575e256365SVladimir Oltean 	ANA_TABLES_ANMOVED,
1585e256365SVladimir Oltean 	ANA_TABLES_MACHDATA,
1595e256365SVladimir Oltean 	ANA_TABLES_MACLDATA,
1605e256365SVladimir Oltean 	ANA_TABLES_STREAMDATA,
1615e256365SVladimir Oltean 	ANA_TABLES_MACACCESS,
1625e256365SVladimir Oltean 	ANA_TABLES_MACTINDX,
1635e256365SVladimir Oltean 	ANA_TABLES_VLANACCESS,
1645e256365SVladimir Oltean 	ANA_TABLES_VLANTIDX,
1655e256365SVladimir Oltean 	ANA_TABLES_ISDXACCESS,
1665e256365SVladimir Oltean 	ANA_TABLES_ISDXTIDX,
1675e256365SVladimir Oltean 	ANA_TABLES_ENTRYLIM,
1685e256365SVladimir Oltean 	ANA_TABLES_PTP_ID_HIGH,
1695e256365SVladimir Oltean 	ANA_TABLES_PTP_ID_LOW,
1705e256365SVladimir Oltean 	ANA_TABLES_STREAMACCESS,
1715e256365SVladimir Oltean 	ANA_TABLES_STREAMTIDX,
1725e256365SVladimir Oltean 	ANA_TABLES_SEQ_HISTORY,
1735e256365SVladimir Oltean 	ANA_TABLES_SEQ_MASK,
1745e256365SVladimir Oltean 	ANA_TABLES_SFID_MASK,
1755e256365SVladimir Oltean 	ANA_TABLES_SFIDACCESS,
1765e256365SVladimir Oltean 	ANA_TABLES_SFIDTIDX,
1775e256365SVladimir Oltean 	ANA_MSTI_STATE,
1785e256365SVladimir Oltean 	ANA_OAM_UPM_LM_CNT,
1795e256365SVladimir Oltean 	ANA_SG_ACCESS_CTRL,
1805e256365SVladimir Oltean 	ANA_SG_CONFIG_REG_1,
1815e256365SVladimir Oltean 	ANA_SG_CONFIG_REG_2,
1825e256365SVladimir Oltean 	ANA_SG_CONFIG_REG_3,
1835e256365SVladimir Oltean 	ANA_SG_CONFIG_REG_4,
1845e256365SVladimir Oltean 	ANA_SG_CONFIG_REG_5,
1855e256365SVladimir Oltean 	ANA_SG_GCL_GS_CONFIG,
1865e256365SVladimir Oltean 	ANA_SG_GCL_TI_CONFIG,
1875e256365SVladimir Oltean 	ANA_SG_STATUS_REG_1,
1885e256365SVladimir Oltean 	ANA_SG_STATUS_REG_2,
1895e256365SVladimir Oltean 	ANA_SG_STATUS_REG_3,
1905e256365SVladimir Oltean 	ANA_PORT_VLAN_CFG,
1915e256365SVladimir Oltean 	ANA_PORT_DROP_CFG,
1925e256365SVladimir Oltean 	ANA_PORT_QOS_CFG,
1935e256365SVladimir Oltean 	ANA_PORT_VCAP_CFG,
1945e256365SVladimir Oltean 	ANA_PORT_VCAP_S1_KEY_CFG,
1955e256365SVladimir Oltean 	ANA_PORT_VCAP_S2_CFG,
1965e256365SVladimir Oltean 	ANA_PORT_PCP_DEI_MAP,
1975e256365SVladimir Oltean 	ANA_PORT_CPU_FWD_CFG,
1985e256365SVladimir Oltean 	ANA_PORT_CPU_FWD_BPDU_CFG,
1995e256365SVladimir Oltean 	ANA_PORT_CPU_FWD_GARP_CFG,
2005e256365SVladimir Oltean 	ANA_PORT_CPU_FWD_CCM_CFG,
2015e256365SVladimir Oltean 	ANA_PORT_PORT_CFG,
2025e256365SVladimir Oltean 	ANA_PORT_POL_CFG,
2035e256365SVladimir Oltean 	ANA_PORT_PTP_CFG,
2045e256365SVladimir Oltean 	ANA_PORT_PTP_DLY1_CFG,
2055e256365SVladimir Oltean 	ANA_PORT_PTP_DLY2_CFG,
2065e256365SVladimir Oltean 	ANA_PORT_SFID_CFG,
2075e256365SVladimir Oltean 	ANA_PFC_PFC_CFG,
2085e256365SVladimir Oltean 	ANA_PFC_PFC_TIMER,
2095e256365SVladimir Oltean 	ANA_IPT_OAM_MEP_CFG,
2105e256365SVladimir Oltean 	ANA_IPT_IPT,
2115e256365SVladimir Oltean 	ANA_PPT_PPT,
2125e256365SVladimir Oltean 	ANA_FID_MAP_FID_MAP,
2135e256365SVladimir Oltean 	ANA_AGGR_CFG,
2145e256365SVladimir Oltean 	ANA_CPUQ_CFG,
2155e256365SVladimir Oltean 	ANA_CPUQ_CFG2,
2165e256365SVladimir Oltean 	ANA_CPUQ_8021_CFG,
2175e256365SVladimir Oltean 	ANA_DSCP_CFG,
2185e256365SVladimir Oltean 	ANA_DSCP_REWR_CFG,
2195e256365SVladimir Oltean 	ANA_VCAP_RNG_TYPE_CFG,
2205e256365SVladimir Oltean 	ANA_VCAP_RNG_VAL_CFG,
2215e256365SVladimir Oltean 	ANA_VRAP_CFG,
2225e256365SVladimir Oltean 	ANA_VRAP_HDR_DATA,
2235e256365SVladimir Oltean 	ANA_VRAP_HDR_MASK,
2245e256365SVladimir Oltean 	ANA_DISCARD_CFG,
2255e256365SVladimir Oltean 	ANA_FID_CFG,
2265e256365SVladimir Oltean 	ANA_POL_PIR_CFG,
2275e256365SVladimir Oltean 	ANA_POL_CIR_CFG,
2285e256365SVladimir Oltean 	ANA_POL_MODE_CFG,
2295e256365SVladimir Oltean 	ANA_POL_PIR_STATE,
2305e256365SVladimir Oltean 	ANA_POL_CIR_STATE,
2315e256365SVladimir Oltean 	ANA_POL_STATE,
2325e256365SVladimir Oltean 	ANA_POL_FLOWC,
2335e256365SVladimir Oltean 	ANA_POL_HYST,
2345e256365SVladimir Oltean 	ANA_POL_MISC_CFG,
2355e256365SVladimir Oltean 	QS_XTR_GRP_CFG = QS << TARGET_OFFSET,
2365e256365SVladimir Oltean 	QS_XTR_RD,
2375e256365SVladimir Oltean 	QS_XTR_FRM_PRUNING,
2385e256365SVladimir Oltean 	QS_XTR_FLUSH,
2395e256365SVladimir Oltean 	QS_XTR_DATA_PRESENT,
2405e256365SVladimir Oltean 	QS_XTR_CFG,
2415e256365SVladimir Oltean 	QS_INJ_GRP_CFG,
2425e256365SVladimir Oltean 	QS_INJ_WR,
2435e256365SVladimir Oltean 	QS_INJ_CTRL,
2445e256365SVladimir Oltean 	QS_INJ_STATUS,
2455e256365SVladimir Oltean 	QS_INJ_ERR,
2465e256365SVladimir Oltean 	QS_INH_DBG,
2475e256365SVladimir Oltean 	QSYS_PORT_MODE = QSYS << TARGET_OFFSET,
2485e256365SVladimir Oltean 	QSYS_SWITCH_PORT_MODE,
2495e256365SVladimir Oltean 	QSYS_STAT_CNT_CFG,
2505e256365SVladimir Oltean 	QSYS_EEE_CFG,
2515e256365SVladimir Oltean 	QSYS_EEE_THRES,
2525e256365SVladimir Oltean 	QSYS_IGR_NO_SHARING,
2535e256365SVladimir Oltean 	QSYS_EGR_NO_SHARING,
2545e256365SVladimir Oltean 	QSYS_SW_STATUS,
2555e256365SVladimir Oltean 	QSYS_EXT_CPU_CFG,
2565e256365SVladimir Oltean 	QSYS_PAD_CFG,
2575e256365SVladimir Oltean 	QSYS_CPU_GROUP_MAP,
2585e256365SVladimir Oltean 	QSYS_QMAP,
2595e256365SVladimir Oltean 	QSYS_ISDX_SGRP,
2605e256365SVladimir Oltean 	QSYS_TIMED_FRAME_ENTRY,
2615e256365SVladimir Oltean 	QSYS_TFRM_MISC,
2625e256365SVladimir Oltean 	QSYS_TFRM_PORT_DLY,
2635e256365SVladimir Oltean 	QSYS_TFRM_TIMER_CFG_1,
2645e256365SVladimir Oltean 	QSYS_TFRM_TIMER_CFG_2,
2655e256365SVladimir Oltean 	QSYS_TFRM_TIMER_CFG_3,
2665e256365SVladimir Oltean 	QSYS_TFRM_TIMER_CFG_4,
2675e256365SVladimir Oltean 	QSYS_TFRM_TIMER_CFG_5,
2685e256365SVladimir Oltean 	QSYS_TFRM_TIMER_CFG_6,
2695e256365SVladimir Oltean 	QSYS_TFRM_TIMER_CFG_7,
2705e256365SVladimir Oltean 	QSYS_TFRM_TIMER_CFG_8,
2715e256365SVladimir Oltean 	QSYS_RED_PROFILE,
2725e256365SVladimir Oltean 	QSYS_RES_QOS_MODE,
2735e256365SVladimir Oltean 	QSYS_RES_CFG,
2745e256365SVladimir Oltean 	QSYS_RES_STAT,
2755e256365SVladimir Oltean 	QSYS_EGR_DROP_MODE,
2765e256365SVladimir Oltean 	QSYS_EQ_CTRL,
2775e256365SVladimir Oltean 	QSYS_EVENTS_CORE,
2785e256365SVladimir Oltean 	QSYS_QMAXSDU_CFG_0,
2795e256365SVladimir Oltean 	QSYS_QMAXSDU_CFG_1,
2805e256365SVladimir Oltean 	QSYS_QMAXSDU_CFG_2,
2815e256365SVladimir Oltean 	QSYS_QMAXSDU_CFG_3,
2825e256365SVladimir Oltean 	QSYS_QMAXSDU_CFG_4,
2835e256365SVladimir Oltean 	QSYS_QMAXSDU_CFG_5,
2845e256365SVladimir Oltean 	QSYS_QMAXSDU_CFG_6,
2855e256365SVladimir Oltean 	QSYS_QMAXSDU_CFG_7,
2865e256365SVladimir Oltean 	QSYS_PREEMPTION_CFG,
2875e256365SVladimir Oltean 	QSYS_CIR_CFG,
2885e256365SVladimir Oltean 	QSYS_EIR_CFG,
2895e256365SVladimir Oltean 	QSYS_SE_CFG,
2905e256365SVladimir Oltean 	QSYS_SE_DWRR_CFG,
2915e256365SVladimir Oltean 	QSYS_SE_CONNECT,
2925e256365SVladimir Oltean 	QSYS_SE_DLB_SENSE,
2935e256365SVladimir Oltean 	QSYS_CIR_STATE,
2945e256365SVladimir Oltean 	QSYS_EIR_STATE,
2955e256365SVladimir Oltean 	QSYS_SE_STATE,
2965e256365SVladimir Oltean 	QSYS_HSCH_MISC_CFG,
2975e256365SVladimir Oltean 	QSYS_TAG_CONFIG,
2985e256365SVladimir Oltean 	QSYS_TAS_PARAM_CFG_CTRL,
2995e256365SVladimir Oltean 	QSYS_PORT_MAX_SDU,
3005e256365SVladimir Oltean 	QSYS_PARAM_CFG_REG_1,
3015e256365SVladimir Oltean 	QSYS_PARAM_CFG_REG_2,
3025e256365SVladimir Oltean 	QSYS_PARAM_CFG_REG_3,
3035e256365SVladimir Oltean 	QSYS_PARAM_CFG_REG_4,
3045e256365SVladimir Oltean 	QSYS_PARAM_CFG_REG_5,
3055e256365SVladimir Oltean 	QSYS_GCL_CFG_REG_1,
3065e256365SVladimir Oltean 	QSYS_GCL_CFG_REG_2,
3075e256365SVladimir Oltean 	QSYS_PARAM_STATUS_REG_1,
3085e256365SVladimir Oltean 	QSYS_PARAM_STATUS_REG_2,
3095e256365SVladimir Oltean 	QSYS_PARAM_STATUS_REG_3,
3105e256365SVladimir Oltean 	QSYS_PARAM_STATUS_REG_4,
3115e256365SVladimir Oltean 	QSYS_PARAM_STATUS_REG_5,
3125e256365SVladimir Oltean 	QSYS_PARAM_STATUS_REG_6,
3135e256365SVladimir Oltean 	QSYS_PARAM_STATUS_REG_7,
3145e256365SVladimir Oltean 	QSYS_PARAM_STATUS_REG_8,
3155e256365SVladimir Oltean 	QSYS_PARAM_STATUS_REG_9,
3165e256365SVladimir Oltean 	QSYS_GCL_STATUS_REG_1,
3175e256365SVladimir Oltean 	QSYS_GCL_STATUS_REG_2,
3185e256365SVladimir Oltean 	REW_PORT_VLAN_CFG = REW << TARGET_OFFSET,
3195e256365SVladimir Oltean 	REW_TAG_CFG,
3205e256365SVladimir Oltean 	REW_PORT_CFG,
3215e256365SVladimir Oltean 	REW_DSCP_CFG,
3225e256365SVladimir Oltean 	REW_PCP_DEI_QOS_MAP_CFG,
3235e256365SVladimir Oltean 	REW_PTP_CFG,
3245e256365SVladimir Oltean 	REW_PTP_DLY1_CFG,
3255e256365SVladimir Oltean 	REW_RED_TAG_CFG,
3265e256365SVladimir Oltean 	REW_DSCP_REMAP_DP1_CFG,
3275e256365SVladimir Oltean 	REW_DSCP_REMAP_CFG,
3285e256365SVladimir Oltean 	REW_STAT_CFG,
3295e256365SVladimir Oltean 	REW_REW_STICKY,
3305e256365SVladimir Oltean 	REW_PPT,
3315e256365SVladimir Oltean 	SYS_COUNT_RX_OCTETS = SYS << TARGET_OFFSET,
3325e256365SVladimir Oltean 	SYS_COUNT_RX_UNICAST,
3335e256365SVladimir Oltean 	SYS_COUNT_RX_MULTICAST,
3345e256365SVladimir Oltean 	SYS_COUNT_RX_BROADCAST,
3355e256365SVladimir Oltean 	SYS_COUNT_RX_SHORTS,
3365e256365SVladimir Oltean 	SYS_COUNT_RX_FRAGMENTS,
3375e256365SVladimir Oltean 	SYS_COUNT_RX_JABBERS,
3385e256365SVladimir Oltean 	SYS_COUNT_RX_CRC_ALIGN_ERRS,
3395e256365SVladimir Oltean 	SYS_COUNT_RX_SYM_ERRS,
3405e256365SVladimir Oltean 	SYS_COUNT_RX_64,
3415e256365SVladimir Oltean 	SYS_COUNT_RX_65_127,
3425e256365SVladimir Oltean 	SYS_COUNT_RX_128_255,
3435e256365SVladimir Oltean 	SYS_COUNT_RX_256_1023,
3445e256365SVladimir Oltean 	SYS_COUNT_RX_1024_1526,
3455e256365SVladimir Oltean 	SYS_COUNT_RX_1527_MAX,
3465e256365SVladimir Oltean 	SYS_COUNT_RX_PAUSE,
3475e256365SVladimir Oltean 	SYS_COUNT_RX_CONTROL,
3485e256365SVladimir Oltean 	SYS_COUNT_RX_LONGS,
3495e256365SVladimir Oltean 	SYS_COUNT_RX_CLASSIFIED_DROPS,
3505e256365SVladimir Oltean 	SYS_COUNT_TX_OCTETS,
3515e256365SVladimir Oltean 	SYS_COUNT_TX_UNICAST,
3525e256365SVladimir Oltean 	SYS_COUNT_TX_MULTICAST,
3535e256365SVladimir Oltean 	SYS_COUNT_TX_BROADCAST,
3545e256365SVladimir Oltean 	SYS_COUNT_TX_COLLISION,
3555e256365SVladimir Oltean 	SYS_COUNT_TX_DROPS,
3565e256365SVladimir Oltean 	SYS_COUNT_TX_PAUSE,
3575e256365SVladimir Oltean 	SYS_COUNT_TX_64,
3585e256365SVladimir Oltean 	SYS_COUNT_TX_65_127,
3595e256365SVladimir Oltean 	SYS_COUNT_TX_128_511,
3605e256365SVladimir Oltean 	SYS_COUNT_TX_512_1023,
3615e256365SVladimir Oltean 	SYS_COUNT_TX_1024_1526,
3625e256365SVladimir Oltean 	SYS_COUNT_TX_1527_MAX,
3635e256365SVladimir Oltean 	SYS_COUNT_TX_AGING,
3645e256365SVladimir Oltean 	SYS_RESET_CFG,
3655e256365SVladimir Oltean 	SYS_SR_ETYPE_CFG,
3665e256365SVladimir Oltean 	SYS_VLAN_ETYPE_CFG,
3675e256365SVladimir Oltean 	SYS_PORT_MODE,
3685e256365SVladimir Oltean 	SYS_FRONT_PORT_MODE,
3695e256365SVladimir Oltean 	SYS_FRM_AGING,
3705e256365SVladimir Oltean 	SYS_STAT_CFG,
3715e256365SVladimir Oltean 	SYS_SW_STATUS,
3725e256365SVladimir Oltean 	SYS_MISC_CFG,
3735e256365SVladimir Oltean 	SYS_REW_MAC_HIGH_CFG,
3745e256365SVladimir Oltean 	SYS_REW_MAC_LOW_CFG,
3755e256365SVladimir Oltean 	SYS_TIMESTAMP_OFFSET,
3765e256365SVladimir Oltean 	SYS_CMID,
3775e256365SVladimir Oltean 	SYS_PAUSE_CFG,
3785e256365SVladimir Oltean 	SYS_PAUSE_TOT_CFG,
3795e256365SVladimir Oltean 	SYS_ATOP,
3805e256365SVladimir Oltean 	SYS_ATOP_TOT_CFG,
3815e256365SVladimir Oltean 	SYS_MAC_FC_CFG,
3825e256365SVladimir Oltean 	SYS_MMGT,
3835e256365SVladimir Oltean 	SYS_MMGT_FAST,
3845e256365SVladimir Oltean 	SYS_EVENTS_DIF,
3855e256365SVladimir Oltean 	SYS_EVENTS_CORE,
3865e256365SVladimir Oltean 	SYS_CNT,
3875e256365SVladimir Oltean 	SYS_PTP_STATUS,
3885e256365SVladimir Oltean 	SYS_PTP_TXSTAMP,
3895e256365SVladimir Oltean 	SYS_PTP_NXT,
3905e256365SVladimir Oltean 	SYS_PTP_CFG,
3915e256365SVladimir Oltean 	SYS_RAM_INIT,
3925e256365SVladimir Oltean 	SYS_CM_ADDR,
3935e256365SVladimir Oltean 	SYS_CM_DATA_WR,
3945e256365SVladimir Oltean 	SYS_CM_DATA_RD,
3955e256365SVladimir Oltean 	SYS_CM_OP,
3965e256365SVladimir Oltean 	SYS_CM_DATA,
3975e256365SVladimir Oltean 	PTP_PIN_CFG = PTP << TARGET_OFFSET,
3985e256365SVladimir Oltean 	PTP_PIN_TOD_SEC_MSB,
3995e256365SVladimir Oltean 	PTP_PIN_TOD_SEC_LSB,
4005e256365SVladimir Oltean 	PTP_PIN_TOD_NSEC,
40194aca082SYangbo Lu 	PTP_PIN_WF_HIGH_PERIOD,
40294aca082SYangbo Lu 	PTP_PIN_WF_LOW_PERIOD,
4035e256365SVladimir Oltean 	PTP_CFG_MISC,
4045e256365SVladimir Oltean 	PTP_CLK_CFG_ADJ_CFG,
4055e256365SVladimir Oltean 	PTP_CLK_CFG_ADJ_FREQ,
4065e256365SVladimir Oltean 	GCB_SOFT_RST = GCB << TARGET_OFFSET,
4072789658fSMaxim Kochetkov 	GCB_MIIM_MII_STATUS,
4082789658fSMaxim Kochetkov 	GCB_MIIM_MII_CMD,
4092789658fSMaxim Kochetkov 	GCB_MIIM_MII_DATA,
41091c724cfSVladimir Oltean 	DEV_CLOCK_CFG = DEV_GMII << TARGET_OFFSET,
41191c724cfSVladimir Oltean 	DEV_PORT_MISC,
41291c724cfSVladimir Oltean 	DEV_EVENTS,
41391c724cfSVladimir Oltean 	DEV_EEE_CFG,
41491c724cfSVladimir Oltean 	DEV_RX_PATH_DELAY,
41591c724cfSVladimir Oltean 	DEV_TX_PATH_DELAY,
41691c724cfSVladimir Oltean 	DEV_PTP_PREDICT_CFG,
41791c724cfSVladimir Oltean 	DEV_MAC_ENA_CFG,
41891c724cfSVladimir Oltean 	DEV_MAC_MODE_CFG,
41991c724cfSVladimir Oltean 	DEV_MAC_MAXLEN_CFG,
42091c724cfSVladimir Oltean 	DEV_MAC_TAGS_CFG,
42191c724cfSVladimir Oltean 	DEV_MAC_ADV_CHK_CFG,
42291c724cfSVladimir Oltean 	DEV_MAC_IFG_CFG,
42391c724cfSVladimir Oltean 	DEV_MAC_HDX_CFG,
42491c724cfSVladimir Oltean 	DEV_MAC_DBG_CFG,
42591c724cfSVladimir Oltean 	DEV_MAC_FC_MAC_LOW_CFG,
42691c724cfSVladimir Oltean 	DEV_MAC_FC_MAC_HIGH_CFG,
42791c724cfSVladimir Oltean 	DEV_MAC_STICKY,
42891c724cfSVladimir Oltean 	PCS1G_CFG,
42991c724cfSVladimir Oltean 	PCS1G_MODE_CFG,
43091c724cfSVladimir Oltean 	PCS1G_SD_CFG,
43191c724cfSVladimir Oltean 	PCS1G_ANEG_CFG,
43291c724cfSVladimir Oltean 	PCS1G_ANEG_NP_CFG,
43391c724cfSVladimir Oltean 	PCS1G_LB_CFG,
43491c724cfSVladimir Oltean 	PCS1G_DBG_CFG,
43591c724cfSVladimir Oltean 	PCS1G_CDET_CFG,
43691c724cfSVladimir Oltean 	PCS1G_ANEG_STATUS,
43791c724cfSVladimir Oltean 	PCS1G_ANEG_NP_STATUS,
43891c724cfSVladimir Oltean 	PCS1G_LINK_STATUS,
43991c724cfSVladimir Oltean 	PCS1G_LINK_DOWN_CNT,
44091c724cfSVladimir Oltean 	PCS1G_STICKY,
44191c724cfSVladimir Oltean 	PCS1G_DEBUG_STATUS,
44291c724cfSVladimir Oltean 	PCS1G_LPI_CFG,
44391c724cfSVladimir Oltean 	PCS1G_LPI_WAKE_ERROR_CNT,
44491c724cfSVladimir Oltean 	PCS1G_LPI_STATUS,
44591c724cfSVladimir Oltean 	PCS1G_TSTPAT_MODE_CFG,
44691c724cfSVladimir Oltean 	PCS1G_TSTPAT_STATUS,
44791c724cfSVladimir Oltean 	DEV_PCS_FX100_CFG,
44891c724cfSVladimir Oltean 	DEV_PCS_FX100_STATUS,
4495e256365SVladimir Oltean };
4505e256365SVladimir Oltean 
4515e256365SVladimir Oltean enum ocelot_regfield {
4525e256365SVladimir Oltean 	ANA_ADVLEARN_VLAN_CHK,
4535e256365SVladimir Oltean 	ANA_ADVLEARN_LEARN_MIRROR,
4545e256365SVladimir Oltean 	ANA_ANEVENTS_FLOOD_DISCARD,
4555e256365SVladimir Oltean 	ANA_ANEVENTS_MSTI_DROP,
4565e256365SVladimir Oltean 	ANA_ANEVENTS_ACLKILL,
4575e256365SVladimir Oltean 	ANA_ANEVENTS_ACLUSED,
4585e256365SVladimir Oltean 	ANA_ANEVENTS_AUTOAGE,
4595e256365SVladimir Oltean 	ANA_ANEVENTS_VS2TTL1,
4605e256365SVladimir Oltean 	ANA_ANEVENTS_STORM_DROP,
4615e256365SVladimir Oltean 	ANA_ANEVENTS_LEARN_DROP,
4625e256365SVladimir Oltean 	ANA_ANEVENTS_AGED_ENTRY,
4635e256365SVladimir Oltean 	ANA_ANEVENTS_CPU_LEARN_FAILED,
4645e256365SVladimir Oltean 	ANA_ANEVENTS_AUTO_LEARN_FAILED,
4655e256365SVladimir Oltean 	ANA_ANEVENTS_LEARN_REMOVE,
4665e256365SVladimir Oltean 	ANA_ANEVENTS_AUTO_LEARNED,
4675e256365SVladimir Oltean 	ANA_ANEVENTS_AUTO_MOVED,
4685e256365SVladimir Oltean 	ANA_ANEVENTS_DROPPED,
4695e256365SVladimir Oltean 	ANA_ANEVENTS_CLASSIFIED_DROP,
4705e256365SVladimir Oltean 	ANA_ANEVENTS_CLASSIFIED_COPY,
4715e256365SVladimir Oltean 	ANA_ANEVENTS_VLAN_DISCARD,
4725e256365SVladimir Oltean 	ANA_ANEVENTS_FWD_DISCARD,
4735e256365SVladimir Oltean 	ANA_ANEVENTS_MULTICAST_FLOOD,
4745e256365SVladimir Oltean 	ANA_ANEVENTS_UNICAST_FLOOD,
4755e256365SVladimir Oltean 	ANA_ANEVENTS_DEST_KNOWN,
4765e256365SVladimir Oltean 	ANA_ANEVENTS_BUCKET3_MATCH,
4775e256365SVladimir Oltean 	ANA_ANEVENTS_BUCKET2_MATCH,
4785e256365SVladimir Oltean 	ANA_ANEVENTS_BUCKET1_MATCH,
4795e256365SVladimir Oltean 	ANA_ANEVENTS_BUCKET0_MATCH,
4805e256365SVladimir Oltean 	ANA_ANEVENTS_CPU_OPERATION,
4815e256365SVladimir Oltean 	ANA_ANEVENTS_DMAC_LOOKUP,
4825e256365SVladimir Oltean 	ANA_ANEVENTS_SMAC_LOOKUP,
4835e256365SVladimir Oltean 	ANA_ANEVENTS_SEQ_GEN_ERR_0,
4845e256365SVladimir Oltean 	ANA_ANEVENTS_SEQ_GEN_ERR_1,
4855e256365SVladimir Oltean 	ANA_TABLES_MACACCESS_B_DOM,
4865e256365SVladimir Oltean 	ANA_TABLES_MACTINDX_BUCKET,
4875e256365SVladimir Oltean 	ANA_TABLES_MACTINDX_M_INDEX,
488886e1387SVladimir Oltean 	QSYS_SWITCH_PORT_MODE_PORT_ENA,
489886e1387SVladimir Oltean 	QSYS_SWITCH_PORT_MODE_SCH_NEXT_CFG,
490886e1387SVladimir Oltean 	QSYS_SWITCH_PORT_MODE_YEL_RSRVD,
491886e1387SVladimir Oltean 	QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE,
492886e1387SVladimir Oltean 	QSYS_SWITCH_PORT_MODE_TX_PFC_ENA,
493886e1387SVladimir Oltean 	QSYS_SWITCH_PORT_MODE_TX_PFC_MODE,
4945e256365SVladimir Oltean 	QSYS_TIMED_FRAME_ENTRY_TFRM_VLD,
4955e256365SVladimir Oltean 	QSYS_TIMED_FRAME_ENTRY_TFRM_FP,
4965e256365SVladimir Oltean 	QSYS_TIMED_FRAME_ENTRY_TFRM_PORTNO,
4975e256365SVladimir Oltean 	QSYS_TIMED_FRAME_ENTRY_TFRM_TM_SEL,
4985e256365SVladimir Oltean 	QSYS_TIMED_FRAME_ENTRY_TFRM_TM_T,
499886e1387SVladimir Oltean 	SYS_PORT_MODE_DATA_WO_TS,
500886e1387SVladimir Oltean 	SYS_PORT_MODE_INCL_INJ_HDR,
501886e1387SVladimir Oltean 	SYS_PORT_MODE_INCL_XTR_HDR,
502886e1387SVladimir Oltean 	SYS_PORT_MODE_INCL_HDR_ERR,
5035e256365SVladimir Oltean 	SYS_RESET_CFG_CORE_ENA,
5045e256365SVladimir Oltean 	SYS_RESET_CFG_MEM_ENA,
5055e256365SVladimir Oltean 	SYS_RESET_CFG_MEM_INIT,
5065e256365SVladimir Oltean 	GCB_SOFT_RST_SWC_RST,
5072789658fSMaxim Kochetkov 	GCB_MIIM_MII_STATUS_PENDING,
5082789658fSMaxim Kochetkov 	GCB_MIIM_MII_STATUS_BUSY,
509541132f0SMaxim Kochetkov 	SYS_PAUSE_CFG_PAUSE_START,
510541132f0SMaxim Kochetkov 	SYS_PAUSE_CFG_PAUSE_STOP,
511541132f0SMaxim Kochetkov 	SYS_PAUSE_CFG_PAUSE_ENA,
5125e256365SVladimir Oltean 	REGFIELD_MAX
5135e256365SVladimir Oltean };
5145e256365SVladimir Oltean 
515c1c3993eSVladimir Oltean enum {
516c1c3993eSVladimir Oltean 	/* VCAP_CORE_CFG */
517c1c3993eSVladimir Oltean 	VCAP_CORE_UPDATE_CTRL,
518c1c3993eSVladimir Oltean 	VCAP_CORE_MV_CFG,
519c1c3993eSVladimir Oltean 	/* VCAP_CORE_CACHE */
520c1c3993eSVladimir Oltean 	VCAP_CACHE_ENTRY_DAT,
521c1c3993eSVladimir Oltean 	VCAP_CACHE_MASK_DAT,
522c1c3993eSVladimir Oltean 	VCAP_CACHE_ACTION_DAT,
523c1c3993eSVladimir Oltean 	VCAP_CACHE_CNT_DAT,
524c1c3993eSVladimir Oltean 	VCAP_CACHE_TG_DAT,
52520968054SVladimir Oltean 	/* VCAP_CONST */
52620968054SVladimir Oltean 	VCAP_CONST_VCAP_VER,
52720968054SVladimir Oltean 	VCAP_CONST_ENTRY_WIDTH,
52820968054SVladimir Oltean 	VCAP_CONST_ENTRY_CNT,
52920968054SVladimir Oltean 	VCAP_CONST_ENTRY_SWCNT,
53020968054SVladimir Oltean 	VCAP_CONST_ENTRY_TG_WIDTH,
53120968054SVladimir Oltean 	VCAP_CONST_ACTION_DEF_CNT,
53220968054SVladimir Oltean 	VCAP_CONST_ACTION_WIDTH,
53320968054SVladimir Oltean 	VCAP_CONST_CNT_WIDTH,
53420968054SVladimir Oltean 	VCAP_CONST_CORE_CNT,
53520968054SVladimir Oltean 	VCAP_CONST_IF_CNT,
536c1c3993eSVladimir Oltean };
537c1c3993eSVladimir Oltean 
5383007bc73SYangbo Lu enum ocelot_ptp_pins {
5393007bc73SYangbo Lu 	PTP_PIN_0,
5403007bc73SYangbo Lu 	PTP_PIN_1,
5413007bc73SYangbo Lu 	PTP_PIN_2,
5423007bc73SYangbo Lu 	PTP_PIN_3,
5435e256365SVladimir Oltean 	TOD_ACC_PIN
5445e256365SVladimir Oltean };
5455e256365SVladimir Oltean 
5465e256365SVladimir Oltean struct ocelot_stat_layout {
5475e256365SVladimir Oltean 	u32 offset;
5485e256365SVladimir Oltean 	char name[ETH_GSTRING_LEN];
5495e256365SVladimir Oltean };
5505e256365SVladimir Oltean 
5515e256365SVladimir Oltean enum ocelot_tag_prefix {
5525e256365SVladimir Oltean 	OCELOT_TAG_PREFIX_DISABLED	= 0,
5535e256365SVladimir Oltean 	OCELOT_TAG_PREFIX_NONE,
5545e256365SVladimir Oltean 	OCELOT_TAG_PREFIX_SHORT,
5555e256365SVladimir Oltean 	OCELOT_TAG_PREFIX_LONG,
5565e256365SVladimir Oltean };
5575e256365SVladimir Oltean 
5585e256365SVladimir Oltean struct ocelot;
5595e256365SVladimir Oltean 
5605e256365SVladimir Oltean struct ocelot_ops {
561319e4dd1SVladimir Oltean 	struct net_device *(*port_to_netdev)(struct ocelot *ocelot, int port);
562319e4dd1SVladimir Oltean 	int (*netdev_to_port)(struct net_device *dev);
5635e256365SVladimir Oltean 	int (*reset)(struct ocelot *ocelot);
564aa92d836SMaxim Kochetkov 	u16 (*wm_enc)(u16 value);
565703b7621SVladimir Oltean 	u16 (*wm_dec)(u16 value);
566703b7621SVladimir Oltean 	void (*wm_stat)(u32 val, u32 *inuse, u32 *maxuse);
5675e256365SVladimir Oltean };
5685e256365SVladimir Oltean 
569aae4e500SVladimir Oltean struct ocelot_vcap_block {
570a56d7a34SVladimir Oltean 	struct list_head rules;
571a56d7a34SVladimir Oltean 	int count;
572c9a7fe12SXiaoliang Yang 	int pol_lpr;
573a56d7a34SVladimir Oltean };
574a56d7a34SVladimir Oltean 
575c3e58a75SVladimir Oltean struct ocelot_vlan {
576e2b2e83eSVladimir Oltean 	bool valid;
577c3e58a75SVladimir Oltean 	u16 vid;
578c3e58a75SVladimir Oltean };
579c3e58a75SVladimir Oltean 
580f59fd9caSVladimir Oltean enum ocelot_sb {
581f59fd9caSVladimir Oltean 	OCELOT_SB_BUF,
582f59fd9caSVladimir Oltean 	OCELOT_SB_REF,
583f59fd9caSVladimir Oltean 	OCELOT_SB_NUM,
584f59fd9caSVladimir Oltean };
585f59fd9caSVladimir Oltean 
586f59fd9caSVladimir Oltean enum ocelot_sb_pool {
587f59fd9caSVladimir Oltean 	OCELOT_SB_POOL_ING,
588f59fd9caSVladimir Oltean 	OCELOT_SB_POOL_EGR,
589f59fd9caSVladimir Oltean 	OCELOT_SB_POOL_NUM,
590f59fd9caSVladimir Oltean };
591f59fd9caSVladimir Oltean 
5925e256365SVladimir Oltean struct ocelot_port {
5935e256365SVladimir Oltean 	struct ocelot			*ocelot;
5945e256365SVladimir Oltean 
59591c724cfSVladimir Oltean 	struct regmap			*target;
5965e256365SVladimir Oltean 
59787b0f983SVladimir Oltean 	bool				vlan_aware;
598c3e58a75SVladimir Oltean 	/* VLAN that untagged frames are classified to, on ingress */
599c3e58a75SVladimir Oltean 	struct ocelot_vlan		pvid_vlan;
600c3e58a75SVladimir Oltean 	/* The VLAN ID that will be transmitted as untagged, on egress */
601c3e58a75SVladimir Oltean 	struct ocelot_vlan		native_vlan;
6025e256365SVladimir Oltean 
6035e256365SVladimir Oltean 	u8				ptp_cmd;
604b049da13SYangbo Lu 	struct sk_buff_head		tx_skbs;
6055e256365SVladimir Oltean 	u8				ts_id;
6066565243cSVladimir Oltean 	spinlock_t			ts_id_lock;
607ee50d07cSVladimir Oltean 
608ee50d07cSVladimir Oltean 	phy_interface_t			phy_mode;
60967c24049SVladimir Oltean 
61067c24049SVladimir Oltean 	u8				*xmit_template;
611e21268efSVladimir Oltean 	bool				is_dsa_8021q_cpu;
612421741eaSVladimir Oltean 	bool				learn_ena;
613b80af659SVladimir Oltean 
614b80af659SVladimir Oltean 	struct net_device		*bond;
61523ca3b72SVladimir Oltean 	bool				lag_tx_active;
6167c588c3eSHoratiu Vultur 
6177c588c3eSHoratiu Vultur 	u16				mrp_ring_id;
618*df291e54SVladimir Oltean 
619*df291e54SVladimir Oltean 	struct net_device		*bridge;
620*df291e54SVladimir Oltean 	u8				stp_state;
6215e256365SVladimir Oltean };
6225e256365SVladimir Oltean 
6235e256365SVladimir Oltean struct ocelot {
6245e256365SVladimir Oltean 	struct device			*dev;
6256c30384eSVladimir Oltean 	struct devlink			*devlink;
6266c30384eSVladimir Oltean 	struct devlink_port		*devlink_ports;
6275e256365SVladimir Oltean 
6285e256365SVladimir Oltean 	const struct ocelot_ops		*ops;
6295e256365SVladimir Oltean 	struct regmap			*targets[TARGET_MAX];
6305e256365SVladimir Oltean 	struct regmap_field		*regfields[REGFIELD_MAX];
6315e256365SVladimir Oltean 	const u32 *const		*map;
6325e256365SVladimir Oltean 	const struct ocelot_stat_layout	*stats_layout;
6335e256365SVladimir Oltean 	unsigned int			num_stats;
6345e256365SVladimir Oltean 
635f59fd9caSVladimir Oltean 	u32				pool_size[OCELOT_SB_NUM][OCELOT_SB_POOL_NUM];
636f6fe01d6SVladimir Oltean 	int				packet_buffer_size;
637f6fe01d6SVladimir Oltean 	int				num_frame_refs;
63821ce7f3eSVladimir Oltean 	int				num_mact_rows;
6395e256365SVladimir Oltean 
6405e256365SVladimir Oltean 	struct ocelot_port		**ports;
6415e256365SVladimir Oltean 
6425e256365SVladimir Oltean 	u8				base_mac[ETH_ALEN];
6435e256365SVladimir Oltean 
6445e256365SVladimir Oltean 	/* Keep track of the vlan port masks */
6455e256365SVladimir Oltean 	u32				vlan_mask[VLAN_N_VID];
6465e256365SVladimir Oltean 
647edd2410bSVladimir Oltean 	/* Switches like VSC9959 have flooding per traffic class */
648edd2410bSVladimir Oltean 	int				num_flooding_pgids;
649edd2410bSVladimir Oltean 
65069df578cSVladimir Oltean 	/* In tables like ANA:PORT and the ANA:PGID:PGID mask,
65169df578cSVladimir Oltean 	 * the CPU is located after the physical ports (at the
65269df578cSVladimir Oltean 	 * num_phys_ports index).
65369df578cSVladimir Oltean 	 */
6545e256365SVladimir Oltean 	u8				num_phys_ports;
6555e256365SVladimir Oltean 
6560b912fc9SVladimir Oltean 	int				npi;
6570b912fc9SVladimir Oltean 
658cacea62fSVladimir Oltean 	enum ocelot_tag_prefix		npi_inj_prefix;
659cacea62fSVladimir Oltean 	enum ocelot_tag_prefix		npi_xtr_prefix;
6600b912fc9SVladimir Oltean 
6615e256365SVladimir Oltean 	struct list_head		multicast;
662e5d1f896SVladimir Oltean 	struct list_head		pgids;
6635e256365SVladimir Oltean 
6641397a2ebSVladimir Oltean 	struct list_head		dummy_rules;
6651397a2ebSVladimir Oltean 	struct ocelot_vcap_block	block[3];
66620968054SVladimir Oltean 	struct vcap_props		*vcap;
667e0632940SVladimir Oltean 
6685e256365SVladimir Oltean 	/* Workqueue to check statistics for overflow with its lock */
6695e256365SVladimir Oltean 	struct mutex			stats_lock;
6705e256365SVladimir Oltean 	u64				*stats;
6715e256365SVladimir Oltean 	struct delayed_work		stats_work;
6725e256365SVladimir Oltean 	struct workqueue_struct		*stats_queue;
6735e256365SVladimir Oltean 
674ca0b272bSVladimir Oltean 	struct workqueue_struct		*owq;
675ca0b272bSVladimir Oltean 
6765e256365SVladimir Oltean 	u8				ptp:1;
6775e256365SVladimir Oltean 	struct ptp_clock		*ptp_clock;
6785e256365SVladimir Oltean 	struct ptp_clock_info		ptp_info;
6795e256365SVladimir Oltean 	struct hwtstamp_config		hwtstamp_config;
6805e256365SVladimir Oltean 	/* Protects the PTP interface state */
6815e256365SVladimir Oltean 	struct mutex			ptp_lock;
6825e256365SVladimir Oltean 	/* Protects the PTP clock */
6835e256365SVladimir Oltean 	spinlock_t			ptp_clock_lock;
684cc2d87bbSYangbo Lu 	struct ptp_pin_desc		ptp_pins[OCELOT_PTP_PINS_NUM];
6855e256365SVladimir Oltean };
6865e256365SVladimir Oltean 
687fc411eaaSVladimir Oltean struct ocelot_policer {
688fc411eaaSVladimir Oltean 	u32 rate; /* kilobit per second */
689fc411eaaSVladimir Oltean 	u32 burst; /* bytes */
690fc411eaaSVladimir Oltean };
691fc411eaaSVladimir Oltean 
6925e256365SVladimir Oltean #define ocelot_read_ix(ocelot, reg, gi, ri) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
6935e256365SVladimir Oltean #define ocelot_read_gix(ocelot, reg, gi) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi))
6945e256365SVladimir Oltean #define ocelot_read_rix(ocelot, reg, ri) __ocelot_read_ix(ocelot, reg, reg##_RSZ * (ri))
6955e256365SVladimir Oltean #define ocelot_read(ocelot, reg) __ocelot_read_ix(ocelot, reg, 0)
6965e256365SVladimir Oltean 
6975e256365SVladimir Oltean #define ocelot_write_ix(ocelot, val, reg, gi, ri) __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
6985e256365SVladimir Oltean #define ocelot_write_gix(ocelot, val, reg, gi) __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi))
6995e256365SVladimir Oltean #define ocelot_write_rix(ocelot, val, reg, ri) __ocelot_write_ix(ocelot, val, reg, reg##_RSZ * (ri))
7005e256365SVladimir Oltean #define ocelot_write(ocelot, val, reg) __ocelot_write_ix(ocelot, val, reg, 0)
7015e256365SVladimir Oltean 
7025e256365SVladimir Oltean #define ocelot_rmw_ix(ocelot, val, m, reg, gi, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
7035e256365SVladimir Oltean #define ocelot_rmw_gix(ocelot, val, m, reg, gi) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi))
7045e256365SVladimir Oltean #define ocelot_rmw_rix(ocelot, val, m, reg, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_RSZ * (ri))
7055e256365SVladimir Oltean #define ocelot_rmw(ocelot, val, m, reg) __ocelot_rmw_ix(ocelot, val, m, reg, 0)
7065e256365SVladimir Oltean 
707886e1387SVladimir Oltean #define ocelot_field_write(ocelot, reg, val) regmap_field_write((ocelot)->regfields[(reg)], (val))
708886e1387SVladimir Oltean #define ocelot_field_read(ocelot, reg, val) regmap_field_read((ocelot)->regfields[(reg)], (val))
709886e1387SVladimir Oltean #define ocelot_fields_write(ocelot, id, reg, val) regmap_fields_write((ocelot)->regfields[(reg)], (id), (val))
710886e1387SVladimir Oltean #define ocelot_fields_read(ocelot, id, reg, val) regmap_fields_read((ocelot)->regfields[(reg)], (id), (val))
711886e1387SVladimir Oltean 
7123c0e37a9SVladimir Oltean #define ocelot_target_read_ix(ocelot, target, reg, gi, ri) \
7133c0e37a9SVladimir Oltean 	__ocelot_target_read_ix(ocelot, target, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
7143c0e37a9SVladimir Oltean #define ocelot_target_read_gix(ocelot, target, reg, gi) \
7153c0e37a9SVladimir Oltean 	__ocelot_target_read_ix(ocelot, target, reg, reg##_GSZ * (gi))
7163c0e37a9SVladimir Oltean #define ocelot_target_read_rix(ocelot, target, reg, ri) \
7173c0e37a9SVladimir Oltean 	__ocelot_target_read_ix(ocelot, target, reg, reg##_RSZ * (ri))
7183c0e37a9SVladimir Oltean #define ocelot_target_read(ocelot, target, reg) \
7193c0e37a9SVladimir Oltean 	__ocelot_target_read_ix(ocelot, target, reg, 0)
7203c0e37a9SVladimir Oltean 
7213c0e37a9SVladimir Oltean #define ocelot_target_write_ix(ocelot, target, val, reg, gi, ri) \
7223c0e37a9SVladimir Oltean 	__ocelot_target_write_ix(ocelot, target, val, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
7233c0e37a9SVladimir Oltean #define ocelot_target_write_gix(ocelot, target, val, reg, gi) \
7243c0e37a9SVladimir Oltean 	__ocelot_target_write_ix(ocelot, target, val, reg, reg##_GSZ * (gi))
7253c0e37a9SVladimir Oltean #define ocelot_target_write_rix(ocelot, target, val, reg, ri) \
7263c0e37a9SVladimir Oltean 	__ocelot_target_write_ix(ocelot, target, val, reg, reg##_RSZ * (ri))
7273c0e37a9SVladimir Oltean #define ocelot_target_write(ocelot, target, val, reg) \
7283c0e37a9SVladimir Oltean 	__ocelot_target_write_ix(ocelot, target, val, reg, 0)
7293c0e37a9SVladimir Oltean 
7305e256365SVladimir Oltean /* I/O */
7315e256365SVladimir Oltean u32 ocelot_port_readl(struct ocelot_port *port, u32 reg);
7325e256365SVladimir Oltean void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);
733eb4733d7SVladimir Oltean void ocelot_port_rmwl(struct ocelot_port *port, u32 val, u32 mask, u32 reg);
7345e256365SVladimir Oltean u32 __ocelot_read_ix(struct ocelot *ocelot, u32 reg, u32 offset);
7355e256365SVladimir Oltean void __ocelot_write_ix(struct ocelot *ocelot, u32 val, u32 reg, u32 offset);
7365e256365SVladimir Oltean void __ocelot_rmw_ix(struct ocelot *ocelot, u32 val, u32 mask, u32 reg,
7375e256365SVladimir Oltean 		     u32 offset);
7383c0e37a9SVladimir Oltean u32 __ocelot_target_read_ix(struct ocelot *ocelot, enum ocelot_target target,
7393c0e37a9SVladimir Oltean 			    u32 reg, u32 offset);
7403c0e37a9SVladimir Oltean void __ocelot_target_write_ix(struct ocelot *ocelot, enum ocelot_target target,
7413c0e37a9SVladimir Oltean 			      u32 val, u32 reg, u32 offset);
7425e256365SVladimir Oltean 
743137ffbc4SVladimir Oltean /* Packet I/O */
744137ffbc4SVladimir Oltean #if IS_ENABLED(CONFIG_MSCC_OCELOT_SWITCH_LIB)
745137ffbc4SVladimir Oltean 
746137ffbc4SVladimir Oltean bool ocelot_can_inject(struct ocelot *ocelot, int grp);
747137ffbc4SVladimir Oltean void ocelot_port_inject_frame(struct ocelot *ocelot, int port, int grp,
748137ffbc4SVladimir Oltean 			      u32 rew_op, struct sk_buff *skb);
749924ee317SVladimir Oltean int ocelot_xtr_poll_frame(struct ocelot *ocelot, int grp, struct sk_buff **skb);
7500a6f17c6SVladimir Oltean void ocelot_drain_cpu_queue(struct ocelot *ocelot, int grp);
751137ffbc4SVladimir Oltean 
752137ffbc4SVladimir Oltean #else
753137ffbc4SVladimir Oltean 
754137ffbc4SVladimir Oltean static inline bool ocelot_can_inject(struct ocelot *ocelot, int grp)
755137ffbc4SVladimir Oltean {
756137ffbc4SVladimir Oltean 	return false;
757137ffbc4SVladimir Oltean }
758137ffbc4SVladimir Oltean 
759137ffbc4SVladimir Oltean static inline void ocelot_port_inject_frame(struct ocelot *ocelot, int port,
760137ffbc4SVladimir Oltean 					    int grp, u32 rew_op,
761137ffbc4SVladimir Oltean 					    struct sk_buff *skb)
762137ffbc4SVladimir Oltean {
763137ffbc4SVladimir Oltean }
764137ffbc4SVladimir Oltean 
765924ee317SVladimir Oltean static inline int ocelot_xtr_poll_frame(struct ocelot *ocelot, int grp,
766924ee317SVladimir Oltean 					struct sk_buff **skb)
767924ee317SVladimir Oltean {
768924ee317SVladimir Oltean 	return -EIO;
769924ee317SVladimir Oltean }
770924ee317SVladimir Oltean 
7710a6f17c6SVladimir Oltean static inline void ocelot_drain_cpu_queue(struct ocelot *ocelot, int grp)
7720a6f17c6SVladimir Oltean {
7730a6f17c6SVladimir Oltean }
7740a6f17c6SVladimir Oltean 
775137ffbc4SVladimir Oltean #endif
776137ffbc4SVladimir Oltean 
7775e256365SVladimir Oltean /* Hardware initialization */
7785e256365SVladimir Oltean int ocelot_regfields_init(struct ocelot *ocelot,
7795e256365SVladimir Oltean 			  const struct reg_field *const regfields);
7805e256365SVladimir Oltean struct regmap *ocelot_regmap_init(struct ocelot *ocelot, struct resource *res);
7815e256365SVladimir Oltean int ocelot_init(struct ocelot *ocelot);
7825e256365SVladimir Oltean void ocelot_deinit(struct ocelot *ocelot);
7835e256365SVladimir Oltean void ocelot_init_port(struct ocelot *ocelot, int port);
784e5fb512dSVladimir Oltean void ocelot_deinit_port(struct ocelot *ocelot, int port);
7855e256365SVladimir Oltean 
7865e256365SVladimir Oltean /* DSA callbacks */
7875e256365SVladimir Oltean void ocelot_port_enable(struct ocelot *ocelot, int port,
7885e256365SVladimir Oltean 			struct phy_device *phy);
7895e256365SVladimir Oltean void ocelot_port_disable(struct ocelot *ocelot, int port);
7905e256365SVladimir Oltean void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data);
7915e256365SVladimir Oltean void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data);
7925e256365SVladimir Oltean int ocelot_get_sset_count(struct ocelot *ocelot, int port, int sset);
7935e256365SVladimir Oltean int ocelot_get_ts_info(struct ocelot *ocelot, int port,
7945e256365SVladimir Oltean 		       struct ethtool_ts_info *info);
7955e256365SVladimir Oltean void ocelot_set_ageing_time(struct ocelot *ocelot, unsigned int msecs);
796eb4733d7SVladimir Oltean int ocelot_port_flush(struct ocelot *ocelot, int port);
7975e256365SVladimir Oltean void ocelot_adjust_link(struct ocelot *ocelot, int port,
7985e256365SVladimir Oltean 			struct phy_device *phydev);
799bae33f2bSVladimir Oltean int ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, bool enabled);
8005e256365SVladimir Oltean void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state);
801e21268efSVladimir Oltean void ocelot_apply_bridge_fwd_mask(struct ocelot *ocelot);
802421741eaSVladimir Oltean int ocelot_port_pre_bridge_flags(struct ocelot *ocelot, int port,
803421741eaSVladimir Oltean 				 struct switchdev_brport_flags val);
804421741eaSVladimir Oltean void ocelot_port_bridge_flags(struct ocelot *ocelot, int port,
805421741eaSVladimir Oltean 			      struct switchdev_brport_flags val);
8065e256365SVladimir Oltean int ocelot_port_bridge_join(struct ocelot *ocelot, int port,
8075e256365SVladimir Oltean 			    struct net_device *bridge);
8085e256365SVladimir Oltean int ocelot_port_bridge_leave(struct ocelot *ocelot, int port,
8095e256365SVladimir Oltean 			     struct net_device *bridge);
8105e256365SVladimir Oltean int ocelot_fdb_dump(struct ocelot *ocelot, int port,
8115e256365SVladimir Oltean 		    dsa_fdb_dump_cb_t *cb, void *data);
8125e256365SVladimir Oltean int ocelot_fdb_add(struct ocelot *ocelot, int port,
81387b0f983SVladimir Oltean 		   const unsigned char *addr, u16 vid);
8145e256365SVladimir Oltean int ocelot_fdb_del(struct ocelot *ocelot, int port,
8155e256365SVladimir Oltean 		   const unsigned char *addr, u16 vid);
8162f0402feSVladimir Oltean int ocelot_vlan_prepare(struct ocelot *ocelot, int port, u16 vid, bool pvid,
8172f0402feSVladimir Oltean 			bool untagged);
8185e256365SVladimir Oltean int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid,
8195e256365SVladimir Oltean 		    bool untagged);
8205e256365SVladimir Oltean int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid);
821f145922dSYangbo Lu int ocelot_hwstamp_get(struct ocelot *ocelot, int port, struct ifreq *ifr);
822f145922dSYangbo Lu int ocelot_hwstamp_set(struct ocelot *ocelot, int port, struct ifreq *ifr);
823e2f9a8feSVladimir Oltean void ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port,
824e2f9a8feSVladimir Oltean 				  struct sk_buff *clone);
825e23a7b3eSYangbo Lu void ocelot_get_txtstamp(struct ocelot *ocelot);
8260b912fc9SVladimir Oltean void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu);
8270b912fc9SVladimir Oltean int ocelot_get_max_mtu(struct ocelot *ocelot, int port);
828fc411eaaSVladimir Oltean int ocelot_port_policer_add(struct ocelot *ocelot, int port,
829fc411eaaSVladimir Oltean 			    struct ocelot_policer *pol);
830fc411eaaSVladimir Oltean int ocelot_port_policer_del(struct ocelot *ocelot, int port);
83107d985eeSVladimir Oltean int ocelot_cls_flower_replace(struct ocelot *ocelot, int port,
83207d985eeSVladimir Oltean 			      struct flow_cls_offload *f, bool ingress);
83307d985eeSVladimir Oltean int ocelot_cls_flower_destroy(struct ocelot *ocelot, int port,
83407d985eeSVladimir Oltean 			      struct flow_cls_offload *f, bool ingress);
83507d985eeSVladimir Oltean int ocelot_cls_flower_stats(struct ocelot *ocelot, int port,
83607d985eeSVladimir Oltean 			    struct flow_cls_offload *f, bool ingress);
837209edf95SVladimir Oltean int ocelot_port_mdb_add(struct ocelot *ocelot, int port,
838209edf95SVladimir Oltean 			const struct switchdev_obj_port_mdb *mdb);
839209edf95SVladimir Oltean int ocelot_port_mdb_del(struct ocelot *ocelot, int port,
840209edf95SVladimir Oltean 			const struct switchdev_obj_port_mdb *mdb);
8418fe6832eSVladimir Oltean int ocelot_port_lag_join(struct ocelot *ocelot, int port,
8428fe6832eSVladimir Oltean 			 struct net_device *bond,
8438fe6832eSVladimir Oltean 			 struct netdev_lag_upper_info *info);
8448fe6832eSVladimir Oltean void ocelot_port_lag_leave(struct ocelot *ocelot, int port,
8458fe6832eSVladimir Oltean 			   struct net_device *bond);
8468fe6832eSVladimir Oltean void ocelot_port_lag_change(struct ocelot *ocelot, int port, bool lag_tx_active);
8475e256365SVladimir Oltean 
848f59fd9caSVladimir Oltean int ocelot_devlink_sb_register(struct ocelot *ocelot);
849f59fd9caSVladimir Oltean void ocelot_devlink_sb_unregister(struct ocelot *ocelot);
850f59fd9caSVladimir Oltean int ocelot_sb_pool_get(struct ocelot *ocelot, unsigned int sb_index,
851f59fd9caSVladimir Oltean 		       u16 pool_index,
852f59fd9caSVladimir Oltean 		       struct devlink_sb_pool_info *pool_info);
853f59fd9caSVladimir Oltean int ocelot_sb_pool_set(struct ocelot *ocelot, unsigned int sb_index,
854f59fd9caSVladimir Oltean 		       u16 pool_index, u32 size,
855f59fd9caSVladimir Oltean 		       enum devlink_sb_threshold_type threshold_type,
856f59fd9caSVladimir Oltean 		       struct netlink_ext_ack *extack);
857f59fd9caSVladimir Oltean int ocelot_sb_port_pool_get(struct ocelot *ocelot, int port,
858f59fd9caSVladimir Oltean 			    unsigned int sb_index, u16 pool_index,
859f59fd9caSVladimir Oltean 			    u32 *p_threshold);
860f59fd9caSVladimir Oltean int ocelot_sb_port_pool_set(struct ocelot *ocelot, int port,
861f59fd9caSVladimir Oltean 			    unsigned int sb_index, u16 pool_index,
862f59fd9caSVladimir Oltean 			    u32 threshold, struct netlink_ext_ack *extack);
863f59fd9caSVladimir Oltean int ocelot_sb_tc_pool_bind_get(struct ocelot *ocelot, int port,
864f59fd9caSVladimir Oltean 			       unsigned int sb_index, u16 tc_index,
865f59fd9caSVladimir Oltean 			       enum devlink_sb_pool_type pool_type,
866f59fd9caSVladimir Oltean 			       u16 *p_pool_index, u32 *p_threshold);
867f59fd9caSVladimir Oltean int ocelot_sb_tc_pool_bind_set(struct ocelot *ocelot, int port,
868f59fd9caSVladimir Oltean 			       unsigned int sb_index, u16 tc_index,
869f59fd9caSVladimir Oltean 			       enum devlink_sb_pool_type pool_type,
870f59fd9caSVladimir Oltean 			       u16 pool_index, u32 threshold,
871f59fd9caSVladimir Oltean 			       struct netlink_ext_ack *extack);
872f59fd9caSVladimir Oltean int ocelot_sb_occ_snapshot(struct ocelot *ocelot, unsigned int sb_index);
873f59fd9caSVladimir Oltean int ocelot_sb_occ_max_clear(struct ocelot *ocelot, unsigned int sb_index);
874f59fd9caSVladimir Oltean int ocelot_sb_occ_port_pool_get(struct ocelot *ocelot, int port,
875f59fd9caSVladimir Oltean 				unsigned int sb_index, u16 pool_index,
876f59fd9caSVladimir Oltean 				u32 *p_cur, u32 *p_max);
877f59fd9caSVladimir Oltean int ocelot_sb_occ_tc_port_bind_get(struct ocelot *ocelot, int port,
878f59fd9caSVladimir Oltean 				   unsigned int sb_index, u16 tc_index,
879f59fd9caSVladimir Oltean 				   enum devlink_sb_pool_type pool_type,
880f59fd9caSVladimir Oltean 				   u32 *p_cur, u32 *p_max);
881f59fd9caSVladimir Oltean 
882d8ea7ff3SHoratiu Vultur #if IS_ENABLED(CONFIG_BRIDGE_MRP)
883d8ea7ff3SHoratiu Vultur int ocelot_mrp_add(struct ocelot *ocelot, int port,
884d8ea7ff3SHoratiu Vultur 		   const struct switchdev_obj_mrp *mrp);
885d8ea7ff3SHoratiu Vultur int ocelot_mrp_del(struct ocelot *ocelot, int port,
886d8ea7ff3SHoratiu Vultur 		   const struct switchdev_obj_mrp *mrp);
887d8ea7ff3SHoratiu Vultur int ocelot_mrp_add_ring_role(struct ocelot *ocelot, int port,
888d8ea7ff3SHoratiu Vultur 			     const struct switchdev_obj_ring_role_mrp *mrp);
889d8ea7ff3SHoratiu Vultur int ocelot_mrp_del_ring_role(struct ocelot *ocelot, int port,
890d8ea7ff3SHoratiu Vultur 			     const struct switchdev_obj_ring_role_mrp *mrp);
891d8ea7ff3SHoratiu Vultur #else
892d8ea7ff3SHoratiu Vultur static inline int ocelot_mrp_add(struct ocelot *ocelot, int port,
893d8ea7ff3SHoratiu Vultur 				 const struct switchdev_obj_mrp *mrp)
894d8ea7ff3SHoratiu Vultur {
895d8ea7ff3SHoratiu Vultur 	return -EOPNOTSUPP;
896d8ea7ff3SHoratiu Vultur }
897d8ea7ff3SHoratiu Vultur 
898d8ea7ff3SHoratiu Vultur static inline int ocelot_mrp_del(struct ocelot *ocelot, int port,
899d8ea7ff3SHoratiu Vultur 				 const struct switchdev_obj_mrp *mrp)
900d8ea7ff3SHoratiu Vultur {
901d8ea7ff3SHoratiu Vultur 	return -EOPNOTSUPP;
902d8ea7ff3SHoratiu Vultur }
903d8ea7ff3SHoratiu Vultur 
904d8ea7ff3SHoratiu Vultur static inline int
905d8ea7ff3SHoratiu Vultur ocelot_mrp_add_ring_role(struct ocelot *ocelot, int port,
906d8ea7ff3SHoratiu Vultur 			 const struct switchdev_obj_ring_role_mrp *mrp)
907d8ea7ff3SHoratiu Vultur {
908d8ea7ff3SHoratiu Vultur 	return -EOPNOTSUPP;
909d8ea7ff3SHoratiu Vultur }
910d8ea7ff3SHoratiu Vultur 
911d8ea7ff3SHoratiu Vultur static inline int
912d8ea7ff3SHoratiu Vultur ocelot_mrp_del_ring_role(struct ocelot *ocelot, int port,
913d8ea7ff3SHoratiu Vultur 			 const struct switchdev_obj_ring_role_mrp *mrp)
914d8ea7ff3SHoratiu Vultur {
915d8ea7ff3SHoratiu Vultur 	return -EOPNOTSUPP;
916d8ea7ff3SHoratiu Vultur }
917d8ea7ff3SHoratiu Vultur #endif
918d8ea7ff3SHoratiu Vultur 
9195e256365SVladimir Oltean #endif
920