1 /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
3 * Microsemi Ocelot Switch driver
5 * Copyright (c) 2017 Microsemi Corporation
8 #ifndef _MSCC_OCELOT_H_
9 #define _MSCC_OCELOT_H_
11 #include <linux/bitops.h>
12 #include <linux/etherdevice.h>
13 #include <linux/if_vlan.h>
14 #include <linux/net_tstamp.h>
15 #include <linux/phy.h>
16 #include <linux/phy/phy.h>
17 #include <linux/platform_device.h>
18 #include <linux/regmap.h>
20 #include <soc/mscc/ocelot_qsys.h>
21 #include <soc/mscc/ocelot_sys.h>
22 #include <soc/mscc/ocelot_dev.h>
23 #include <soc/mscc/ocelot_ana.h>
24 #include <soc/mscc/ocelot_ptp.h>
25 #include <soc/mscc/ocelot.h>
26 #include "ocelot_rew.h"
27 #include "ocelot_qs.h"
29 #define OCELOT_BUFFER_CELL_SZ 60
31 #define OCELOT_STATS_CHECK_DELAY (2 * HZ)
33 #define OCELOT_PTP_QUEUE_SZ 128
41 u32 timestamp; /* rew_val */
44 struct ocelot_multicast {
45 struct list_head list;
46 unsigned char addr[ETH_ALEN];
52 struct ocelot_port_tc {
54 unsigned long offload_cnt;
56 unsigned long police_id;
59 struct ocelot_port_private {
60 struct ocelot_port port;
61 struct net_device *dev;
62 struct phy_device *phy;
67 struct ocelot_port_tc tc;
70 struct ocelot_dump_ctx {
71 struct net_device *dev;
73 struct netlink_callback *cb;
77 /* MAC table entry types.
78 * ENTRYTYPE_NORMAL is subject to aging.
79 * ENTRYTYPE_LOCKED is not subject to aging.
80 * ENTRYTYPE_MACv4 is not subject to aging. For IPv4 multicast.
81 * ENTRYTYPE_MACv6 is not subject to aging. For IPv6 multicast.
83 enum macaccess_entry_type {
90 int ocelot_port_fdb_do_dump(const unsigned char *addr, u16 vid,
91 bool is_static, void *data);
92 int ocelot_mact_learn(struct ocelot *ocelot, int port,
93 const unsigned char mac[ETH_ALEN],
94 unsigned int vid, enum macaccess_entry_type type);
95 int ocelot_mact_forget(struct ocelot *ocelot,
96 const unsigned char mac[ETH_ALEN], unsigned int vid);
97 int ocelot_port_lag_join(struct ocelot *ocelot, int port,
98 struct net_device *bond);
99 void ocelot_port_lag_leave(struct ocelot *ocelot, int port,
100 struct net_device *bond);
102 u32 ocelot_port_readl(struct ocelot_port *port, u32 reg);
103 void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);
105 int ocelot_probe_port(struct ocelot *ocelot, int port, struct regmap *target,
106 struct phy_device *phy);
108 void ocelot_set_cpu_port(struct ocelot *ocelot, int cpu,
109 enum ocelot_tag_prefix injection,
110 enum ocelot_tag_prefix extraction);
112 extern struct notifier_block ocelot_netdevice_nb;
113 extern struct notifier_block ocelot_switchdev_nb;
114 extern struct notifier_block ocelot_switchdev_blocking_nb;