Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
0002 /*
0003  * Microsemi Ocelot Switch driver
0004  *
0005  * Copyright (c) 2017 Microsemi Corporation
0006  */
0007 
0008 #ifndef _MSCC_OCELOT_H_
0009 #define _MSCC_OCELOT_H_
0010 
0011 #include <linux/bitops.h>
0012 #include <linux/etherdevice.h>
0013 #include <linux/if_vlan.h>
0014 #include <linux/net_tstamp.h>
0015 #include <linux/phylink.h>
0016 #include <linux/platform_device.h>
0017 #include <linux/regmap.h>
0018 
0019 #include <soc/mscc/ocelot_qsys.h>
0020 #include <soc/mscc/ocelot_sys.h>
0021 #include <soc/mscc/ocelot_dev.h>
0022 #include <soc/mscc/ocelot_ana.h>
0023 #include <soc/mscc/ocelot_ptp.h>
0024 #include <soc/mscc/ocelot_vcap.h>
0025 #include <soc/mscc/ocelot.h>
0026 #include "ocelot_rew.h"
0027 #include "ocelot_qs.h"
0028 
0029 #define OCELOT_STANDALONE_PVID 0
0030 #define OCELOT_BUFFER_CELL_SZ 60
0031 
0032 #define OCELOT_STATS_CHECK_DELAY (2 * HZ)
0033 
0034 #define OCELOT_PTP_QUEUE_SZ 128
0035 
0036 #define OCELOT_JUMBO_MTU    9000
0037 
0038 struct ocelot_port_tc {
0039     bool block_shared;
0040     unsigned long offload_cnt;
0041     unsigned long ingress_mirred_id;
0042     unsigned long egress_mirred_id;
0043     unsigned long police_id;
0044 };
0045 
0046 struct ocelot_port_private {
0047     struct ocelot_port port;
0048     struct net_device *dev;
0049     struct phylink *phylink;
0050     struct phylink_config phylink_config;
0051     struct ocelot_port_tc tc;
0052 };
0053 
0054 struct ocelot_dump_ctx {
0055     struct net_device *dev;
0056     struct sk_buff *skb;
0057     struct netlink_callback *cb;
0058     int idx;
0059 };
0060 
0061 /* A (PGID) port mask structure, encoding the 2^ocelot->num_phys_ports
0062  * possibilities of egress port masks for L2 multicast traffic.
0063  * For a switch with 9 user ports, there are 512 possible port masks, but the
0064  * hardware only has 46 individual PGIDs that it can forward multicast traffic
0065  * to. So we need a structure that maps the limited PGID indices to the port
0066  * destinations requested by the user for L2 multicast.
0067  */
0068 struct ocelot_pgid {
0069     unsigned long ports;
0070     int index;
0071     refcount_t refcount;
0072     struct list_head list;
0073 };
0074 
0075 struct ocelot_multicast {
0076     struct list_head list;
0077     enum macaccess_entry_type entry_type;
0078     unsigned char addr[ETH_ALEN];
0079     u16 vid;
0080     u16 ports;
0081     struct ocelot_pgid *pgid;
0082 };
0083 
0084 int ocelot_bridge_num_find(struct ocelot *ocelot,
0085                const struct net_device *bridge);
0086 
0087 int ocelot_port_fdb_do_dump(const unsigned char *addr, u16 vid,
0088                 bool is_static, void *data);
0089 int ocelot_mact_learn(struct ocelot *ocelot, int port,
0090               const unsigned char mac[ETH_ALEN],
0091               unsigned int vid, enum macaccess_entry_type type);
0092 int ocelot_mact_forget(struct ocelot *ocelot,
0093                const unsigned char mac[ETH_ALEN], unsigned int vid);
0094 struct net_device *ocelot_port_to_netdev(struct ocelot *ocelot, int port);
0095 int ocelot_netdev_to_port(struct net_device *dev);
0096 
0097 u32 ocelot_port_readl(struct ocelot_port *port, u32 reg);
0098 void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);
0099 
0100 int ocelot_probe_port(struct ocelot *ocelot, int port, struct regmap *target,
0101               struct device_node *portnp);
0102 void ocelot_release_port(struct ocelot_port *ocelot_port);
0103 int ocelot_devlink_init(struct ocelot *ocelot);
0104 void ocelot_devlink_teardown(struct ocelot *ocelot);
0105 int ocelot_port_devlink_init(struct ocelot *ocelot, int port,
0106                  enum devlink_port_flavour flavour);
0107 void ocelot_port_devlink_teardown(struct ocelot *ocelot, int port);
0108 
0109 int ocelot_trap_add(struct ocelot *ocelot, int port,
0110             unsigned long cookie, bool take_ts,
0111             void (*populate)(struct ocelot_vcap_filter *f));
0112 int ocelot_trap_del(struct ocelot *ocelot, int port, unsigned long cookie);
0113 
0114 struct ocelot_mirror *ocelot_mirror_get(struct ocelot *ocelot, int to,
0115                     struct netlink_ext_ack *extack);
0116 void ocelot_mirror_put(struct ocelot *ocelot);
0117 
0118 extern struct notifier_block ocelot_netdevice_nb;
0119 extern struct notifier_block ocelot_switchdev_nb;
0120 extern struct notifier_block ocelot_switchdev_blocking_nb;
0121 extern const struct devlink_ops ocelot_devlink_ops;
0122 
0123 #endif