1*4882a593Smuzhiyun /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */ 2*4882a593Smuzhiyun /* Copyright (c) 2017 Microsemi Corporation 3*4882a593Smuzhiyun */ 4*4882a593Smuzhiyun 5*4882a593Smuzhiyun #ifndef _SOC_MSCC_OCELOT_H 6*4882a593Smuzhiyun #define _SOC_MSCC_OCELOT_H 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun #include <linux/ptp_clock_kernel.h> 9*4882a593Smuzhiyun #include <linux/net_tstamp.h> 10*4882a593Smuzhiyun #include <linux/if_vlan.h> 11*4882a593Smuzhiyun #include <linux/regmap.h> 12*4882a593Smuzhiyun #include <net/dsa.h> 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun /* Port Group IDs (PGID) are masks of destination ports. 15*4882a593Smuzhiyun * 16*4882a593Smuzhiyun * For L2 forwarding, the switch performs 3 lookups in the PGID table for each 17*4882a593Smuzhiyun * frame, and forwards the frame to the ports that are present in the logical 18*4882a593Smuzhiyun * AND of all 3 PGIDs. 19*4882a593Smuzhiyun * 20*4882a593Smuzhiyun * These PGID lookups are: 21*4882a593Smuzhiyun * - In one of PGID[0-63]: for the destination masks. There are 2 paths by 22*4882a593Smuzhiyun * which the switch selects a destination PGID: 23*4882a593Smuzhiyun * - The {DMAC, VID} is present in the MAC table. In that case, the 24*4882a593Smuzhiyun * destination PGID is given by the DEST_IDX field of the MAC table entry 25*4882a593Smuzhiyun * that matched. 26*4882a593Smuzhiyun * - The {DMAC, VID} is not present in the MAC table (it is unknown). The 27*4882a593Smuzhiyun * frame is disseminated as being either unicast, multicast or broadcast, 28*4882a593Smuzhiyun * and according to that, the destination PGID is chosen as being the 29*4882a593Smuzhiyun * value contained by ANA_FLOODING_FLD_UNICAST, 30*4882a593Smuzhiyun * ANA_FLOODING_FLD_MULTICAST or ANA_FLOODING_FLD_BROADCAST. 31*4882a593Smuzhiyun * The destination PGID can be an unicast set: the first PGIDs, 0 to 32*4882a593Smuzhiyun * ocelot->num_phys_ports - 1, or a multicast set: the PGIDs from 33*4882a593Smuzhiyun * ocelot->num_phys_ports to 63. By convention, a unicast PGID corresponds to 34*4882a593Smuzhiyun * a physical port and has a single bit set in the destination ports mask: 35*4882a593Smuzhiyun * that corresponding to the port number itself. In contrast, a multicast 36*4882a593Smuzhiyun * PGID will have potentially more than one single bit set in the destination 37*4882a593Smuzhiyun * ports mask. 38*4882a593Smuzhiyun * - In one of PGID[64-79]: for the aggregation mask. The switch classifier 39*4882a593Smuzhiyun * dissects each frame and generates a 4-bit Link Aggregation Code which is 40*4882a593Smuzhiyun * used for this second PGID table lookup. The goal of link aggregation is to 41*4882a593Smuzhiyun * hash multiple flows within the same LAG on to different destination ports. 42*4882a593Smuzhiyun * The first lookup will result in a PGID with all the LAG members present in 43*4882a593Smuzhiyun * the destination ports mask, and the second lookup, by Link Aggregation 44*4882a593Smuzhiyun * Code, will ensure that each flow gets forwarded only to a single port out 45*4882a593Smuzhiyun * of that mask (there are no duplicates). 46*4882a593Smuzhiyun * - In one of PGID[80-90]: for the source mask. The third time, the PGID table 47*4882a593Smuzhiyun * is indexed with the ingress port (plus 80). These PGIDs answer the 48*4882a593Smuzhiyun * question "is port i allowed to forward traffic to port j?" If yes, then 49*4882a593Smuzhiyun * BIT(j) of PGID 80+i will be found set. The third PGID lookup can be used 50*4882a593Smuzhiyun * to enforce the L2 forwarding matrix imposed by e.g. a Linux bridge. 51*4882a593Smuzhiyun */ 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun /* Reserve some destination PGIDs at the end of the range: 54*4882a593Smuzhiyun * PGID_CPU: used for whitelisting certain MAC addresses, such as the addresses 55*4882a593Smuzhiyun * of the switch port net devices, towards the CPU port module. 56*4882a593Smuzhiyun * PGID_UC: the flooding destinations for unknown unicast traffic. 57*4882a593Smuzhiyun * PGID_MC: the flooding destinations for broadcast and non-IP multicast 58*4882a593Smuzhiyun * traffic. 59*4882a593Smuzhiyun * PGID_MCIPV4: the flooding destinations for IPv4 multicast traffic. 60*4882a593Smuzhiyun * PGID_MCIPV6: the flooding destinations for IPv6 multicast traffic. 61*4882a593Smuzhiyun */ 62*4882a593Smuzhiyun #define PGID_CPU 59 63*4882a593Smuzhiyun #define PGID_UC 60 64*4882a593Smuzhiyun #define PGID_MC 61 65*4882a593Smuzhiyun #define PGID_MCIPV4 62 66*4882a593Smuzhiyun #define PGID_MCIPV6 63 67*4882a593Smuzhiyun 68*4882a593Smuzhiyun #define for_each_unicast_dest_pgid(ocelot, pgid) \ 69*4882a593Smuzhiyun for ((pgid) = 0; \ 70*4882a593Smuzhiyun (pgid) < (ocelot)->num_phys_ports; \ 71*4882a593Smuzhiyun (pgid)++) 72*4882a593Smuzhiyun 73*4882a593Smuzhiyun #define for_each_nonreserved_multicast_dest_pgid(ocelot, pgid) \ 74*4882a593Smuzhiyun for ((pgid) = (ocelot)->num_phys_ports + 1; \ 75*4882a593Smuzhiyun (pgid) < PGID_CPU; \ 76*4882a593Smuzhiyun (pgid)++) 77*4882a593Smuzhiyun 78*4882a593Smuzhiyun #define for_each_aggr_pgid(ocelot, pgid) \ 79*4882a593Smuzhiyun for ((pgid) = PGID_AGGR; \ 80*4882a593Smuzhiyun (pgid) < PGID_SRC; \ 81*4882a593Smuzhiyun (pgid)++) 82*4882a593Smuzhiyun 83*4882a593Smuzhiyun /* Aggregation PGIDs, one per Link Aggregation Code */ 84*4882a593Smuzhiyun #define PGID_AGGR 64 85*4882a593Smuzhiyun 86*4882a593Smuzhiyun /* Source PGIDs, one per physical port */ 87*4882a593Smuzhiyun #define PGID_SRC 80 88*4882a593Smuzhiyun 89*4882a593Smuzhiyun #define IFH_INJ_BYPASS BIT(31) 90*4882a593Smuzhiyun #define IFH_INJ_POP_CNT_DISABLE (3 << 28) 91*4882a593Smuzhiyun 92*4882a593Smuzhiyun #define IFH_TAG_TYPE_C 0 93*4882a593Smuzhiyun #define IFH_TAG_TYPE_S 1 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun #define IFH_REW_OP_NOOP 0x0 96*4882a593Smuzhiyun #define IFH_REW_OP_DSCP 0x1 97*4882a593Smuzhiyun #define IFH_REW_OP_ONE_STEP_PTP 0x2 98*4882a593Smuzhiyun #define IFH_REW_OP_TWO_STEP_PTP 0x3 99*4882a593Smuzhiyun #define IFH_REW_OP_ORIGIN_PTP 0x5 100*4882a593Smuzhiyun 101*4882a593Smuzhiyun #define OCELOT_TAG_LEN 16 102*4882a593Smuzhiyun #define OCELOT_SHORT_PREFIX_LEN 4 103*4882a593Smuzhiyun #define OCELOT_LONG_PREFIX_LEN 16 104*4882a593Smuzhiyun #define OCELOT_TOTAL_TAG_LEN (OCELOT_SHORT_PREFIX_LEN + OCELOT_TAG_LEN) 105*4882a593Smuzhiyun 106*4882a593Smuzhiyun #define OCELOT_SPEED_2500 0 107*4882a593Smuzhiyun #define OCELOT_SPEED_1000 1 108*4882a593Smuzhiyun #define OCELOT_SPEED_100 2 109*4882a593Smuzhiyun #define OCELOT_SPEED_10 3 110*4882a593Smuzhiyun 111*4882a593Smuzhiyun #define OCELOT_PTP_PINS_NUM 4 112*4882a593Smuzhiyun 113*4882a593Smuzhiyun #define TARGET_OFFSET 24 114*4882a593Smuzhiyun #define REG_MASK GENMASK(TARGET_OFFSET - 1, 0) 115*4882a593Smuzhiyun #define REG(reg, offset) [reg & REG_MASK] = offset 116*4882a593Smuzhiyun 117*4882a593Smuzhiyun #define REG_RESERVED_ADDR 0xffffffff 118*4882a593Smuzhiyun #define REG_RESERVED(reg) REG(reg, REG_RESERVED_ADDR) 119*4882a593Smuzhiyun 120*4882a593Smuzhiyun enum ocelot_target { 121*4882a593Smuzhiyun ANA = 1, 122*4882a593Smuzhiyun QS, 123*4882a593Smuzhiyun QSYS, 124*4882a593Smuzhiyun REW, 125*4882a593Smuzhiyun SYS, 126*4882a593Smuzhiyun S0, 127*4882a593Smuzhiyun S1, 128*4882a593Smuzhiyun S2, 129*4882a593Smuzhiyun HSIO, 130*4882a593Smuzhiyun PTP, 131*4882a593Smuzhiyun GCB, 132*4882a593Smuzhiyun DEV_GMII, 133*4882a593Smuzhiyun TARGET_MAX, 134*4882a593Smuzhiyun }; 135*4882a593Smuzhiyun 136*4882a593Smuzhiyun enum ocelot_reg { 137*4882a593Smuzhiyun ANA_ADVLEARN = ANA << TARGET_OFFSET, 138*4882a593Smuzhiyun ANA_VLANMASK, 139*4882a593Smuzhiyun ANA_PORT_B_DOMAIN, 140*4882a593Smuzhiyun ANA_ANAGEFIL, 141*4882a593Smuzhiyun ANA_ANEVENTS, 142*4882a593Smuzhiyun ANA_STORMLIMIT_BURST, 143*4882a593Smuzhiyun ANA_STORMLIMIT_CFG, 144*4882a593Smuzhiyun ANA_ISOLATED_PORTS, 145*4882a593Smuzhiyun ANA_COMMUNITY_PORTS, 146*4882a593Smuzhiyun ANA_AUTOAGE, 147*4882a593Smuzhiyun ANA_MACTOPTIONS, 148*4882a593Smuzhiyun ANA_LEARNDISC, 149*4882a593Smuzhiyun ANA_AGENCTRL, 150*4882a593Smuzhiyun ANA_MIRRORPORTS, 151*4882a593Smuzhiyun ANA_EMIRRORPORTS, 152*4882a593Smuzhiyun ANA_FLOODING, 153*4882a593Smuzhiyun ANA_FLOODING_IPMC, 154*4882a593Smuzhiyun ANA_SFLOW_CFG, 155*4882a593Smuzhiyun ANA_PORT_MODE, 156*4882a593Smuzhiyun ANA_CUT_THRU_CFG, 157*4882a593Smuzhiyun ANA_PGID_PGID, 158*4882a593Smuzhiyun ANA_TABLES_ANMOVED, 159*4882a593Smuzhiyun ANA_TABLES_MACHDATA, 160*4882a593Smuzhiyun ANA_TABLES_MACLDATA, 161*4882a593Smuzhiyun ANA_TABLES_STREAMDATA, 162*4882a593Smuzhiyun ANA_TABLES_MACACCESS, 163*4882a593Smuzhiyun ANA_TABLES_MACTINDX, 164*4882a593Smuzhiyun ANA_TABLES_VLANACCESS, 165*4882a593Smuzhiyun ANA_TABLES_VLANTIDX, 166*4882a593Smuzhiyun ANA_TABLES_ISDXACCESS, 167*4882a593Smuzhiyun ANA_TABLES_ISDXTIDX, 168*4882a593Smuzhiyun ANA_TABLES_ENTRYLIM, 169*4882a593Smuzhiyun ANA_TABLES_PTP_ID_HIGH, 170*4882a593Smuzhiyun ANA_TABLES_PTP_ID_LOW, 171*4882a593Smuzhiyun ANA_TABLES_STREAMACCESS, 172*4882a593Smuzhiyun ANA_TABLES_STREAMTIDX, 173*4882a593Smuzhiyun ANA_TABLES_SEQ_HISTORY, 174*4882a593Smuzhiyun ANA_TABLES_SEQ_MASK, 175*4882a593Smuzhiyun ANA_TABLES_SFID_MASK, 176*4882a593Smuzhiyun ANA_TABLES_SFIDACCESS, 177*4882a593Smuzhiyun ANA_TABLES_SFIDTIDX, 178*4882a593Smuzhiyun ANA_MSTI_STATE, 179*4882a593Smuzhiyun ANA_OAM_UPM_LM_CNT, 180*4882a593Smuzhiyun ANA_SG_ACCESS_CTRL, 181*4882a593Smuzhiyun ANA_SG_CONFIG_REG_1, 182*4882a593Smuzhiyun ANA_SG_CONFIG_REG_2, 183*4882a593Smuzhiyun ANA_SG_CONFIG_REG_3, 184*4882a593Smuzhiyun ANA_SG_CONFIG_REG_4, 185*4882a593Smuzhiyun ANA_SG_CONFIG_REG_5, 186*4882a593Smuzhiyun ANA_SG_GCL_GS_CONFIG, 187*4882a593Smuzhiyun ANA_SG_GCL_TI_CONFIG, 188*4882a593Smuzhiyun ANA_SG_STATUS_REG_1, 189*4882a593Smuzhiyun ANA_SG_STATUS_REG_2, 190*4882a593Smuzhiyun ANA_SG_STATUS_REG_3, 191*4882a593Smuzhiyun ANA_PORT_VLAN_CFG, 192*4882a593Smuzhiyun ANA_PORT_DROP_CFG, 193*4882a593Smuzhiyun ANA_PORT_QOS_CFG, 194*4882a593Smuzhiyun ANA_PORT_VCAP_CFG, 195*4882a593Smuzhiyun ANA_PORT_VCAP_S1_KEY_CFG, 196*4882a593Smuzhiyun ANA_PORT_VCAP_S2_CFG, 197*4882a593Smuzhiyun ANA_PORT_PCP_DEI_MAP, 198*4882a593Smuzhiyun ANA_PORT_CPU_FWD_CFG, 199*4882a593Smuzhiyun ANA_PORT_CPU_FWD_BPDU_CFG, 200*4882a593Smuzhiyun ANA_PORT_CPU_FWD_GARP_CFG, 201*4882a593Smuzhiyun ANA_PORT_CPU_FWD_CCM_CFG, 202*4882a593Smuzhiyun ANA_PORT_PORT_CFG, 203*4882a593Smuzhiyun ANA_PORT_POL_CFG, 204*4882a593Smuzhiyun ANA_PORT_PTP_CFG, 205*4882a593Smuzhiyun ANA_PORT_PTP_DLY1_CFG, 206*4882a593Smuzhiyun ANA_PORT_PTP_DLY2_CFG, 207*4882a593Smuzhiyun ANA_PORT_SFID_CFG, 208*4882a593Smuzhiyun ANA_PFC_PFC_CFG, 209*4882a593Smuzhiyun ANA_PFC_PFC_TIMER, 210*4882a593Smuzhiyun ANA_IPT_OAM_MEP_CFG, 211*4882a593Smuzhiyun ANA_IPT_IPT, 212*4882a593Smuzhiyun ANA_PPT_PPT, 213*4882a593Smuzhiyun ANA_FID_MAP_FID_MAP, 214*4882a593Smuzhiyun ANA_AGGR_CFG, 215*4882a593Smuzhiyun ANA_CPUQ_CFG, 216*4882a593Smuzhiyun ANA_CPUQ_CFG2, 217*4882a593Smuzhiyun ANA_CPUQ_8021_CFG, 218*4882a593Smuzhiyun ANA_DSCP_CFG, 219*4882a593Smuzhiyun ANA_DSCP_REWR_CFG, 220*4882a593Smuzhiyun ANA_VCAP_RNG_TYPE_CFG, 221*4882a593Smuzhiyun ANA_VCAP_RNG_VAL_CFG, 222*4882a593Smuzhiyun ANA_VRAP_CFG, 223*4882a593Smuzhiyun ANA_VRAP_HDR_DATA, 224*4882a593Smuzhiyun ANA_VRAP_HDR_MASK, 225*4882a593Smuzhiyun ANA_DISCARD_CFG, 226*4882a593Smuzhiyun ANA_FID_CFG, 227*4882a593Smuzhiyun ANA_POL_PIR_CFG, 228*4882a593Smuzhiyun ANA_POL_CIR_CFG, 229*4882a593Smuzhiyun ANA_POL_MODE_CFG, 230*4882a593Smuzhiyun ANA_POL_PIR_STATE, 231*4882a593Smuzhiyun ANA_POL_CIR_STATE, 232*4882a593Smuzhiyun ANA_POL_STATE, 233*4882a593Smuzhiyun ANA_POL_FLOWC, 234*4882a593Smuzhiyun ANA_POL_HYST, 235*4882a593Smuzhiyun ANA_POL_MISC_CFG, 236*4882a593Smuzhiyun QS_XTR_GRP_CFG = QS << TARGET_OFFSET, 237*4882a593Smuzhiyun QS_XTR_RD, 238*4882a593Smuzhiyun QS_XTR_FRM_PRUNING, 239*4882a593Smuzhiyun QS_XTR_FLUSH, 240*4882a593Smuzhiyun QS_XTR_DATA_PRESENT, 241*4882a593Smuzhiyun QS_XTR_CFG, 242*4882a593Smuzhiyun QS_INJ_GRP_CFG, 243*4882a593Smuzhiyun QS_INJ_WR, 244*4882a593Smuzhiyun QS_INJ_CTRL, 245*4882a593Smuzhiyun QS_INJ_STATUS, 246*4882a593Smuzhiyun QS_INJ_ERR, 247*4882a593Smuzhiyun QS_INH_DBG, 248*4882a593Smuzhiyun QSYS_PORT_MODE = QSYS << TARGET_OFFSET, 249*4882a593Smuzhiyun QSYS_SWITCH_PORT_MODE, 250*4882a593Smuzhiyun QSYS_STAT_CNT_CFG, 251*4882a593Smuzhiyun QSYS_EEE_CFG, 252*4882a593Smuzhiyun QSYS_EEE_THRES, 253*4882a593Smuzhiyun QSYS_IGR_NO_SHARING, 254*4882a593Smuzhiyun QSYS_EGR_NO_SHARING, 255*4882a593Smuzhiyun QSYS_SW_STATUS, 256*4882a593Smuzhiyun QSYS_EXT_CPU_CFG, 257*4882a593Smuzhiyun QSYS_PAD_CFG, 258*4882a593Smuzhiyun QSYS_CPU_GROUP_MAP, 259*4882a593Smuzhiyun QSYS_QMAP, 260*4882a593Smuzhiyun QSYS_ISDX_SGRP, 261*4882a593Smuzhiyun QSYS_TIMED_FRAME_ENTRY, 262*4882a593Smuzhiyun QSYS_TFRM_MISC, 263*4882a593Smuzhiyun QSYS_TFRM_PORT_DLY, 264*4882a593Smuzhiyun QSYS_TFRM_TIMER_CFG_1, 265*4882a593Smuzhiyun QSYS_TFRM_TIMER_CFG_2, 266*4882a593Smuzhiyun QSYS_TFRM_TIMER_CFG_3, 267*4882a593Smuzhiyun QSYS_TFRM_TIMER_CFG_4, 268*4882a593Smuzhiyun QSYS_TFRM_TIMER_CFG_5, 269*4882a593Smuzhiyun QSYS_TFRM_TIMER_CFG_6, 270*4882a593Smuzhiyun QSYS_TFRM_TIMER_CFG_7, 271*4882a593Smuzhiyun QSYS_TFRM_TIMER_CFG_8, 272*4882a593Smuzhiyun QSYS_RED_PROFILE, 273*4882a593Smuzhiyun QSYS_RES_QOS_MODE, 274*4882a593Smuzhiyun QSYS_RES_CFG, 275*4882a593Smuzhiyun QSYS_RES_STAT, 276*4882a593Smuzhiyun QSYS_EGR_DROP_MODE, 277*4882a593Smuzhiyun QSYS_EQ_CTRL, 278*4882a593Smuzhiyun QSYS_EVENTS_CORE, 279*4882a593Smuzhiyun QSYS_QMAXSDU_CFG_0, 280*4882a593Smuzhiyun QSYS_QMAXSDU_CFG_1, 281*4882a593Smuzhiyun QSYS_QMAXSDU_CFG_2, 282*4882a593Smuzhiyun QSYS_QMAXSDU_CFG_3, 283*4882a593Smuzhiyun QSYS_QMAXSDU_CFG_4, 284*4882a593Smuzhiyun QSYS_QMAXSDU_CFG_5, 285*4882a593Smuzhiyun QSYS_QMAXSDU_CFG_6, 286*4882a593Smuzhiyun QSYS_QMAXSDU_CFG_7, 287*4882a593Smuzhiyun QSYS_PREEMPTION_CFG, 288*4882a593Smuzhiyun QSYS_CIR_CFG, 289*4882a593Smuzhiyun QSYS_EIR_CFG, 290*4882a593Smuzhiyun QSYS_SE_CFG, 291*4882a593Smuzhiyun QSYS_SE_DWRR_CFG, 292*4882a593Smuzhiyun QSYS_SE_CONNECT, 293*4882a593Smuzhiyun QSYS_SE_DLB_SENSE, 294*4882a593Smuzhiyun QSYS_CIR_STATE, 295*4882a593Smuzhiyun QSYS_EIR_STATE, 296*4882a593Smuzhiyun QSYS_SE_STATE, 297*4882a593Smuzhiyun QSYS_HSCH_MISC_CFG, 298*4882a593Smuzhiyun QSYS_TAG_CONFIG, 299*4882a593Smuzhiyun QSYS_TAS_PARAM_CFG_CTRL, 300*4882a593Smuzhiyun QSYS_PORT_MAX_SDU, 301*4882a593Smuzhiyun QSYS_PARAM_CFG_REG_1, 302*4882a593Smuzhiyun QSYS_PARAM_CFG_REG_2, 303*4882a593Smuzhiyun QSYS_PARAM_CFG_REG_3, 304*4882a593Smuzhiyun QSYS_PARAM_CFG_REG_4, 305*4882a593Smuzhiyun QSYS_PARAM_CFG_REG_5, 306*4882a593Smuzhiyun QSYS_GCL_CFG_REG_1, 307*4882a593Smuzhiyun QSYS_GCL_CFG_REG_2, 308*4882a593Smuzhiyun QSYS_PARAM_STATUS_REG_1, 309*4882a593Smuzhiyun QSYS_PARAM_STATUS_REG_2, 310*4882a593Smuzhiyun QSYS_PARAM_STATUS_REG_3, 311*4882a593Smuzhiyun QSYS_PARAM_STATUS_REG_4, 312*4882a593Smuzhiyun QSYS_PARAM_STATUS_REG_5, 313*4882a593Smuzhiyun QSYS_PARAM_STATUS_REG_6, 314*4882a593Smuzhiyun QSYS_PARAM_STATUS_REG_7, 315*4882a593Smuzhiyun QSYS_PARAM_STATUS_REG_8, 316*4882a593Smuzhiyun QSYS_PARAM_STATUS_REG_9, 317*4882a593Smuzhiyun QSYS_GCL_STATUS_REG_1, 318*4882a593Smuzhiyun QSYS_GCL_STATUS_REG_2, 319*4882a593Smuzhiyun REW_PORT_VLAN_CFG = REW << TARGET_OFFSET, 320*4882a593Smuzhiyun REW_TAG_CFG, 321*4882a593Smuzhiyun REW_PORT_CFG, 322*4882a593Smuzhiyun REW_DSCP_CFG, 323*4882a593Smuzhiyun REW_PCP_DEI_QOS_MAP_CFG, 324*4882a593Smuzhiyun REW_PTP_CFG, 325*4882a593Smuzhiyun REW_PTP_DLY1_CFG, 326*4882a593Smuzhiyun REW_RED_TAG_CFG, 327*4882a593Smuzhiyun REW_DSCP_REMAP_DP1_CFG, 328*4882a593Smuzhiyun REW_DSCP_REMAP_CFG, 329*4882a593Smuzhiyun REW_STAT_CFG, 330*4882a593Smuzhiyun REW_REW_STICKY, 331*4882a593Smuzhiyun REW_PPT, 332*4882a593Smuzhiyun SYS_COUNT_RX_OCTETS = SYS << TARGET_OFFSET, 333*4882a593Smuzhiyun SYS_COUNT_RX_UNICAST, 334*4882a593Smuzhiyun SYS_COUNT_RX_MULTICAST, 335*4882a593Smuzhiyun SYS_COUNT_RX_BROADCAST, 336*4882a593Smuzhiyun SYS_COUNT_RX_SHORTS, 337*4882a593Smuzhiyun SYS_COUNT_RX_FRAGMENTS, 338*4882a593Smuzhiyun SYS_COUNT_RX_JABBERS, 339*4882a593Smuzhiyun SYS_COUNT_RX_CRC_ALIGN_ERRS, 340*4882a593Smuzhiyun SYS_COUNT_RX_SYM_ERRS, 341*4882a593Smuzhiyun SYS_COUNT_RX_64, 342*4882a593Smuzhiyun SYS_COUNT_RX_65_127, 343*4882a593Smuzhiyun SYS_COUNT_RX_128_255, 344*4882a593Smuzhiyun SYS_COUNT_RX_256_1023, 345*4882a593Smuzhiyun SYS_COUNT_RX_1024_1526, 346*4882a593Smuzhiyun SYS_COUNT_RX_1527_MAX, 347*4882a593Smuzhiyun SYS_COUNT_RX_PAUSE, 348*4882a593Smuzhiyun SYS_COUNT_RX_CONTROL, 349*4882a593Smuzhiyun SYS_COUNT_RX_LONGS, 350*4882a593Smuzhiyun SYS_COUNT_RX_CLASSIFIED_DROPS, 351*4882a593Smuzhiyun SYS_COUNT_TX_OCTETS, 352*4882a593Smuzhiyun SYS_COUNT_TX_UNICAST, 353*4882a593Smuzhiyun SYS_COUNT_TX_MULTICAST, 354*4882a593Smuzhiyun SYS_COUNT_TX_BROADCAST, 355*4882a593Smuzhiyun SYS_COUNT_TX_COLLISION, 356*4882a593Smuzhiyun SYS_COUNT_TX_DROPS, 357*4882a593Smuzhiyun SYS_COUNT_TX_PAUSE, 358*4882a593Smuzhiyun SYS_COUNT_TX_64, 359*4882a593Smuzhiyun SYS_COUNT_TX_65_127, 360*4882a593Smuzhiyun SYS_COUNT_TX_128_511, 361*4882a593Smuzhiyun SYS_COUNT_TX_512_1023, 362*4882a593Smuzhiyun SYS_COUNT_TX_1024_1526, 363*4882a593Smuzhiyun SYS_COUNT_TX_1527_MAX, 364*4882a593Smuzhiyun SYS_COUNT_TX_AGING, 365*4882a593Smuzhiyun SYS_RESET_CFG, 366*4882a593Smuzhiyun SYS_SR_ETYPE_CFG, 367*4882a593Smuzhiyun SYS_VLAN_ETYPE_CFG, 368*4882a593Smuzhiyun SYS_PORT_MODE, 369*4882a593Smuzhiyun SYS_FRONT_PORT_MODE, 370*4882a593Smuzhiyun SYS_FRM_AGING, 371*4882a593Smuzhiyun SYS_STAT_CFG, 372*4882a593Smuzhiyun SYS_SW_STATUS, 373*4882a593Smuzhiyun SYS_MISC_CFG, 374*4882a593Smuzhiyun SYS_REW_MAC_HIGH_CFG, 375*4882a593Smuzhiyun SYS_REW_MAC_LOW_CFG, 376*4882a593Smuzhiyun SYS_TIMESTAMP_OFFSET, 377*4882a593Smuzhiyun SYS_CMID, 378*4882a593Smuzhiyun SYS_PAUSE_CFG, 379*4882a593Smuzhiyun SYS_PAUSE_TOT_CFG, 380*4882a593Smuzhiyun SYS_ATOP, 381*4882a593Smuzhiyun SYS_ATOP_TOT_CFG, 382*4882a593Smuzhiyun SYS_MAC_FC_CFG, 383*4882a593Smuzhiyun SYS_MMGT, 384*4882a593Smuzhiyun SYS_MMGT_FAST, 385*4882a593Smuzhiyun SYS_EVENTS_DIF, 386*4882a593Smuzhiyun SYS_EVENTS_CORE, 387*4882a593Smuzhiyun SYS_CNT, 388*4882a593Smuzhiyun SYS_PTP_STATUS, 389*4882a593Smuzhiyun SYS_PTP_TXSTAMP, 390*4882a593Smuzhiyun SYS_PTP_NXT, 391*4882a593Smuzhiyun SYS_PTP_CFG, 392*4882a593Smuzhiyun SYS_RAM_INIT, 393*4882a593Smuzhiyun SYS_CM_ADDR, 394*4882a593Smuzhiyun SYS_CM_DATA_WR, 395*4882a593Smuzhiyun SYS_CM_DATA_RD, 396*4882a593Smuzhiyun SYS_CM_OP, 397*4882a593Smuzhiyun SYS_CM_DATA, 398*4882a593Smuzhiyun PTP_PIN_CFG = PTP << TARGET_OFFSET, 399*4882a593Smuzhiyun PTP_PIN_TOD_SEC_MSB, 400*4882a593Smuzhiyun PTP_PIN_TOD_SEC_LSB, 401*4882a593Smuzhiyun PTP_PIN_TOD_NSEC, 402*4882a593Smuzhiyun PTP_PIN_WF_HIGH_PERIOD, 403*4882a593Smuzhiyun PTP_PIN_WF_LOW_PERIOD, 404*4882a593Smuzhiyun PTP_CFG_MISC, 405*4882a593Smuzhiyun PTP_CLK_CFG_ADJ_CFG, 406*4882a593Smuzhiyun PTP_CLK_CFG_ADJ_FREQ, 407*4882a593Smuzhiyun GCB_SOFT_RST = GCB << TARGET_OFFSET, 408*4882a593Smuzhiyun GCB_MIIM_MII_STATUS, 409*4882a593Smuzhiyun GCB_MIIM_MII_CMD, 410*4882a593Smuzhiyun GCB_MIIM_MII_DATA, 411*4882a593Smuzhiyun DEV_CLOCK_CFG = DEV_GMII << TARGET_OFFSET, 412*4882a593Smuzhiyun DEV_PORT_MISC, 413*4882a593Smuzhiyun DEV_EVENTS, 414*4882a593Smuzhiyun DEV_EEE_CFG, 415*4882a593Smuzhiyun DEV_RX_PATH_DELAY, 416*4882a593Smuzhiyun DEV_TX_PATH_DELAY, 417*4882a593Smuzhiyun DEV_PTP_PREDICT_CFG, 418*4882a593Smuzhiyun DEV_MAC_ENA_CFG, 419*4882a593Smuzhiyun DEV_MAC_MODE_CFG, 420*4882a593Smuzhiyun DEV_MAC_MAXLEN_CFG, 421*4882a593Smuzhiyun DEV_MAC_TAGS_CFG, 422*4882a593Smuzhiyun DEV_MAC_ADV_CHK_CFG, 423*4882a593Smuzhiyun DEV_MAC_IFG_CFG, 424*4882a593Smuzhiyun DEV_MAC_HDX_CFG, 425*4882a593Smuzhiyun DEV_MAC_DBG_CFG, 426*4882a593Smuzhiyun DEV_MAC_FC_MAC_LOW_CFG, 427*4882a593Smuzhiyun DEV_MAC_FC_MAC_HIGH_CFG, 428*4882a593Smuzhiyun DEV_MAC_STICKY, 429*4882a593Smuzhiyun PCS1G_CFG, 430*4882a593Smuzhiyun PCS1G_MODE_CFG, 431*4882a593Smuzhiyun PCS1G_SD_CFG, 432*4882a593Smuzhiyun PCS1G_ANEG_CFG, 433*4882a593Smuzhiyun PCS1G_ANEG_NP_CFG, 434*4882a593Smuzhiyun PCS1G_LB_CFG, 435*4882a593Smuzhiyun PCS1G_DBG_CFG, 436*4882a593Smuzhiyun PCS1G_CDET_CFG, 437*4882a593Smuzhiyun PCS1G_ANEG_STATUS, 438*4882a593Smuzhiyun PCS1G_ANEG_NP_STATUS, 439*4882a593Smuzhiyun PCS1G_LINK_STATUS, 440*4882a593Smuzhiyun PCS1G_LINK_DOWN_CNT, 441*4882a593Smuzhiyun PCS1G_STICKY, 442*4882a593Smuzhiyun PCS1G_DEBUG_STATUS, 443*4882a593Smuzhiyun PCS1G_LPI_CFG, 444*4882a593Smuzhiyun PCS1G_LPI_WAKE_ERROR_CNT, 445*4882a593Smuzhiyun PCS1G_LPI_STATUS, 446*4882a593Smuzhiyun PCS1G_TSTPAT_MODE_CFG, 447*4882a593Smuzhiyun PCS1G_TSTPAT_STATUS, 448*4882a593Smuzhiyun DEV_PCS_FX100_CFG, 449*4882a593Smuzhiyun DEV_PCS_FX100_STATUS, 450*4882a593Smuzhiyun }; 451*4882a593Smuzhiyun 452*4882a593Smuzhiyun enum ocelot_regfield { 453*4882a593Smuzhiyun ANA_ADVLEARN_VLAN_CHK, 454*4882a593Smuzhiyun ANA_ADVLEARN_LEARN_MIRROR, 455*4882a593Smuzhiyun ANA_ANEVENTS_FLOOD_DISCARD, 456*4882a593Smuzhiyun ANA_ANEVENTS_MSTI_DROP, 457*4882a593Smuzhiyun ANA_ANEVENTS_ACLKILL, 458*4882a593Smuzhiyun ANA_ANEVENTS_ACLUSED, 459*4882a593Smuzhiyun ANA_ANEVENTS_AUTOAGE, 460*4882a593Smuzhiyun ANA_ANEVENTS_VS2TTL1, 461*4882a593Smuzhiyun ANA_ANEVENTS_STORM_DROP, 462*4882a593Smuzhiyun ANA_ANEVENTS_LEARN_DROP, 463*4882a593Smuzhiyun ANA_ANEVENTS_AGED_ENTRY, 464*4882a593Smuzhiyun ANA_ANEVENTS_CPU_LEARN_FAILED, 465*4882a593Smuzhiyun ANA_ANEVENTS_AUTO_LEARN_FAILED, 466*4882a593Smuzhiyun ANA_ANEVENTS_LEARN_REMOVE, 467*4882a593Smuzhiyun ANA_ANEVENTS_AUTO_LEARNED, 468*4882a593Smuzhiyun ANA_ANEVENTS_AUTO_MOVED, 469*4882a593Smuzhiyun ANA_ANEVENTS_DROPPED, 470*4882a593Smuzhiyun ANA_ANEVENTS_CLASSIFIED_DROP, 471*4882a593Smuzhiyun ANA_ANEVENTS_CLASSIFIED_COPY, 472*4882a593Smuzhiyun ANA_ANEVENTS_VLAN_DISCARD, 473*4882a593Smuzhiyun ANA_ANEVENTS_FWD_DISCARD, 474*4882a593Smuzhiyun ANA_ANEVENTS_MULTICAST_FLOOD, 475*4882a593Smuzhiyun ANA_ANEVENTS_UNICAST_FLOOD, 476*4882a593Smuzhiyun ANA_ANEVENTS_DEST_KNOWN, 477*4882a593Smuzhiyun ANA_ANEVENTS_BUCKET3_MATCH, 478*4882a593Smuzhiyun ANA_ANEVENTS_BUCKET2_MATCH, 479*4882a593Smuzhiyun ANA_ANEVENTS_BUCKET1_MATCH, 480*4882a593Smuzhiyun ANA_ANEVENTS_BUCKET0_MATCH, 481*4882a593Smuzhiyun ANA_ANEVENTS_CPU_OPERATION, 482*4882a593Smuzhiyun ANA_ANEVENTS_DMAC_LOOKUP, 483*4882a593Smuzhiyun ANA_ANEVENTS_SMAC_LOOKUP, 484*4882a593Smuzhiyun ANA_ANEVENTS_SEQ_GEN_ERR_0, 485*4882a593Smuzhiyun ANA_ANEVENTS_SEQ_GEN_ERR_1, 486*4882a593Smuzhiyun ANA_TABLES_MACACCESS_B_DOM, 487*4882a593Smuzhiyun ANA_TABLES_MACTINDX_BUCKET, 488*4882a593Smuzhiyun ANA_TABLES_MACTINDX_M_INDEX, 489*4882a593Smuzhiyun QSYS_SWITCH_PORT_MODE_PORT_ENA, 490*4882a593Smuzhiyun QSYS_SWITCH_PORT_MODE_SCH_NEXT_CFG, 491*4882a593Smuzhiyun QSYS_SWITCH_PORT_MODE_YEL_RSRVD, 492*4882a593Smuzhiyun QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE, 493*4882a593Smuzhiyun QSYS_SWITCH_PORT_MODE_TX_PFC_ENA, 494*4882a593Smuzhiyun QSYS_SWITCH_PORT_MODE_TX_PFC_MODE, 495*4882a593Smuzhiyun QSYS_TIMED_FRAME_ENTRY_TFRM_VLD, 496*4882a593Smuzhiyun QSYS_TIMED_FRAME_ENTRY_TFRM_FP, 497*4882a593Smuzhiyun QSYS_TIMED_FRAME_ENTRY_TFRM_PORTNO, 498*4882a593Smuzhiyun QSYS_TIMED_FRAME_ENTRY_TFRM_TM_SEL, 499*4882a593Smuzhiyun QSYS_TIMED_FRAME_ENTRY_TFRM_TM_T, 500*4882a593Smuzhiyun SYS_PORT_MODE_DATA_WO_TS, 501*4882a593Smuzhiyun SYS_PORT_MODE_INCL_INJ_HDR, 502*4882a593Smuzhiyun SYS_PORT_MODE_INCL_XTR_HDR, 503*4882a593Smuzhiyun SYS_PORT_MODE_INCL_HDR_ERR, 504*4882a593Smuzhiyun SYS_RESET_CFG_CORE_ENA, 505*4882a593Smuzhiyun SYS_RESET_CFG_MEM_ENA, 506*4882a593Smuzhiyun SYS_RESET_CFG_MEM_INIT, 507*4882a593Smuzhiyun GCB_SOFT_RST_SWC_RST, 508*4882a593Smuzhiyun GCB_MIIM_MII_STATUS_PENDING, 509*4882a593Smuzhiyun GCB_MIIM_MII_STATUS_BUSY, 510*4882a593Smuzhiyun SYS_PAUSE_CFG_PAUSE_START, 511*4882a593Smuzhiyun SYS_PAUSE_CFG_PAUSE_STOP, 512*4882a593Smuzhiyun SYS_PAUSE_CFG_PAUSE_ENA, 513*4882a593Smuzhiyun REGFIELD_MAX 514*4882a593Smuzhiyun }; 515*4882a593Smuzhiyun 516*4882a593Smuzhiyun enum { 517*4882a593Smuzhiyun /* VCAP_CORE_CFG */ 518*4882a593Smuzhiyun VCAP_CORE_UPDATE_CTRL, 519*4882a593Smuzhiyun VCAP_CORE_MV_CFG, 520*4882a593Smuzhiyun /* VCAP_CORE_CACHE */ 521*4882a593Smuzhiyun VCAP_CACHE_ENTRY_DAT, 522*4882a593Smuzhiyun VCAP_CACHE_MASK_DAT, 523*4882a593Smuzhiyun VCAP_CACHE_ACTION_DAT, 524*4882a593Smuzhiyun VCAP_CACHE_CNT_DAT, 525*4882a593Smuzhiyun VCAP_CACHE_TG_DAT, 526*4882a593Smuzhiyun /* VCAP_CONST */ 527*4882a593Smuzhiyun VCAP_CONST_VCAP_VER, 528*4882a593Smuzhiyun VCAP_CONST_ENTRY_WIDTH, 529*4882a593Smuzhiyun VCAP_CONST_ENTRY_CNT, 530*4882a593Smuzhiyun VCAP_CONST_ENTRY_SWCNT, 531*4882a593Smuzhiyun VCAP_CONST_ENTRY_TG_WIDTH, 532*4882a593Smuzhiyun VCAP_CONST_ACTION_DEF_CNT, 533*4882a593Smuzhiyun VCAP_CONST_ACTION_WIDTH, 534*4882a593Smuzhiyun VCAP_CONST_CNT_WIDTH, 535*4882a593Smuzhiyun VCAP_CONST_CORE_CNT, 536*4882a593Smuzhiyun VCAP_CONST_IF_CNT, 537*4882a593Smuzhiyun }; 538*4882a593Smuzhiyun 539*4882a593Smuzhiyun enum ocelot_ptp_pins { 540*4882a593Smuzhiyun PTP_PIN_0, 541*4882a593Smuzhiyun PTP_PIN_1, 542*4882a593Smuzhiyun PTP_PIN_2, 543*4882a593Smuzhiyun PTP_PIN_3, 544*4882a593Smuzhiyun TOD_ACC_PIN 545*4882a593Smuzhiyun }; 546*4882a593Smuzhiyun 547*4882a593Smuzhiyun struct ocelot_stat_layout { 548*4882a593Smuzhiyun u32 offset; 549*4882a593Smuzhiyun char name[ETH_GSTRING_LEN]; 550*4882a593Smuzhiyun }; 551*4882a593Smuzhiyun 552*4882a593Smuzhiyun enum ocelot_tag_prefix { 553*4882a593Smuzhiyun OCELOT_TAG_PREFIX_DISABLED = 0, 554*4882a593Smuzhiyun OCELOT_TAG_PREFIX_NONE, 555*4882a593Smuzhiyun OCELOT_TAG_PREFIX_SHORT, 556*4882a593Smuzhiyun OCELOT_TAG_PREFIX_LONG, 557*4882a593Smuzhiyun }; 558*4882a593Smuzhiyun 559*4882a593Smuzhiyun struct ocelot; 560*4882a593Smuzhiyun 561*4882a593Smuzhiyun struct ocelot_ops { 562*4882a593Smuzhiyun struct net_device *(*port_to_netdev)(struct ocelot *ocelot, int port); 563*4882a593Smuzhiyun int (*netdev_to_port)(struct net_device *dev); 564*4882a593Smuzhiyun int (*reset)(struct ocelot *ocelot); 565*4882a593Smuzhiyun u16 (*wm_enc)(u16 value); 566*4882a593Smuzhiyun }; 567*4882a593Smuzhiyun 568*4882a593Smuzhiyun struct ocelot_vcap_block { 569*4882a593Smuzhiyun struct list_head rules; 570*4882a593Smuzhiyun int count; 571*4882a593Smuzhiyun int pol_lpr; 572*4882a593Smuzhiyun }; 573*4882a593Smuzhiyun 574*4882a593Smuzhiyun struct ocelot_port { 575*4882a593Smuzhiyun struct ocelot *ocelot; 576*4882a593Smuzhiyun 577*4882a593Smuzhiyun struct regmap *target; 578*4882a593Smuzhiyun 579*4882a593Smuzhiyun bool vlan_aware; 580*4882a593Smuzhiyun 581*4882a593Smuzhiyun /* Ingress default VLAN (pvid) */ 582*4882a593Smuzhiyun u16 pvid; 583*4882a593Smuzhiyun 584*4882a593Smuzhiyun /* Egress default VLAN (vid) */ 585*4882a593Smuzhiyun u16 vid; 586*4882a593Smuzhiyun 587*4882a593Smuzhiyun u8 ptp_cmd; 588*4882a593Smuzhiyun struct sk_buff_head tx_skbs; 589*4882a593Smuzhiyun u8 ts_id; 590*4882a593Smuzhiyun spinlock_t ts_id_lock; 591*4882a593Smuzhiyun 592*4882a593Smuzhiyun phy_interface_t phy_mode; 593*4882a593Smuzhiyun 594*4882a593Smuzhiyun u8 *xmit_template; 595*4882a593Smuzhiyun }; 596*4882a593Smuzhiyun 597*4882a593Smuzhiyun struct ocelot { 598*4882a593Smuzhiyun struct device *dev; 599*4882a593Smuzhiyun 600*4882a593Smuzhiyun const struct ocelot_ops *ops; 601*4882a593Smuzhiyun struct regmap *targets[TARGET_MAX]; 602*4882a593Smuzhiyun struct regmap_field *regfields[REGFIELD_MAX]; 603*4882a593Smuzhiyun const u32 *const *map; 604*4882a593Smuzhiyun const struct ocelot_stat_layout *stats_layout; 605*4882a593Smuzhiyun unsigned int num_stats; 606*4882a593Smuzhiyun 607*4882a593Smuzhiyun int shared_queue_sz; 608*4882a593Smuzhiyun int num_mact_rows; 609*4882a593Smuzhiyun 610*4882a593Smuzhiyun struct net_device *hw_bridge_dev; 611*4882a593Smuzhiyun u16 bridge_mask; 612*4882a593Smuzhiyun u16 bridge_fwd_mask; 613*4882a593Smuzhiyun 614*4882a593Smuzhiyun struct ocelot_port **ports; 615*4882a593Smuzhiyun 616*4882a593Smuzhiyun u8 base_mac[ETH_ALEN]; 617*4882a593Smuzhiyun 618*4882a593Smuzhiyun /* Keep track of the vlan port masks */ 619*4882a593Smuzhiyun u32 vlan_mask[VLAN_N_VID]; 620*4882a593Smuzhiyun 621*4882a593Smuzhiyun /* Switches like VSC9959 have flooding per traffic class */ 622*4882a593Smuzhiyun int num_flooding_pgids; 623*4882a593Smuzhiyun 624*4882a593Smuzhiyun /* In tables like ANA:PORT and the ANA:PGID:PGID mask, 625*4882a593Smuzhiyun * the CPU is located after the physical ports (at the 626*4882a593Smuzhiyun * num_phys_ports index). 627*4882a593Smuzhiyun */ 628*4882a593Smuzhiyun u8 num_phys_ports; 629*4882a593Smuzhiyun 630*4882a593Smuzhiyun int npi; 631*4882a593Smuzhiyun 632*4882a593Smuzhiyun enum ocelot_tag_prefix inj_prefix; 633*4882a593Smuzhiyun enum ocelot_tag_prefix xtr_prefix; 634*4882a593Smuzhiyun 635*4882a593Smuzhiyun u32 *lags; 636*4882a593Smuzhiyun 637*4882a593Smuzhiyun struct list_head multicast; 638*4882a593Smuzhiyun 639*4882a593Smuzhiyun struct list_head dummy_rules; 640*4882a593Smuzhiyun struct ocelot_vcap_block block[3]; 641*4882a593Smuzhiyun struct vcap_props *vcap; 642*4882a593Smuzhiyun 643*4882a593Smuzhiyun /* Workqueue to check statistics for overflow with its lock */ 644*4882a593Smuzhiyun struct mutex stats_lock; 645*4882a593Smuzhiyun u64 *stats; 646*4882a593Smuzhiyun struct delayed_work stats_work; 647*4882a593Smuzhiyun struct workqueue_struct *stats_queue; 648*4882a593Smuzhiyun 649*4882a593Smuzhiyun u8 ptp:1; 650*4882a593Smuzhiyun struct ptp_clock *ptp_clock; 651*4882a593Smuzhiyun struct ptp_clock_info ptp_info; 652*4882a593Smuzhiyun struct hwtstamp_config hwtstamp_config; 653*4882a593Smuzhiyun /* Protects the PTP interface state */ 654*4882a593Smuzhiyun struct mutex ptp_lock; 655*4882a593Smuzhiyun /* Protects the PTP clock */ 656*4882a593Smuzhiyun spinlock_t ptp_clock_lock; 657*4882a593Smuzhiyun struct ptp_pin_desc ptp_pins[OCELOT_PTP_PINS_NUM]; 658*4882a593Smuzhiyun }; 659*4882a593Smuzhiyun 660*4882a593Smuzhiyun struct ocelot_policer { 661*4882a593Smuzhiyun u32 rate; /* kilobit per second */ 662*4882a593Smuzhiyun u32 burst; /* bytes */ 663*4882a593Smuzhiyun }; 664*4882a593Smuzhiyun 665*4882a593Smuzhiyun #define ocelot_read_ix(ocelot, reg, gi, ri) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) 666*4882a593Smuzhiyun #define ocelot_read_gix(ocelot, reg, gi) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi)) 667*4882a593Smuzhiyun #define ocelot_read_rix(ocelot, reg, ri) __ocelot_read_ix(ocelot, reg, reg##_RSZ * (ri)) 668*4882a593Smuzhiyun #define ocelot_read(ocelot, reg) __ocelot_read_ix(ocelot, reg, 0) 669*4882a593Smuzhiyun 670*4882a593Smuzhiyun #define ocelot_write_ix(ocelot, val, reg, gi, ri) __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) 671*4882a593Smuzhiyun #define ocelot_write_gix(ocelot, val, reg, gi) __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi)) 672*4882a593Smuzhiyun #define ocelot_write_rix(ocelot, val, reg, ri) __ocelot_write_ix(ocelot, val, reg, reg##_RSZ * (ri)) 673*4882a593Smuzhiyun #define ocelot_write(ocelot, val, reg) __ocelot_write_ix(ocelot, val, reg, 0) 674*4882a593Smuzhiyun 675*4882a593Smuzhiyun #define ocelot_rmw_ix(ocelot, val, m, reg, gi, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) 676*4882a593Smuzhiyun #define ocelot_rmw_gix(ocelot, val, m, reg, gi) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi)) 677*4882a593Smuzhiyun #define ocelot_rmw_rix(ocelot, val, m, reg, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_RSZ * (ri)) 678*4882a593Smuzhiyun #define ocelot_rmw(ocelot, val, m, reg) __ocelot_rmw_ix(ocelot, val, m, reg, 0) 679*4882a593Smuzhiyun 680*4882a593Smuzhiyun #define ocelot_field_write(ocelot, reg, val) regmap_field_write((ocelot)->regfields[(reg)], (val)) 681*4882a593Smuzhiyun #define ocelot_field_read(ocelot, reg, val) regmap_field_read((ocelot)->regfields[(reg)], (val)) 682*4882a593Smuzhiyun #define ocelot_fields_write(ocelot, id, reg, val) regmap_fields_write((ocelot)->regfields[(reg)], (id), (val)) 683*4882a593Smuzhiyun #define ocelot_fields_read(ocelot, id, reg, val) regmap_fields_read((ocelot)->regfields[(reg)], (id), (val)) 684*4882a593Smuzhiyun 685*4882a593Smuzhiyun #define ocelot_target_read_ix(ocelot, target, reg, gi, ri) \ 686*4882a593Smuzhiyun __ocelot_target_read_ix(ocelot, target, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) 687*4882a593Smuzhiyun #define ocelot_target_read_gix(ocelot, target, reg, gi) \ 688*4882a593Smuzhiyun __ocelot_target_read_ix(ocelot, target, reg, reg##_GSZ * (gi)) 689*4882a593Smuzhiyun #define ocelot_target_read_rix(ocelot, target, reg, ri) \ 690*4882a593Smuzhiyun __ocelot_target_read_ix(ocelot, target, reg, reg##_RSZ * (ri)) 691*4882a593Smuzhiyun #define ocelot_target_read(ocelot, target, reg) \ 692*4882a593Smuzhiyun __ocelot_target_read_ix(ocelot, target, reg, 0) 693*4882a593Smuzhiyun 694*4882a593Smuzhiyun #define ocelot_target_write_ix(ocelot, target, val, reg, gi, ri) \ 695*4882a593Smuzhiyun __ocelot_target_write_ix(ocelot, target, val, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) 696*4882a593Smuzhiyun #define ocelot_target_write_gix(ocelot, target, val, reg, gi) \ 697*4882a593Smuzhiyun __ocelot_target_write_ix(ocelot, target, val, reg, reg##_GSZ * (gi)) 698*4882a593Smuzhiyun #define ocelot_target_write_rix(ocelot, target, val, reg, ri) \ 699*4882a593Smuzhiyun __ocelot_target_write_ix(ocelot, target, val, reg, reg##_RSZ * (ri)) 700*4882a593Smuzhiyun #define ocelot_target_write(ocelot, target, val, reg) \ 701*4882a593Smuzhiyun __ocelot_target_write_ix(ocelot, target, val, reg, 0) 702*4882a593Smuzhiyun 703*4882a593Smuzhiyun /* I/O */ 704*4882a593Smuzhiyun u32 ocelot_port_readl(struct ocelot_port *port, u32 reg); 705*4882a593Smuzhiyun void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg); 706*4882a593Smuzhiyun void ocelot_port_rmwl(struct ocelot_port *port, u32 val, u32 mask, u32 reg); 707*4882a593Smuzhiyun u32 __ocelot_read_ix(struct ocelot *ocelot, u32 reg, u32 offset); 708*4882a593Smuzhiyun void __ocelot_write_ix(struct ocelot *ocelot, u32 val, u32 reg, u32 offset); 709*4882a593Smuzhiyun void __ocelot_rmw_ix(struct ocelot *ocelot, u32 val, u32 mask, u32 reg, 710*4882a593Smuzhiyun u32 offset); 711*4882a593Smuzhiyun u32 __ocelot_target_read_ix(struct ocelot *ocelot, enum ocelot_target target, 712*4882a593Smuzhiyun u32 reg, u32 offset); 713*4882a593Smuzhiyun void __ocelot_target_write_ix(struct ocelot *ocelot, enum ocelot_target target, 714*4882a593Smuzhiyun u32 val, u32 reg, u32 offset); 715*4882a593Smuzhiyun 716*4882a593Smuzhiyun /* Hardware initialization */ 717*4882a593Smuzhiyun int ocelot_regfields_init(struct ocelot *ocelot, 718*4882a593Smuzhiyun const struct reg_field *const regfields); 719*4882a593Smuzhiyun struct regmap *ocelot_regmap_init(struct ocelot *ocelot, struct resource *res); 720*4882a593Smuzhiyun int ocelot_init(struct ocelot *ocelot); 721*4882a593Smuzhiyun void ocelot_deinit(struct ocelot *ocelot); 722*4882a593Smuzhiyun void ocelot_init_port(struct ocelot *ocelot, int port); 723*4882a593Smuzhiyun void ocelot_deinit_port(struct ocelot *ocelot, int port); 724*4882a593Smuzhiyun 725*4882a593Smuzhiyun /* DSA callbacks */ 726*4882a593Smuzhiyun void ocelot_port_enable(struct ocelot *ocelot, int port, 727*4882a593Smuzhiyun struct phy_device *phy); 728*4882a593Smuzhiyun void ocelot_port_disable(struct ocelot *ocelot, int port); 729*4882a593Smuzhiyun void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data); 730*4882a593Smuzhiyun void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data); 731*4882a593Smuzhiyun int ocelot_get_sset_count(struct ocelot *ocelot, int port, int sset); 732*4882a593Smuzhiyun int ocelot_get_ts_info(struct ocelot *ocelot, int port, 733*4882a593Smuzhiyun struct ethtool_ts_info *info); 734*4882a593Smuzhiyun void ocelot_set_ageing_time(struct ocelot *ocelot, unsigned int msecs); 735*4882a593Smuzhiyun int ocelot_port_flush(struct ocelot *ocelot, int port); 736*4882a593Smuzhiyun void ocelot_adjust_link(struct ocelot *ocelot, int port, 737*4882a593Smuzhiyun struct phy_device *phydev); 738*4882a593Smuzhiyun int ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, bool enabled, 739*4882a593Smuzhiyun struct switchdev_trans *trans); 740*4882a593Smuzhiyun void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state); 741*4882a593Smuzhiyun int ocelot_port_bridge_join(struct ocelot *ocelot, int port, 742*4882a593Smuzhiyun struct net_device *bridge); 743*4882a593Smuzhiyun int ocelot_port_bridge_leave(struct ocelot *ocelot, int port, 744*4882a593Smuzhiyun struct net_device *bridge); 745*4882a593Smuzhiyun int ocelot_fdb_dump(struct ocelot *ocelot, int port, 746*4882a593Smuzhiyun dsa_fdb_dump_cb_t *cb, void *data); 747*4882a593Smuzhiyun int ocelot_fdb_add(struct ocelot *ocelot, int port, 748*4882a593Smuzhiyun const unsigned char *addr, u16 vid); 749*4882a593Smuzhiyun int ocelot_fdb_del(struct ocelot *ocelot, int port, 750*4882a593Smuzhiyun const unsigned char *addr, u16 vid); 751*4882a593Smuzhiyun int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid, 752*4882a593Smuzhiyun bool untagged); 753*4882a593Smuzhiyun int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid); 754*4882a593Smuzhiyun int ocelot_hwstamp_get(struct ocelot *ocelot, int port, struct ifreq *ifr); 755*4882a593Smuzhiyun int ocelot_hwstamp_set(struct ocelot *ocelot, int port, struct ifreq *ifr); 756*4882a593Smuzhiyun void ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port, 757*4882a593Smuzhiyun struct sk_buff *clone); 758*4882a593Smuzhiyun void ocelot_get_txtstamp(struct ocelot *ocelot); 759*4882a593Smuzhiyun void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu); 760*4882a593Smuzhiyun int ocelot_get_max_mtu(struct ocelot *ocelot, int port); 761*4882a593Smuzhiyun int ocelot_port_policer_add(struct ocelot *ocelot, int port, 762*4882a593Smuzhiyun struct ocelot_policer *pol); 763*4882a593Smuzhiyun int ocelot_port_policer_del(struct ocelot *ocelot, int port); 764*4882a593Smuzhiyun int ocelot_cls_flower_replace(struct ocelot *ocelot, int port, 765*4882a593Smuzhiyun struct flow_cls_offload *f, bool ingress); 766*4882a593Smuzhiyun int ocelot_cls_flower_destroy(struct ocelot *ocelot, int port, 767*4882a593Smuzhiyun struct flow_cls_offload *f, bool ingress); 768*4882a593Smuzhiyun int ocelot_cls_flower_stats(struct ocelot *ocelot, int port, 769*4882a593Smuzhiyun struct flow_cls_offload *f, bool ingress); 770*4882a593Smuzhiyun int ocelot_port_mdb_add(struct ocelot *ocelot, int port, 771*4882a593Smuzhiyun const struct switchdev_obj_port_mdb *mdb); 772*4882a593Smuzhiyun int ocelot_port_mdb_del(struct ocelot *ocelot, int port, 773*4882a593Smuzhiyun const struct switchdev_obj_port_mdb *mdb); 774*4882a593Smuzhiyun 775*4882a593Smuzhiyun #endif 776