Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: mscc: ocelot: publish structure definitions to include/soc/mscc/ocelot.h

We will be registering another switch driver based on ocelot, which
lives under drivers/net/dsa.

Make sure the Felix DSA front-end has the necessary abstractions to
implement a new Ocelot driver instantiation. This includes the function
prototypes for implementing DSA callbacks.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vladimir Oltean and committed by
David S. Miller
5e256365 3a77b593

+588 -511
+46 -32
drivers/net/ethernet/mscc/ocelot.c
··· 21 21 #include <net/netevent.h> 22 22 #include <net/rtnetlink.h> 23 23 #include <net/switchdev.h> 24 - #include <net/dsa.h> 25 24 26 25 #include "ocelot.h" 27 26 #include "ocelot_ace.h" ··· 183 184 ocelot_write(ocelot, val, ANA_VLANMASK); 184 185 } 185 186 186 - static void ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, 187 - bool vlan_aware) 187 + void ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, 188 + bool vlan_aware) 188 189 { 189 190 struct ocelot_port *ocelot_port = ocelot->ports[port]; 190 191 u32 val; ··· 229 230 REW_TAG_CFG_TAG_CFG_M, 230 231 REW_TAG_CFG, port); 231 232 } 233 + EXPORT_SYMBOL(ocelot_port_vlan_filtering); 232 234 233 235 static int ocelot_port_set_native_vlan(struct ocelot *ocelot, int port, 234 236 u16 vid) ··· 267 267 ocelot_port->pvid = pvid; 268 268 } 269 269 270 - static int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid, 271 - bool untagged) 270 + int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid, 271 + bool untagged) 272 272 { 273 273 int ret; 274 274 ··· 291 291 292 292 return 0; 293 293 } 294 + EXPORT_SYMBOL(ocelot_vlan_add); 294 295 295 296 static int ocelot_vlan_vid_add(struct net_device *dev, u16 vid, bool pvid, 296 297 bool untagged) ··· 313 312 return 0; 314 313 } 315 314 316 - static int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid) 315 + int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid) 317 316 { 318 317 struct ocelot_port *ocelot_port = ocelot->ports[port]; 319 318 int ret; ··· 334 333 335 334 return 0; 336 335 } 336 + EXPORT_SYMBOL(ocelot_vlan_del); 337 337 338 338 static int ocelot_vlan_vid_del(struct net_device *dev, u16 vid) 339 339 { ··· 406 404 return value; 407 405 } 408 406 409 - static void ocelot_adjust_link(struct ocelot *ocelot, int port, 410 - struct phy_device *phydev) 407 + void ocelot_adjust_link(struct ocelot *ocelot, int port, 408 + struct phy_device *phydev) 411 409 { 412 410 struct ocelot_port *ocelot_port = ocelot->ports[port]; 413 411 int speed, mode = 0; ··· 473 471 SYS_MAC_FC_CFG, port); 474 472 ocelot_write_rix(ocelot, 0, ANA_POL_FLOWC, port); 475 473 } 474 + EXPORT_SYMBOL(ocelot_adjust_link); 476 475 477 476 static void ocelot_port_adjust_link(struct net_device *dev) 478 477 { ··· 484 481 ocelot_adjust_link(ocelot, port, dev->phydev); 485 482 } 486 483 487 - static void ocelot_port_enable(struct ocelot *ocelot, int port, 488 - struct phy_device *phy) 484 + void ocelot_port_enable(struct ocelot *ocelot, int port, 485 + struct phy_device *phy) 489 486 { 490 487 /* Enable receiving frames on the port, and activate auto-learning of 491 488 * MAC addresses. ··· 495 492 ANA_PORT_PORT_CFG_PORTID_VAL(port), 496 493 ANA_PORT_PORT_CFG, port); 497 494 } 495 + EXPORT_SYMBOL(ocelot_port_enable); 498 496 499 497 static int ocelot_port_open(struct net_device *dev) 500 498 { ··· 530 526 return 0; 531 527 } 532 528 533 - static void ocelot_port_disable(struct ocelot *ocelot, int port) 529 + void ocelot_port_disable(struct ocelot *ocelot, int port) 534 530 { 535 531 struct ocelot_port *ocelot_port = ocelot->ports[port]; 536 532 ··· 538 534 ocelot_rmw_rix(ocelot, 0, QSYS_SWITCH_PORT_MODE_PORT_ENA, 539 535 QSYS_SWITCH_PORT_MODE, port); 540 536 } 537 + EXPORT_SYMBOL(ocelot_port_disable); 541 538 542 539 static int ocelot_port_stop(struct net_device *dev) 543 540 { ··· 795 790 stats->collisions = ocelot_read(ocelot, SYS_COUNT_TX_COLLISION); 796 791 } 797 792 798 - static int ocelot_fdb_add(struct ocelot *ocelot, int port, 799 - const unsigned char *addr, u16 vid, 800 - bool vlan_aware) 793 + int ocelot_fdb_add(struct ocelot *ocelot, int port, 794 + const unsigned char *addr, u16 vid, bool vlan_aware) 801 795 { 802 796 struct ocelot_port *ocelot_port = ocelot->ports[port]; 803 797 ··· 816 812 817 813 return ocelot_mact_learn(ocelot, port, addr, vid, ENTRYTYPE_LOCKED); 818 814 } 815 + EXPORT_SYMBOL(ocelot_fdb_add); 819 816 820 817 static int ocelot_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], 821 818 struct net_device *dev, ··· 831 826 return ocelot_fdb_add(ocelot, port, addr, vid, priv->vlan_aware); 832 827 } 833 828 834 - static int ocelot_fdb_del(struct ocelot *ocelot, int port, 835 - const unsigned char *addr, u16 vid) 829 + int ocelot_fdb_del(struct ocelot *ocelot, int port, 830 + const unsigned char *addr, u16 vid) 836 831 { 837 832 return ocelot_mact_forget(ocelot, addr, vid); 838 833 } 834 + EXPORT_SYMBOL(ocelot_fdb_del); 839 835 840 836 static int ocelot_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], 841 837 struct net_device *dev, ··· 946 940 return 0; 947 941 } 948 942 949 - static int ocelot_fdb_dump(struct ocelot *ocelot, int port, 950 - dsa_fdb_dump_cb_t *cb, void *data) 943 + int ocelot_fdb_dump(struct ocelot *ocelot, int port, 944 + dsa_fdb_dump_cb_t *cb, void *data) 951 945 { 952 946 int i, j; 953 947 ··· 979 973 980 974 return 0; 981 975 } 976 + EXPORT_SYMBOL(ocelot_fdb_dump); 982 977 983 978 static int ocelot_port_fdb_dump(struct sk_buff *skb, 984 979 struct netlink_callback *cb, ··· 1160 1153 .ndo_do_ioctl = ocelot_ioctl, 1161 1154 }; 1162 1155 1163 - static void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, 1164 - u8 *data) 1156 + void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data) 1165 1157 { 1166 1158 int i; 1167 1159 ··· 1171 1165 memcpy(data + i * ETH_GSTRING_LEN, ocelot->stats_layout[i].name, 1172 1166 ETH_GSTRING_LEN); 1173 1167 } 1168 + EXPORT_SYMBOL(ocelot_get_strings); 1174 1169 1175 1170 static void ocelot_port_get_strings(struct net_device *netdev, u32 sset, 1176 1171 u8 *data) ··· 1223 1216 OCELOT_STATS_CHECK_DELAY); 1224 1217 } 1225 1218 1226 - static void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data) 1219 + void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data) 1227 1220 { 1228 1221 int i; 1229 1222 ··· 1234 1227 for (i = 0; i < ocelot->num_stats; i++) 1235 1228 *data++ = ocelot->stats[port * ocelot->num_stats + i]; 1236 1229 } 1230 + EXPORT_SYMBOL(ocelot_get_ethtool_stats); 1237 1231 1238 1232 static void ocelot_port_get_ethtool_stats(struct net_device *dev, 1239 1233 struct ethtool_stats *stats, ··· 1247 1239 ocelot_get_ethtool_stats(ocelot, port, data); 1248 1240 } 1249 1241 1250 - static int ocelot_get_sset_count(struct ocelot *ocelot, int port, int sset) 1242 + int ocelot_get_sset_count(struct ocelot *ocelot, int port, int sset) 1251 1243 { 1252 1244 if (sset != ETH_SS_STATS) 1253 1245 return -EOPNOTSUPP; 1254 1246 1255 1247 return ocelot->num_stats; 1256 1248 } 1249 + EXPORT_SYMBOL(ocelot_get_sset_count); 1257 1250 1258 1251 static int ocelot_port_get_sset_count(struct net_device *dev, int sset) 1259 1252 { ··· 1265 1256 return ocelot_get_sset_count(ocelot, port, sset); 1266 1257 } 1267 1258 1268 - static int ocelot_get_ts_info(struct ocelot *ocelot, int port, 1269 - struct ethtool_ts_info *info) 1259 + int ocelot_get_ts_info(struct ocelot *ocelot, int port, 1260 + struct ethtool_ts_info *info) 1270 1261 { 1271 1262 info->phc_index = ocelot->ptp_clock ? 1272 1263 ptp_clock_index(ocelot->ptp_clock) : -1; ··· 1282 1273 1283 1274 return 0; 1284 1275 } 1276 + EXPORT_SYMBOL(ocelot_get_ts_info); 1285 1277 1286 1278 static int ocelot_port_get_ts_info(struct net_device *dev, 1287 1279 struct ethtool_ts_info *info) ··· 1306 1296 .get_ts_info = ocelot_port_get_ts_info, 1307 1297 }; 1308 1298 1309 - static void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, 1310 - u8 state) 1299 + void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state) 1311 1300 { 1312 1301 u32 port_cfg; 1313 1302 int p, i; ··· 1367 1358 } 1368 1359 } 1369 1360 } 1361 + EXPORT_SYMBOL(ocelot_bridge_stp_state_set); 1370 1362 1371 1363 static void ocelot_port_attr_stp_state_set(struct ocelot *ocelot, int port, 1372 1364 struct switchdev_trans *trans, ··· 1379 1369 ocelot_bridge_stp_state_set(ocelot, port, state); 1380 1370 } 1381 1371 1382 - static void ocelot_set_ageing_time(struct ocelot *ocelot, unsigned int msecs) 1372 + void ocelot_set_ageing_time(struct ocelot *ocelot, unsigned int msecs) 1383 1373 { 1384 1374 ocelot_write(ocelot, ANA_AUTOAGE_AGE_PERIOD(msecs / 2), 1385 1375 ANA_AUTOAGE); 1386 1376 } 1377 + EXPORT_SYMBOL(ocelot_set_ageing_time); 1387 1378 1388 1379 static void ocelot_port_attr_ageing_set(struct ocelot *ocelot, int port, 1389 1380 unsigned long ageing_clock_t) ··· 1615 1604 return ret; 1616 1605 } 1617 1606 1618 - static int ocelot_port_bridge_join(struct ocelot *ocelot, int port, 1619 - struct net_device *bridge) 1607 + int ocelot_port_bridge_join(struct ocelot *ocelot, int port, 1608 + struct net_device *bridge) 1620 1609 { 1621 1610 if (!ocelot->bridge_mask) { 1622 1611 ocelot->hw_bridge_dev = bridge; ··· 1631 1620 1632 1621 return 0; 1633 1622 } 1623 + EXPORT_SYMBOL(ocelot_port_bridge_join); 1634 1624 1635 - static int ocelot_port_bridge_leave(struct ocelot *ocelot, int port, 1636 - struct net_device *bridge) 1625 + int ocelot_port_bridge_leave(struct ocelot *ocelot, int port, 1626 + struct net_device *bridge) 1637 1627 { 1638 1628 ocelot->bridge_mask &= ~BIT(port); 1639 1629 ··· 1645 1633 ocelot_port_set_pvid(ocelot, port, 0); 1646 1634 return ocelot_port_set_native_vlan(ocelot, port, 0); 1647 1635 } 1636 + EXPORT_SYMBOL(ocelot_port_bridge_leave); 1648 1637 1649 1638 static void ocelot_set_aggr_pgids(struct ocelot *ocelot) 1650 1639 { ··· 2132 2119 ocelot_write(ocelot, ocelot_wm_enc(atop_wm), SYS_ATOP_TOT_CFG); 2133 2120 } 2134 2121 2135 - static void ocelot_init_port(struct ocelot *ocelot, int port) 2122 + void ocelot_init_port(struct ocelot *ocelot, int port) 2136 2123 { 2137 2124 struct ocelot_port *ocelot_port = ocelot->ports[port]; 2138 2125 ··· 2179 2166 /* Enable vcap lookups */ 2180 2167 ocelot_vcap_enable(ocelot, port); 2181 2168 } 2169 + EXPORT_SYMBOL(ocelot_init_port); 2182 2170 2183 2171 int ocelot_probe_port(struct ocelot *ocelot, u8 port, 2184 2172 void __iomem *regs,
+3 -479
drivers/net/ethernet/mscc/ocelot.h
··· 18 18 #include <linux/ptp_clock_kernel.h> 19 19 #include <linux/regmap.h> 20 20 21 + #include <soc/mscc/ocelot.h> 21 22 #include "ocelot_ana.h" 22 23 #include "ocelot_dev.h" 23 24 #include "ocelot_qsys.h" ··· 53 52 u32 timestamp; /* rew_val */ 54 53 }; 55 54 56 - #define IFH_INJ_BYPASS BIT(31) 57 - #define IFH_INJ_POP_CNT_DISABLE (3 << 28) 58 - 59 - #define IFH_TAG_TYPE_C 0 60 - #define IFH_TAG_TYPE_S 1 61 - 62 - #define IFH_REW_OP_NOOP 0x0 63 - #define IFH_REW_OP_DSCP 0x1 64 - #define IFH_REW_OP_ONE_STEP_PTP 0x2 65 - #define IFH_REW_OP_TWO_STEP_PTP 0x3 66 - #define IFH_REW_OP_ORIGIN_PTP 0x5 67 - 68 - #define OCELOT_TAG_LEN 16 69 - #define OCELOT_SHORT_PREFIX_LEN 4 70 - #define OCELOT_LONG_PREFIX_LEN 16 71 - 72 - #define OCELOT_SPEED_2500 0 73 - #define OCELOT_SPEED_1000 1 74 - #define OCELOT_SPEED_100 2 75 - #define OCELOT_SPEED_10 3 76 - 77 - #define TARGET_OFFSET 24 78 - #define REG_MASK GENMASK(TARGET_OFFSET - 1, 0) 79 - #define REG(reg, offset) [reg & REG_MASK] = offset 80 - 81 - enum ocelot_target { 82 - ANA = 1, 83 - QS, 84 - QSYS, 85 - REW, 86 - SYS, 87 - S2, 88 - HSIO, 89 - PTP, 90 - TARGET_MAX, 91 - }; 92 - 93 - enum ocelot_reg { 94 - ANA_ADVLEARN = ANA << TARGET_OFFSET, 95 - ANA_VLANMASK, 96 - ANA_PORT_B_DOMAIN, 97 - ANA_ANAGEFIL, 98 - ANA_ANEVENTS, 99 - ANA_STORMLIMIT_BURST, 100 - ANA_STORMLIMIT_CFG, 101 - ANA_ISOLATED_PORTS, 102 - ANA_COMMUNITY_PORTS, 103 - ANA_AUTOAGE, 104 - ANA_MACTOPTIONS, 105 - ANA_LEARNDISC, 106 - ANA_AGENCTRL, 107 - ANA_MIRRORPORTS, 108 - ANA_EMIRRORPORTS, 109 - ANA_FLOODING, 110 - ANA_FLOODING_IPMC, 111 - ANA_SFLOW_CFG, 112 - ANA_PORT_MODE, 113 - ANA_CUT_THRU_CFG, 114 - ANA_PGID_PGID, 115 - ANA_TABLES_ANMOVED, 116 - ANA_TABLES_MACHDATA, 117 - ANA_TABLES_MACLDATA, 118 - ANA_TABLES_STREAMDATA, 119 - ANA_TABLES_MACACCESS, 120 - ANA_TABLES_MACTINDX, 121 - ANA_TABLES_VLANACCESS, 122 - ANA_TABLES_VLANTIDX, 123 - ANA_TABLES_ISDXACCESS, 124 - ANA_TABLES_ISDXTIDX, 125 - ANA_TABLES_ENTRYLIM, 126 - ANA_TABLES_PTP_ID_HIGH, 127 - ANA_TABLES_PTP_ID_LOW, 128 - ANA_TABLES_STREAMACCESS, 129 - ANA_TABLES_STREAMTIDX, 130 - ANA_TABLES_SEQ_HISTORY, 131 - ANA_TABLES_SEQ_MASK, 132 - ANA_TABLES_SFID_MASK, 133 - ANA_TABLES_SFIDACCESS, 134 - ANA_TABLES_SFIDTIDX, 135 - ANA_MSTI_STATE, 136 - ANA_OAM_UPM_LM_CNT, 137 - ANA_SG_ACCESS_CTRL, 138 - ANA_SG_CONFIG_REG_1, 139 - ANA_SG_CONFIG_REG_2, 140 - ANA_SG_CONFIG_REG_3, 141 - ANA_SG_CONFIG_REG_4, 142 - ANA_SG_CONFIG_REG_5, 143 - ANA_SG_GCL_GS_CONFIG, 144 - ANA_SG_GCL_TI_CONFIG, 145 - ANA_SG_STATUS_REG_1, 146 - ANA_SG_STATUS_REG_2, 147 - ANA_SG_STATUS_REG_3, 148 - ANA_PORT_VLAN_CFG, 149 - ANA_PORT_DROP_CFG, 150 - ANA_PORT_QOS_CFG, 151 - ANA_PORT_VCAP_CFG, 152 - ANA_PORT_VCAP_S1_KEY_CFG, 153 - ANA_PORT_VCAP_S2_CFG, 154 - ANA_PORT_PCP_DEI_MAP, 155 - ANA_PORT_CPU_FWD_CFG, 156 - ANA_PORT_CPU_FWD_BPDU_CFG, 157 - ANA_PORT_CPU_FWD_GARP_CFG, 158 - ANA_PORT_CPU_FWD_CCM_CFG, 159 - ANA_PORT_PORT_CFG, 160 - ANA_PORT_POL_CFG, 161 - ANA_PORT_PTP_CFG, 162 - ANA_PORT_PTP_DLY1_CFG, 163 - ANA_PORT_PTP_DLY2_CFG, 164 - ANA_PORT_SFID_CFG, 165 - ANA_PFC_PFC_CFG, 166 - ANA_PFC_PFC_TIMER, 167 - ANA_IPT_OAM_MEP_CFG, 168 - ANA_IPT_IPT, 169 - ANA_PPT_PPT, 170 - ANA_FID_MAP_FID_MAP, 171 - ANA_AGGR_CFG, 172 - ANA_CPUQ_CFG, 173 - ANA_CPUQ_CFG2, 174 - ANA_CPUQ_8021_CFG, 175 - ANA_DSCP_CFG, 176 - ANA_DSCP_REWR_CFG, 177 - ANA_VCAP_RNG_TYPE_CFG, 178 - ANA_VCAP_RNG_VAL_CFG, 179 - ANA_VRAP_CFG, 180 - ANA_VRAP_HDR_DATA, 181 - ANA_VRAP_HDR_MASK, 182 - ANA_DISCARD_CFG, 183 - ANA_FID_CFG, 184 - ANA_POL_PIR_CFG, 185 - ANA_POL_CIR_CFG, 186 - ANA_POL_MODE_CFG, 187 - ANA_POL_PIR_STATE, 188 - ANA_POL_CIR_STATE, 189 - ANA_POL_STATE, 190 - ANA_POL_FLOWC, 191 - ANA_POL_HYST, 192 - ANA_POL_MISC_CFG, 193 - QS_XTR_GRP_CFG = QS << TARGET_OFFSET, 194 - QS_XTR_RD, 195 - QS_XTR_FRM_PRUNING, 196 - QS_XTR_FLUSH, 197 - QS_XTR_DATA_PRESENT, 198 - QS_XTR_CFG, 199 - QS_INJ_GRP_CFG, 200 - QS_INJ_WR, 201 - QS_INJ_CTRL, 202 - QS_INJ_STATUS, 203 - QS_INJ_ERR, 204 - QS_INH_DBG, 205 - QSYS_PORT_MODE = QSYS << TARGET_OFFSET, 206 - QSYS_SWITCH_PORT_MODE, 207 - QSYS_STAT_CNT_CFG, 208 - QSYS_EEE_CFG, 209 - QSYS_EEE_THRES, 210 - QSYS_IGR_NO_SHARING, 211 - QSYS_EGR_NO_SHARING, 212 - QSYS_SW_STATUS, 213 - QSYS_EXT_CPU_CFG, 214 - QSYS_PAD_CFG, 215 - QSYS_CPU_GROUP_MAP, 216 - QSYS_QMAP, 217 - QSYS_ISDX_SGRP, 218 - QSYS_TIMED_FRAME_ENTRY, 219 - QSYS_TFRM_MISC, 220 - QSYS_TFRM_PORT_DLY, 221 - QSYS_TFRM_TIMER_CFG_1, 222 - QSYS_TFRM_TIMER_CFG_2, 223 - QSYS_TFRM_TIMER_CFG_3, 224 - QSYS_TFRM_TIMER_CFG_4, 225 - QSYS_TFRM_TIMER_CFG_5, 226 - QSYS_TFRM_TIMER_CFG_6, 227 - QSYS_TFRM_TIMER_CFG_7, 228 - QSYS_TFRM_TIMER_CFG_8, 229 - QSYS_RED_PROFILE, 230 - QSYS_RES_QOS_MODE, 231 - QSYS_RES_CFG, 232 - QSYS_RES_STAT, 233 - QSYS_EGR_DROP_MODE, 234 - QSYS_EQ_CTRL, 235 - QSYS_EVENTS_CORE, 236 - QSYS_QMAXSDU_CFG_0, 237 - QSYS_QMAXSDU_CFG_1, 238 - QSYS_QMAXSDU_CFG_2, 239 - QSYS_QMAXSDU_CFG_3, 240 - QSYS_QMAXSDU_CFG_4, 241 - QSYS_QMAXSDU_CFG_5, 242 - QSYS_QMAXSDU_CFG_6, 243 - QSYS_QMAXSDU_CFG_7, 244 - QSYS_PREEMPTION_CFG, 245 - QSYS_CIR_CFG, 246 - QSYS_EIR_CFG, 247 - QSYS_SE_CFG, 248 - QSYS_SE_DWRR_CFG, 249 - QSYS_SE_CONNECT, 250 - QSYS_SE_DLB_SENSE, 251 - QSYS_CIR_STATE, 252 - QSYS_EIR_STATE, 253 - QSYS_SE_STATE, 254 - QSYS_HSCH_MISC_CFG, 255 - QSYS_TAG_CONFIG, 256 - QSYS_TAS_PARAM_CFG_CTRL, 257 - QSYS_PORT_MAX_SDU, 258 - QSYS_PARAM_CFG_REG_1, 259 - QSYS_PARAM_CFG_REG_2, 260 - QSYS_PARAM_CFG_REG_3, 261 - QSYS_PARAM_CFG_REG_4, 262 - QSYS_PARAM_CFG_REG_5, 263 - QSYS_GCL_CFG_REG_1, 264 - QSYS_GCL_CFG_REG_2, 265 - QSYS_PARAM_STATUS_REG_1, 266 - QSYS_PARAM_STATUS_REG_2, 267 - QSYS_PARAM_STATUS_REG_3, 268 - QSYS_PARAM_STATUS_REG_4, 269 - QSYS_PARAM_STATUS_REG_5, 270 - QSYS_PARAM_STATUS_REG_6, 271 - QSYS_PARAM_STATUS_REG_7, 272 - QSYS_PARAM_STATUS_REG_8, 273 - QSYS_PARAM_STATUS_REG_9, 274 - QSYS_GCL_STATUS_REG_1, 275 - QSYS_GCL_STATUS_REG_2, 276 - REW_PORT_VLAN_CFG = REW << TARGET_OFFSET, 277 - REW_TAG_CFG, 278 - REW_PORT_CFG, 279 - REW_DSCP_CFG, 280 - REW_PCP_DEI_QOS_MAP_CFG, 281 - REW_PTP_CFG, 282 - REW_PTP_DLY1_CFG, 283 - REW_RED_TAG_CFG, 284 - REW_DSCP_REMAP_DP1_CFG, 285 - REW_DSCP_REMAP_CFG, 286 - REW_STAT_CFG, 287 - REW_REW_STICKY, 288 - REW_PPT, 289 - SYS_COUNT_RX_OCTETS = SYS << TARGET_OFFSET, 290 - SYS_COUNT_RX_UNICAST, 291 - SYS_COUNT_RX_MULTICAST, 292 - SYS_COUNT_RX_BROADCAST, 293 - SYS_COUNT_RX_SHORTS, 294 - SYS_COUNT_RX_FRAGMENTS, 295 - SYS_COUNT_RX_JABBERS, 296 - SYS_COUNT_RX_CRC_ALIGN_ERRS, 297 - SYS_COUNT_RX_SYM_ERRS, 298 - SYS_COUNT_RX_64, 299 - SYS_COUNT_RX_65_127, 300 - SYS_COUNT_RX_128_255, 301 - SYS_COUNT_RX_256_1023, 302 - SYS_COUNT_RX_1024_1526, 303 - SYS_COUNT_RX_1527_MAX, 304 - SYS_COUNT_RX_PAUSE, 305 - SYS_COUNT_RX_CONTROL, 306 - SYS_COUNT_RX_LONGS, 307 - SYS_COUNT_RX_CLASSIFIED_DROPS, 308 - SYS_COUNT_TX_OCTETS, 309 - SYS_COUNT_TX_UNICAST, 310 - SYS_COUNT_TX_MULTICAST, 311 - SYS_COUNT_TX_BROADCAST, 312 - SYS_COUNT_TX_COLLISION, 313 - SYS_COUNT_TX_DROPS, 314 - SYS_COUNT_TX_PAUSE, 315 - SYS_COUNT_TX_64, 316 - SYS_COUNT_TX_65_127, 317 - SYS_COUNT_TX_128_511, 318 - SYS_COUNT_TX_512_1023, 319 - SYS_COUNT_TX_1024_1526, 320 - SYS_COUNT_TX_1527_MAX, 321 - SYS_COUNT_TX_AGING, 322 - SYS_RESET_CFG, 323 - SYS_SR_ETYPE_CFG, 324 - SYS_VLAN_ETYPE_CFG, 325 - SYS_PORT_MODE, 326 - SYS_FRONT_PORT_MODE, 327 - SYS_FRM_AGING, 328 - SYS_STAT_CFG, 329 - SYS_SW_STATUS, 330 - SYS_MISC_CFG, 331 - SYS_REW_MAC_HIGH_CFG, 332 - SYS_REW_MAC_LOW_CFG, 333 - SYS_TIMESTAMP_OFFSET, 334 - SYS_CMID, 335 - SYS_PAUSE_CFG, 336 - SYS_PAUSE_TOT_CFG, 337 - SYS_ATOP, 338 - SYS_ATOP_TOT_CFG, 339 - SYS_MAC_FC_CFG, 340 - SYS_MMGT, 341 - SYS_MMGT_FAST, 342 - SYS_EVENTS_DIF, 343 - SYS_EVENTS_CORE, 344 - SYS_CNT, 345 - SYS_PTP_STATUS, 346 - SYS_PTP_TXSTAMP, 347 - SYS_PTP_NXT, 348 - SYS_PTP_CFG, 349 - SYS_RAM_INIT, 350 - SYS_CM_ADDR, 351 - SYS_CM_DATA_WR, 352 - SYS_CM_DATA_RD, 353 - SYS_CM_OP, 354 - SYS_CM_DATA, 355 - S2_CORE_UPDATE_CTRL = S2 << TARGET_OFFSET, 356 - S2_CORE_MV_CFG, 357 - S2_CACHE_ENTRY_DAT, 358 - S2_CACHE_MASK_DAT, 359 - S2_CACHE_ACTION_DAT, 360 - S2_CACHE_CNT_DAT, 361 - S2_CACHE_TG_DAT, 362 - PTP_PIN_CFG = PTP << TARGET_OFFSET, 363 - PTP_PIN_TOD_SEC_MSB, 364 - PTP_PIN_TOD_SEC_LSB, 365 - PTP_PIN_TOD_NSEC, 366 - PTP_CFG_MISC, 367 - PTP_CLK_CFG_ADJ_CFG, 368 - PTP_CLK_CFG_ADJ_FREQ, 369 - }; 370 - 371 - enum ocelot_regfield { 372 - ANA_ADVLEARN_VLAN_CHK, 373 - ANA_ADVLEARN_LEARN_MIRROR, 374 - ANA_ANEVENTS_FLOOD_DISCARD, 375 - ANA_ANEVENTS_MSTI_DROP, 376 - ANA_ANEVENTS_ACLKILL, 377 - ANA_ANEVENTS_ACLUSED, 378 - ANA_ANEVENTS_AUTOAGE, 379 - ANA_ANEVENTS_VS2TTL1, 380 - ANA_ANEVENTS_STORM_DROP, 381 - ANA_ANEVENTS_LEARN_DROP, 382 - ANA_ANEVENTS_AGED_ENTRY, 383 - ANA_ANEVENTS_CPU_LEARN_FAILED, 384 - ANA_ANEVENTS_AUTO_LEARN_FAILED, 385 - ANA_ANEVENTS_LEARN_REMOVE, 386 - ANA_ANEVENTS_AUTO_LEARNED, 387 - ANA_ANEVENTS_AUTO_MOVED, 388 - ANA_ANEVENTS_DROPPED, 389 - ANA_ANEVENTS_CLASSIFIED_DROP, 390 - ANA_ANEVENTS_CLASSIFIED_COPY, 391 - ANA_ANEVENTS_VLAN_DISCARD, 392 - ANA_ANEVENTS_FWD_DISCARD, 393 - ANA_ANEVENTS_MULTICAST_FLOOD, 394 - ANA_ANEVENTS_UNICAST_FLOOD, 395 - ANA_ANEVENTS_DEST_KNOWN, 396 - ANA_ANEVENTS_BUCKET3_MATCH, 397 - ANA_ANEVENTS_BUCKET2_MATCH, 398 - ANA_ANEVENTS_BUCKET1_MATCH, 399 - ANA_ANEVENTS_BUCKET0_MATCH, 400 - ANA_ANEVENTS_CPU_OPERATION, 401 - ANA_ANEVENTS_DMAC_LOOKUP, 402 - ANA_ANEVENTS_SMAC_LOOKUP, 403 - ANA_ANEVENTS_SEQ_GEN_ERR_0, 404 - ANA_ANEVENTS_SEQ_GEN_ERR_1, 405 - ANA_TABLES_MACACCESS_B_DOM, 406 - ANA_TABLES_MACTINDX_BUCKET, 407 - ANA_TABLES_MACTINDX_M_INDEX, 408 - QSYS_TIMED_FRAME_ENTRY_TFRM_VLD, 409 - QSYS_TIMED_FRAME_ENTRY_TFRM_FP, 410 - QSYS_TIMED_FRAME_ENTRY_TFRM_PORTNO, 411 - QSYS_TIMED_FRAME_ENTRY_TFRM_TM_SEL, 412 - QSYS_TIMED_FRAME_ENTRY_TFRM_TM_T, 413 - SYS_RESET_CFG_CORE_ENA, 414 - SYS_RESET_CFG_MEM_ENA, 415 - SYS_RESET_CFG_MEM_INIT, 416 - REGFIELD_MAX 417 - }; 418 - 419 - enum ocelot_clk_pins { 420 - ALT_PPS_PIN = 1, 421 - EXT_CLK_PIN, 422 - ALT_LDST_PIN, 423 - TOD_ACC_PIN 424 - }; 425 - 426 55 struct ocelot_multicast { 427 56 struct list_head list; 428 57 unsigned char addr[ETH_ALEN]; 429 58 u16 vid; 430 59 u16 ports; 431 - }; 432 - 433 - enum ocelot_tag_prefix { 434 - OCELOT_TAG_PREFIX_DISABLED = 0, 435 - OCELOT_TAG_PREFIX_NONE, 436 - OCELOT_TAG_PREFIX_SHORT, 437 - OCELOT_TAG_PREFIX_LONG, 438 - }; 439 - 440 - struct ocelot_port; 441 - struct ocelot; 442 - 443 - struct ocelot_stat_layout { 444 - u32 offset; 445 - char name[ETH_GSTRING_LEN]; 446 - }; 447 - 448 - struct ocelot_ops { 449 - void (*pcs_init)(struct ocelot *ocelot, int port); 450 - int (*reset)(struct ocelot *ocelot); 451 - }; 452 - 453 - struct ocelot { 454 - const struct ocelot_ops *ops; 455 - struct device *dev; 456 - 457 - struct regmap *targets[TARGET_MAX]; 458 - struct regmap_field *regfields[REGFIELD_MAX]; 459 - const u32 *const *map; 460 - const struct ocelot_stat_layout *stats_layout; 461 - unsigned int num_stats; 462 - 463 - u8 base_mac[ETH_ALEN]; 464 - 465 - struct net_device *hw_bridge_dev; 466 - u16 bridge_mask; 467 - u16 bridge_fwd_mask; 468 - 469 - struct workqueue_struct *ocelot_owq; 470 - 471 - int shared_queue_sz; 472 - 473 - u8 num_phys_ports; 474 - u8 num_cpu_ports; 475 - u8 cpu; 476 - struct ocelot_port **ports; 477 - 478 - u32 *lags; 479 - 480 - /* Keep track of the vlan port masks */ 481 - u32 vlan_mask[VLAN_N_VID]; 482 - 483 - struct list_head multicast; 484 - 485 - /* Workqueue to check statistics for overflow with its lock */ 486 - struct mutex stats_lock; 487 - u64 *stats; 488 - struct delayed_work stats_work; 489 - struct workqueue_struct *stats_queue; 490 - 491 - u8 ptp:1; 492 - struct ptp_clock *ptp_clock; 493 - struct ptp_clock_info ptp_info; 494 - struct hwtstamp_config hwtstamp_config; 495 - struct mutex ptp_lock; /* Protects the PTP interface state */ 496 - spinlock_t ptp_clock_lock; /* Protects the PTP clock */ 497 - }; 498 - 499 - struct ocelot_port { 500 - struct ocelot *ocelot; 501 - 502 - void __iomem *regs; 503 - 504 - /* Ingress default VLAN (pvid) */ 505 - u16 pvid; 506 - 507 - /* Egress default VLAN (vid) */ 508 - u16 vid; 509 - 510 - u8 ptp_cmd; 511 - struct list_head skbs; 512 - u8 ts_id; 513 60 }; 514 61 515 62 struct ocelot_port_private { ··· 80 531 u8 id; 81 532 }; 82 533 83 - u32 __ocelot_read_ix(struct ocelot *ocelot, u32 reg, u32 offset); 84 - #define ocelot_read_ix(ocelot, reg, gi, ri) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) 85 - #define ocelot_read_gix(ocelot, reg, gi) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi)) 86 - #define ocelot_read_rix(ocelot, reg, ri) __ocelot_read_ix(ocelot, reg, reg##_RSZ * (ri)) 87 - #define ocelot_read(ocelot, reg) __ocelot_read_ix(ocelot, reg, 0) 88 - 89 - void __ocelot_write_ix(struct ocelot *ocelot, u32 val, u32 reg, u32 offset); 90 - #define ocelot_write_ix(ocelot, val, reg, gi, ri) __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) 91 - #define ocelot_write_gix(ocelot, val, reg, gi) __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi)) 92 - #define ocelot_write_rix(ocelot, val, reg, ri) __ocelot_write_ix(ocelot, val, reg, reg##_RSZ * (ri)) 93 - #define ocelot_write(ocelot, val, reg) __ocelot_write_ix(ocelot, val, reg, 0) 94 - 95 - void __ocelot_rmw_ix(struct ocelot *ocelot, u32 val, u32 mask, u32 reg, 96 - u32 offset); 97 - #define ocelot_rmw_ix(ocelot, val, m, reg, gi, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) 98 - #define ocelot_rmw_gix(ocelot, val, m, reg, gi) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi)) 99 - #define ocelot_rmw_rix(ocelot, val, m, reg, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_RSZ * (ri)) 100 - #define ocelot_rmw(ocelot, val, m, reg) __ocelot_rmw_ix(ocelot, val, m, reg, 0) 101 - 102 534 u32 ocelot_port_readl(struct ocelot_port *port, u32 reg); 103 535 void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg); 104 - 105 - int ocelot_regfields_init(struct ocelot *ocelot, 106 - const struct reg_field *const regfields); 107 - struct regmap *ocelot_regmap_init(struct ocelot *ocelot, struct resource *res); 108 536 109 537 #define ocelot_field_write(ocelot, reg, val) regmap_field_write((ocelot)->regfields[(reg)], (val)) 110 538 #define ocelot_field_read(ocelot, reg, val) regmap_field_read((ocelot)->regfields[(reg)], (val)) 111 539 112 - int ocelot_init(struct ocelot *ocelot); 113 - void ocelot_deinit(struct ocelot *ocelot); 114 540 int ocelot_chip_init(struct ocelot *ocelot, const struct ocelot_ops *ops); 115 541 int ocelot_probe_port(struct ocelot *ocelot, u8 port, 116 542 void __iomem *regs, ··· 99 575 extern struct notifier_block ocelot_switchdev_nb; 100 576 extern struct notifier_block ocelot_switchdev_blocking_nb; 101 577 102 - int ocelot_ptp_gettime64(struct ptp_clock_info *ptp, struct timespec64 *ts); 103 - void ocelot_get_hwtimestamp(struct ocelot *ocelot, struct timespec64 *ts); 578 + #define ocelot_field_write(ocelot, reg, val) regmap_field_write((ocelot)->regfields[(reg)], (val)) 579 + #define ocelot_field_read(ocelot, reg, val) regmap_field_read((ocelot)->regfields[(reg)], (val)) 104 580 105 581 #endif
+539
include/soc/mscc/ocelot.h
··· 1 + /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */ 2 + /* Copyright (c) 2017 Microsemi Corporation 3 + */ 4 + 5 + #ifndef _SOC_MSCC_OCELOT_H 6 + #define _SOC_MSCC_OCELOT_H 7 + 8 + #include <linux/ptp_clock_kernel.h> 9 + #include <linux/net_tstamp.h> 10 + #include <linux/if_vlan.h> 11 + #include <linux/regmap.h> 12 + #include <net/dsa.h> 13 + 14 + #define IFH_INJ_BYPASS BIT(31) 15 + #define IFH_INJ_POP_CNT_DISABLE (3 << 28) 16 + 17 + #define IFH_TAG_TYPE_C 0 18 + #define IFH_TAG_TYPE_S 1 19 + 20 + #define IFH_REW_OP_NOOP 0x0 21 + #define IFH_REW_OP_DSCP 0x1 22 + #define IFH_REW_OP_ONE_STEP_PTP 0x2 23 + #define IFH_REW_OP_TWO_STEP_PTP 0x3 24 + #define IFH_REW_OP_ORIGIN_PTP 0x5 25 + 26 + #define OCELOT_TAG_LEN 16 27 + #define OCELOT_SHORT_PREFIX_LEN 4 28 + #define OCELOT_LONG_PREFIX_LEN 16 29 + 30 + #define OCELOT_SPEED_2500 0 31 + #define OCELOT_SPEED_1000 1 32 + #define OCELOT_SPEED_100 2 33 + #define OCELOT_SPEED_10 3 34 + 35 + #define TARGET_OFFSET 24 36 + #define REG_MASK GENMASK(TARGET_OFFSET - 1, 0) 37 + #define REG(reg, offset) [reg & REG_MASK] = offset 38 + 39 + #define REG_RESERVED_ADDR 0xffffffff 40 + #define REG_RESERVED(reg) REG(reg, REG_RESERVED_ADDR) 41 + 42 + enum ocelot_target { 43 + ANA = 1, 44 + QS, 45 + QSYS, 46 + REW, 47 + SYS, 48 + S2, 49 + HSIO, 50 + PTP, 51 + GCB, 52 + TARGET_MAX, 53 + }; 54 + 55 + enum ocelot_reg { 56 + ANA_ADVLEARN = ANA << TARGET_OFFSET, 57 + ANA_VLANMASK, 58 + ANA_PORT_B_DOMAIN, 59 + ANA_ANAGEFIL, 60 + ANA_ANEVENTS, 61 + ANA_STORMLIMIT_BURST, 62 + ANA_STORMLIMIT_CFG, 63 + ANA_ISOLATED_PORTS, 64 + ANA_COMMUNITY_PORTS, 65 + ANA_AUTOAGE, 66 + ANA_MACTOPTIONS, 67 + ANA_LEARNDISC, 68 + ANA_AGENCTRL, 69 + ANA_MIRRORPORTS, 70 + ANA_EMIRRORPORTS, 71 + ANA_FLOODING, 72 + ANA_FLOODING_IPMC, 73 + ANA_SFLOW_CFG, 74 + ANA_PORT_MODE, 75 + ANA_CUT_THRU_CFG, 76 + ANA_PGID_PGID, 77 + ANA_TABLES_ANMOVED, 78 + ANA_TABLES_MACHDATA, 79 + ANA_TABLES_MACLDATA, 80 + ANA_TABLES_STREAMDATA, 81 + ANA_TABLES_MACACCESS, 82 + ANA_TABLES_MACTINDX, 83 + ANA_TABLES_VLANACCESS, 84 + ANA_TABLES_VLANTIDX, 85 + ANA_TABLES_ISDXACCESS, 86 + ANA_TABLES_ISDXTIDX, 87 + ANA_TABLES_ENTRYLIM, 88 + ANA_TABLES_PTP_ID_HIGH, 89 + ANA_TABLES_PTP_ID_LOW, 90 + ANA_TABLES_STREAMACCESS, 91 + ANA_TABLES_STREAMTIDX, 92 + ANA_TABLES_SEQ_HISTORY, 93 + ANA_TABLES_SEQ_MASK, 94 + ANA_TABLES_SFID_MASK, 95 + ANA_TABLES_SFIDACCESS, 96 + ANA_TABLES_SFIDTIDX, 97 + ANA_MSTI_STATE, 98 + ANA_OAM_UPM_LM_CNT, 99 + ANA_SG_ACCESS_CTRL, 100 + ANA_SG_CONFIG_REG_1, 101 + ANA_SG_CONFIG_REG_2, 102 + ANA_SG_CONFIG_REG_3, 103 + ANA_SG_CONFIG_REG_4, 104 + ANA_SG_CONFIG_REG_5, 105 + ANA_SG_GCL_GS_CONFIG, 106 + ANA_SG_GCL_TI_CONFIG, 107 + ANA_SG_STATUS_REG_1, 108 + ANA_SG_STATUS_REG_2, 109 + ANA_SG_STATUS_REG_3, 110 + ANA_PORT_VLAN_CFG, 111 + ANA_PORT_DROP_CFG, 112 + ANA_PORT_QOS_CFG, 113 + ANA_PORT_VCAP_CFG, 114 + ANA_PORT_VCAP_S1_KEY_CFG, 115 + ANA_PORT_VCAP_S2_CFG, 116 + ANA_PORT_PCP_DEI_MAP, 117 + ANA_PORT_CPU_FWD_CFG, 118 + ANA_PORT_CPU_FWD_BPDU_CFG, 119 + ANA_PORT_CPU_FWD_GARP_CFG, 120 + ANA_PORT_CPU_FWD_CCM_CFG, 121 + ANA_PORT_PORT_CFG, 122 + ANA_PORT_POL_CFG, 123 + ANA_PORT_PTP_CFG, 124 + ANA_PORT_PTP_DLY1_CFG, 125 + ANA_PORT_PTP_DLY2_CFG, 126 + ANA_PORT_SFID_CFG, 127 + ANA_PFC_PFC_CFG, 128 + ANA_PFC_PFC_TIMER, 129 + ANA_IPT_OAM_MEP_CFG, 130 + ANA_IPT_IPT, 131 + ANA_PPT_PPT, 132 + ANA_FID_MAP_FID_MAP, 133 + ANA_AGGR_CFG, 134 + ANA_CPUQ_CFG, 135 + ANA_CPUQ_CFG2, 136 + ANA_CPUQ_8021_CFG, 137 + ANA_DSCP_CFG, 138 + ANA_DSCP_REWR_CFG, 139 + ANA_VCAP_RNG_TYPE_CFG, 140 + ANA_VCAP_RNG_VAL_CFG, 141 + ANA_VRAP_CFG, 142 + ANA_VRAP_HDR_DATA, 143 + ANA_VRAP_HDR_MASK, 144 + ANA_DISCARD_CFG, 145 + ANA_FID_CFG, 146 + ANA_POL_PIR_CFG, 147 + ANA_POL_CIR_CFG, 148 + ANA_POL_MODE_CFG, 149 + ANA_POL_PIR_STATE, 150 + ANA_POL_CIR_STATE, 151 + ANA_POL_STATE, 152 + ANA_POL_FLOWC, 153 + ANA_POL_HYST, 154 + ANA_POL_MISC_CFG, 155 + QS_XTR_GRP_CFG = QS << TARGET_OFFSET, 156 + QS_XTR_RD, 157 + QS_XTR_FRM_PRUNING, 158 + QS_XTR_FLUSH, 159 + QS_XTR_DATA_PRESENT, 160 + QS_XTR_CFG, 161 + QS_INJ_GRP_CFG, 162 + QS_INJ_WR, 163 + QS_INJ_CTRL, 164 + QS_INJ_STATUS, 165 + QS_INJ_ERR, 166 + QS_INH_DBG, 167 + QSYS_PORT_MODE = QSYS << TARGET_OFFSET, 168 + QSYS_SWITCH_PORT_MODE, 169 + QSYS_STAT_CNT_CFG, 170 + QSYS_EEE_CFG, 171 + QSYS_EEE_THRES, 172 + QSYS_IGR_NO_SHARING, 173 + QSYS_EGR_NO_SHARING, 174 + QSYS_SW_STATUS, 175 + QSYS_EXT_CPU_CFG, 176 + QSYS_PAD_CFG, 177 + QSYS_CPU_GROUP_MAP, 178 + QSYS_QMAP, 179 + QSYS_ISDX_SGRP, 180 + QSYS_TIMED_FRAME_ENTRY, 181 + QSYS_TFRM_MISC, 182 + QSYS_TFRM_PORT_DLY, 183 + QSYS_TFRM_TIMER_CFG_1, 184 + QSYS_TFRM_TIMER_CFG_2, 185 + QSYS_TFRM_TIMER_CFG_3, 186 + QSYS_TFRM_TIMER_CFG_4, 187 + QSYS_TFRM_TIMER_CFG_5, 188 + QSYS_TFRM_TIMER_CFG_6, 189 + QSYS_TFRM_TIMER_CFG_7, 190 + QSYS_TFRM_TIMER_CFG_8, 191 + QSYS_RED_PROFILE, 192 + QSYS_RES_QOS_MODE, 193 + QSYS_RES_CFG, 194 + QSYS_RES_STAT, 195 + QSYS_EGR_DROP_MODE, 196 + QSYS_EQ_CTRL, 197 + QSYS_EVENTS_CORE, 198 + QSYS_QMAXSDU_CFG_0, 199 + QSYS_QMAXSDU_CFG_1, 200 + QSYS_QMAXSDU_CFG_2, 201 + QSYS_QMAXSDU_CFG_3, 202 + QSYS_QMAXSDU_CFG_4, 203 + QSYS_QMAXSDU_CFG_5, 204 + QSYS_QMAXSDU_CFG_6, 205 + QSYS_QMAXSDU_CFG_7, 206 + QSYS_PREEMPTION_CFG, 207 + QSYS_CIR_CFG, 208 + QSYS_EIR_CFG, 209 + QSYS_SE_CFG, 210 + QSYS_SE_DWRR_CFG, 211 + QSYS_SE_CONNECT, 212 + QSYS_SE_DLB_SENSE, 213 + QSYS_CIR_STATE, 214 + QSYS_EIR_STATE, 215 + QSYS_SE_STATE, 216 + QSYS_HSCH_MISC_CFG, 217 + QSYS_TAG_CONFIG, 218 + QSYS_TAS_PARAM_CFG_CTRL, 219 + QSYS_PORT_MAX_SDU, 220 + QSYS_PARAM_CFG_REG_1, 221 + QSYS_PARAM_CFG_REG_2, 222 + QSYS_PARAM_CFG_REG_3, 223 + QSYS_PARAM_CFG_REG_4, 224 + QSYS_PARAM_CFG_REG_5, 225 + QSYS_GCL_CFG_REG_1, 226 + QSYS_GCL_CFG_REG_2, 227 + QSYS_PARAM_STATUS_REG_1, 228 + QSYS_PARAM_STATUS_REG_2, 229 + QSYS_PARAM_STATUS_REG_3, 230 + QSYS_PARAM_STATUS_REG_4, 231 + QSYS_PARAM_STATUS_REG_5, 232 + QSYS_PARAM_STATUS_REG_6, 233 + QSYS_PARAM_STATUS_REG_7, 234 + QSYS_PARAM_STATUS_REG_8, 235 + QSYS_PARAM_STATUS_REG_9, 236 + QSYS_GCL_STATUS_REG_1, 237 + QSYS_GCL_STATUS_REG_2, 238 + REW_PORT_VLAN_CFG = REW << TARGET_OFFSET, 239 + REW_TAG_CFG, 240 + REW_PORT_CFG, 241 + REW_DSCP_CFG, 242 + REW_PCP_DEI_QOS_MAP_CFG, 243 + REW_PTP_CFG, 244 + REW_PTP_DLY1_CFG, 245 + REW_RED_TAG_CFG, 246 + REW_DSCP_REMAP_DP1_CFG, 247 + REW_DSCP_REMAP_CFG, 248 + REW_STAT_CFG, 249 + REW_REW_STICKY, 250 + REW_PPT, 251 + SYS_COUNT_RX_OCTETS = SYS << TARGET_OFFSET, 252 + SYS_COUNT_RX_UNICAST, 253 + SYS_COUNT_RX_MULTICAST, 254 + SYS_COUNT_RX_BROADCAST, 255 + SYS_COUNT_RX_SHORTS, 256 + SYS_COUNT_RX_FRAGMENTS, 257 + SYS_COUNT_RX_JABBERS, 258 + SYS_COUNT_RX_CRC_ALIGN_ERRS, 259 + SYS_COUNT_RX_SYM_ERRS, 260 + SYS_COUNT_RX_64, 261 + SYS_COUNT_RX_65_127, 262 + SYS_COUNT_RX_128_255, 263 + SYS_COUNT_RX_256_1023, 264 + SYS_COUNT_RX_1024_1526, 265 + SYS_COUNT_RX_1527_MAX, 266 + SYS_COUNT_RX_PAUSE, 267 + SYS_COUNT_RX_CONTROL, 268 + SYS_COUNT_RX_LONGS, 269 + SYS_COUNT_RX_CLASSIFIED_DROPS, 270 + SYS_COUNT_TX_OCTETS, 271 + SYS_COUNT_TX_UNICAST, 272 + SYS_COUNT_TX_MULTICAST, 273 + SYS_COUNT_TX_BROADCAST, 274 + SYS_COUNT_TX_COLLISION, 275 + SYS_COUNT_TX_DROPS, 276 + SYS_COUNT_TX_PAUSE, 277 + SYS_COUNT_TX_64, 278 + SYS_COUNT_TX_65_127, 279 + SYS_COUNT_TX_128_511, 280 + SYS_COUNT_TX_512_1023, 281 + SYS_COUNT_TX_1024_1526, 282 + SYS_COUNT_TX_1527_MAX, 283 + SYS_COUNT_TX_AGING, 284 + SYS_RESET_CFG, 285 + SYS_SR_ETYPE_CFG, 286 + SYS_VLAN_ETYPE_CFG, 287 + SYS_PORT_MODE, 288 + SYS_FRONT_PORT_MODE, 289 + SYS_FRM_AGING, 290 + SYS_STAT_CFG, 291 + SYS_SW_STATUS, 292 + SYS_MISC_CFG, 293 + SYS_REW_MAC_HIGH_CFG, 294 + SYS_REW_MAC_LOW_CFG, 295 + SYS_TIMESTAMP_OFFSET, 296 + SYS_CMID, 297 + SYS_PAUSE_CFG, 298 + SYS_PAUSE_TOT_CFG, 299 + SYS_ATOP, 300 + SYS_ATOP_TOT_CFG, 301 + SYS_MAC_FC_CFG, 302 + SYS_MMGT, 303 + SYS_MMGT_FAST, 304 + SYS_EVENTS_DIF, 305 + SYS_EVENTS_CORE, 306 + SYS_CNT, 307 + SYS_PTP_STATUS, 308 + SYS_PTP_TXSTAMP, 309 + SYS_PTP_NXT, 310 + SYS_PTP_CFG, 311 + SYS_RAM_INIT, 312 + SYS_CM_ADDR, 313 + SYS_CM_DATA_WR, 314 + SYS_CM_DATA_RD, 315 + SYS_CM_OP, 316 + SYS_CM_DATA, 317 + S2_CORE_UPDATE_CTRL = S2 << TARGET_OFFSET, 318 + S2_CORE_MV_CFG, 319 + S2_CACHE_ENTRY_DAT, 320 + S2_CACHE_MASK_DAT, 321 + S2_CACHE_ACTION_DAT, 322 + S2_CACHE_CNT_DAT, 323 + S2_CACHE_TG_DAT, 324 + PTP_PIN_CFG = PTP << TARGET_OFFSET, 325 + PTP_PIN_TOD_SEC_MSB, 326 + PTP_PIN_TOD_SEC_LSB, 327 + PTP_PIN_TOD_NSEC, 328 + PTP_CFG_MISC, 329 + PTP_CLK_CFG_ADJ_CFG, 330 + PTP_CLK_CFG_ADJ_FREQ, 331 + GCB_SOFT_RST = GCB << TARGET_OFFSET, 332 + }; 333 + 334 + enum ocelot_regfield { 335 + ANA_ADVLEARN_VLAN_CHK, 336 + ANA_ADVLEARN_LEARN_MIRROR, 337 + ANA_ANEVENTS_FLOOD_DISCARD, 338 + ANA_ANEVENTS_MSTI_DROP, 339 + ANA_ANEVENTS_ACLKILL, 340 + ANA_ANEVENTS_ACLUSED, 341 + ANA_ANEVENTS_AUTOAGE, 342 + ANA_ANEVENTS_VS2TTL1, 343 + ANA_ANEVENTS_STORM_DROP, 344 + ANA_ANEVENTS_LEARN_DROP, 345 + ANA_ANEVENTS_AGED_ENTRY, 346 + ANA_ANEVENTS_CPU_LEARN_FAILED, 347 + ANA_ANEVENTS_AUTO_LEARN_FAILED, 348 + ANA_ANEVENTS_LEARN_REMOVE, 349 + ANA_ANEVENTS_AUTO_LEARNED, 350 + ANA_ANEVENTS_AUTO_MOVED, 351 + ANA_ANEVENTS_DROPPED, 352 + ANA_ANEVENTS_CLASSIFIED_DROP, 353 + ANA_ANEVENTS_CLASSIFIED_COPY, 354 + ANA_ANEVENTS_VLAN_DISCARD, 355 + ANA_ANEVENTS_FWD_DISCARD, 356 + ANA_ANEVENTS_MULTICAST_FLOOD, 357 + ANA_ANEVENTS_UNICAST_FLOOD, 358 + ANA_ANEVENTS_DEST_KNOWN, 359 + ANA_ANEVENTS_BUCKET3_MATCH, 360 + ANA_ANEVENTS_BUCKET2_MATCH, 361 + ANA_ANEVENTS_BUCKET1_MATCH, 362 + ANA_ANEVENTS_BUCKET0_MATCH, 363 + ANA_ANEVENTS_CPU_OPERATION, 364 + ANA_ANEVENTS_DMAC_LOOKUP, 365 + ANA_ANEVENTS_SMAC_LOOKUP, 366 + ANA_ANEVENTS_SEQ_GEN_ERR_0, 367 + ANA_ANEVENTS_SEQ_GEN_ERR_1, 368 + ANA_TABLES_MACACCESS_B_DOM, 369 + ANA_TABLES_MACTINDX_BUCKET, 370 + ANA_TABLES_MACTINDX_M_INDEX, 371 + QSYS_TIMED_FRAME_ENTRY_TFRM_VLD, 372 + QSYS_TIMED_FRAME_ENTRY_TFRM_FP, 373 + QSYS_TIMED_FRAME_ENTRY_TFRM_PORTNO, 374 + QSYS_TIMED_FRAME_ENTRY_TFRM_TM_SEL, 375 + QSYS_TIMED_FRAME_ENTRY_TFRM_TM_T, 376 + SYS_RESET_CFG_CORE_ENA, 377 + SYS_RESET_CFG_MEM_ENA, 378 + SYS_RESET_CFG_MEM_INIT, 379 + GCB_SOFT_RST_SWC_RST, 380 + REGFIELD_MAX 381 + }; 382 + 383 + enum ocelot_clk_pins { 384 + ALT_PPS_PIN = 1, 385 + EXT_CLK_PIN, 386 + ALT_LDST_PIN, 387 + TOD_ACC_PIN 388 + }; 389 + 390 + struct ocelot_stat_layout { 391 + u32 offset; 392 + char name[ETH_GSTRING_LEN]; 393 + }; 394 + 395 + enum ocelot_tag_prefix { 396 + OCELOT_TAG_PREFIX_DISABLED = 0, 397 + OCELOT_TAG_PREFIX_NONE, 398 + OCELOT_TAG_PREFIX_SHORT, 399 + OCELOT_TAG_PREFIX_LONG, 400 + }; 401 + 402 + struct ocelot; 403 + 404 + struct ocelot_ops { 405 + void (*pcs_init)(struct ocelot *ocelot, int port); 406 + int (*reset)(struct ocelot *ocelot); 407 + }; 408 + 409 + struct ocelot_port { 410 + struct ocelot *ocelot; 411 + 412 + void __iomem *regs; 413 + 414 + /* Ingress default VLAN (pvid) */ 415 + u16 pvid; 416 + 417 + /* Egress default VLAN (vid) */ 418 + u16 vid; 419 + 420 + u8 ptp_cmd; 421 + struct list_head skbs; 422 + u8 ts_id; 423 + }; 424 + 425 + struct ocelot { 426 + struct device *dev; 427 + 428 + const struct ocelot_ops *ops; 429 + struct regmap *targets[TARGET_MAX]; 430 + struct regmap_field *regfields[REGFIELD_MAX]; 431 + const u32 *const *map; 432 + const struct ocelot_stat_layout *stats_layout; 433 + unsigned int num_stats; 434 + 435 + int shared_queue_sz; 436 + 437 + struct net_device *hw_bridge_dev; 438 + u16 bridge_mask; 439 + u16 bridge_fwd_mask; 440 + 441 + struct ocelot_port **ports; 442 + 443 + u8 base_mac[ETH_ALEN]; 444 + 445 + /* Keep track of the vlan port masks */ 446 + u32 vlan_mask[VLAN_N_VID]; 447 + 448 + u8 num_phys_ports; 449 + u8 num_cpu_ports; 450 + u8 cpu; 451 + 452 + u32 *lags; 453 + 454 + struct list_head multicast; 455 + 456 + /* Workqueue to check statistics for overflow with its lock */ 457 + struct mutex stats_lock; 458 + u64 *stats; 459 + struct delayed_work stats_work; 460 + struct workqueue_struct *stats_queue; 461 + 462 + u8 ptp:1; 463 + struct ptp_clock *ptp_clock; 464 + struct ptp_clock_info ptp_info; 465 + struct hwtstamp_config hwtstamp_config; 466 + /* Protects the PTP interface state */ 467 + struct mutex ptp_lock; 468 + /* Protects the PTP clock */ 469 + spinlock_t ptp_clock_lock; 470 + 471 + void (*port_pcs_init)(struct ocelot_port *port); 472 + }; 473 + 474 + #define ocelot_read_ix(ocelot, reg, gi, ri) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) 475 + #define ocelot_read_gix(ocelot, reg, gi) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi)) 476 + #define ocelot_read_rix(ocelot, reg, ri) __ocelot_read_ix(ocelot, reg, reg##_RSZ * (ri)) 477 + #define ocelot_read(ocelot, reg) __ocelot_read_ix(ocelot, reg, 0) 478 + 479 + #define ocelot_write_ix(ocelot, val, reg, gi, ri) __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) 480 + #define ocelot_write_gix(ocelot, val, reg, gi) __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi)) 481 + #define ocelot_write_rix(ocelot, val, reg, ri) __ocelot_write_ix(ocelot, val, reg, reg##_RSZ * (ri)) 482 + #define ocelot_write(ocelot, val, reg) __ocelot_write_ix(ocelot, val, reg, 0) 483 + 484 + #define ocelot_rmw_ix(ocelot, val, m, reg, gi, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) 485 + #define ocelot_rmw_gix(ocelot, val, m, reg, gi) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi)) 486 + #define ocelot_rmw_rix(ocelot, val, m, reg, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_RSZ * (ri)) 487 + #define ocelot_rmw(ocelot, val, m, reg) __ocelot_rmw_ix(ocelot, val, m, reg, 0) 488 + 489 + /* I/O */ 490 + u32 ocelot_port_readl(struct ocelot_port *port, u32 reg); 491 + void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg); 492 + u32 __ocelot_read_ix(struct ocelot *ocelot, u32 reg, u32 offset); 493 + void __ocelot_write_ix(struct ocelot *ocelot, u32 val, u32 reg, u32 offset); 494 + void __ocelot_rmw_ix(struct ocelot *ocelot, u32 val, u32 mask, u32 reg, 495 + u32 offset); 496 + 497 + /* Hardware initialization */ 498 + int ocelot_regfields_init(struct ocelot *ocelot, 499 + const struct reg_field *const regfields); 500 + struct regmap *ocelot_regmap_init(struct ocelot *ocelot, struct resource *res); 501 + void ocelot_set_cpu_port(struct ocelot *ocelot, int cpu, 502 + enum ocelot_tag_prefix injection, 503 + enum ocelot_tag_prefix extraction); 504 + int ocelot_init(struct ocelot *ocelot); 505 + void ocelot_deinit(struct ocelot *ocelot); 506 + void ocelot_init_port(struct ocelot *ocelot, int port); 507 + 508 + /* DSA callbacks */ 509 + void ocelot_port_enable(struct ocelot *ocelot, int port, 510 + struct phy_device *phy); 511 + void ocelot_port_disable(struct ocelot *ocelot, int port); 512 + void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data); 513 + void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data); 514 + int ocelot_get_sset_count(struct ocelot *ocelot, int port, int sset); 515 + int ocelot_get_ts_info(struct ocelot *ocelot, int port, 516 + struct ethtool_ts_info *info); 517 + void ocelot_set_ageing_time(struct ocelot *ocelot, unsigned int msecs); 518 + void ocelot_adjust_link(struct ocelot *ocelot, int port, 519 + struct phy_device *phydev); 520 + void ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, 521 + bool vlan_aware); 522 + void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state); 523 + int ocelot_port_bridge_join(struct ocelot *ocelot, int port, 524 + struct net_device *bridge); 525 + int ocelot_port_bridge_leave(struct ocelot *ocelot, int port, 526 + struct net_device *bridge); 527 + int ocelot_fdb_dump(struct ocelot *ocelot, int port, 528 + dsa_fdb_dump_cb_t *cb, void *data); 529 + int ocelot_fdb_add(struct ocelot *ocelot, int port, 530 + const unsigned char *addr, u16 vid, bool vlan_aware); 531 + int ocelot_fdb_del(struct ocelot *ocelot, int port, 532 + const unsigned char *addr, u16 vid); 533 + int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid, 534 + bool untagged); 535 + int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid); 536 + int ocelot_ptp_gettime64(struct ptp_clock_info *ptp, struct timespec64 *ts); 537 + void ocelot_get_hwtimestamp(struct ocelot *ocelot, struct timespec64 *ts); 538 + 539 + #endif