Linux Audio

Check our new training course

Loading...
v6.13.7
  1/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
  2/*
  3 * Microsemi Ocelot Switch driver
  4 *
  5 * Copyright (c) 2017 Microsemi Corporation
  6 */
  7
  8#ifndef _MSCC_OCELOT_H_
  9#define _MSCC_OCELOT_H_
 10
 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/phylink.h>
 
 16#include <linux/platform_device.h>
 17#include <linux/regmap.h>
 18
 19#include <soc/mscc/ocelot_qsys.h>
 20#include <soc/mscc/ocelot_sys.h>
 21#include <soc/mscc/ocelot_dev.h>
 22#include <soc/mscc/ocelot_ana.h>
 23#include <soc/mscc/ocelot_ptp.h>
 24#include <soc/mscc/ocelot_vcap.h>
 25#include <soc/mscc/ocelot.h>
 26#include "ocelot_rew.h"
 27#include "ocelot_qs.h"
 28
 29#define OCELOT_STANDALONE_PVID 0
 30#define OCELOT_BUFFER_CELL_SZ 60
 31
 32#define OCELOT_STATS_CHECK_DELAY (2 * HZ)
 33
 34#define OCELOT_PTP_QUEUE_SZ	128
 35
 36#define OCELOT_JUMBO_MTU	9000
 37
 38struct ocelot_port_tc {
 39	bool block_shared;
 40	unsigned long offload_cnt;
 41	unsigned long ingress_mirred_id;
 42	unsigned long egress_mirred_id;
 43	unsigned long police_id;
 44};
 45
 46struct ocelot_port_private {
 47	struct ocelot_port port;
 48	struct net_device *dev;
 49	struct phylink *phylink;
 50	struct phylink_config phylink_config;
 
 
 
 51	struct ocelot_port_tc tc;
 52};
 53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 54/* A (PGID) port mask structure, encoding the 2^ocelot->num_phys_ports
 55 * possibilities of egress port masks for L2 multicast traffic.
 56 * For a switch with 9 user ports, there are 512 possible port masks, but the
 57 * hardware only has 46 individual PGIDs that it can forward multicast traffic
 58 * to. So we need a structure that maps the limited PGID indices to the port
 59 * destinations requested by the user for L2 multicast.
 60 */
 61struct ocelot_pgid {
 62	unsigned long ports;
 63	int index;
 64	refcount_t refcount;
 65	struct list_head list;
 66};
 67
 68struct ocelot_multicast {
 69	struct list_head list;
 70	enum macaccess_entry_type entry_type;
 71	unsigned char addr[ETH_ALEN];
 72	u16 vid;
 73	u16 ports;
 74	struct ocelot_pgid *pgid;
 75};
 76
 77static inline void ocelot_reg_to_target_addr(struct ocelot *ocelot,
 78					     enum ocelot_reg reg,
 79					     enum ocelot_target *target,
 80					     u32 *addr)
 81{
 82	*target = reg >> TARGET_OFFSET;
 83	*addr = ocelot->map[*target][reg & REG_MASK];
 84}
 85
 86int ocelot_bridge_num_find(struct ocelot *ocelot,
 87			   const struct net_device *bridge);
 88
 89int ocelot_mact_learn(struct ocelot *ocelot, int port,
 90		      const unsigned char mac[ETH_ALEN],
 91		      unsigned int vid, enum macaccess_entry_type type);
 92int ocelot_mact_forget(struct ocelot *ocelot,
 93		       const unsigned char mac[ETH_ALEN], unsigned int vid);
 94struct net_device *ocelot_port_to_netdev(struct ocelot *ocelot, int port);
 95int ocelot_netdev_to_port(struct net_device *dev);
 96
 
 
 
 97int ocelot_probe_port(struct ocelot *ocelot, int port, struct regmap *target,
 98		      struct device_node *portnp);
 99void ocelot_release_port(struct ocelot_port *ocelot_port);
 
 
100int ocelot_port_devlink_init(struct ocelot *ocelot, int port,
101			     enum devlink_port_flavour flavour);
102void ocelot_port_devlink_teardown(struct ocelot *ocelot, int port);
103
104int ocelot_trap_add(struct ocelot *ocelot, int port,
105		    unsigned long cookie, bool take_ts,
106		    void (*populate)(struct ocelot_vcap_filter *f));
107int ocelot_trap_del(struct ocelot *ocelot, int port, unsigned long cookie);
108
109struct ocelot_mirror *ocelot_mirror_get(struct ocelot *ocelot, int to,
110					struct netlink_ext_ack *extack);
111void ocelot_mirror_put(struct ocelot *ocelot);
112
113int ocelot_stats_init(struct ocelot *ocelot);
114void ocelot_stats_deinit(struct ocelot *ocelot);
115
116int ocelot_mm_init(struct ocelot *ocelot);
117void ocelot_port_change_fp(struct ocelot *ocelot, int port,
118			   unsigned long preemptible_tcs);
119void ocelot_port_update_active_preemptible_tcs(struct ocelot *ocelot, int port);
120
121extern struct notifier_block ocelot_netdevice_nb;
122extern struct notifier_block ocelot_switchdev_nb;
123extern struct notifier_block ocelot_switchdev_blocking_nb;
124extern const struct devlink_ops ocelot_devlink_ops;
125
126#endif
v5.14.15
  1/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
  2/*
  3 * Microsemi Ocelot Switch driver
  4 *
  5 * Copyright (c) 2017 Microsemi Corporation
  6 */
  7
  8#ifndef _MSCC_OCELOT_H_
  9#define _MSCC_OCELOT_H_
 10
 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>
 19
 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"
 28
 
 29#define OCELOT_BUFFER_CELL_SZ 60
 30
 31#define OCELOT_STATS_CHECK_DELAY (2 * HZ)
 32
 33#define OCELOT_PTP_QUEUE_SZ	128
 34
 
 
 35struct ocelot_port_tc {
 36	bool block_shared;
 37	unsigned long offload_cnt;
 38
 
 39	unsigned long police_id;
 40};
 41
 42struct ocelot_port_private {
 43	struct ocelot_port port;
 44	struct net_device *dev;
 45	struct phy_device *phy;
 46	u8 chip_port;
 47
 48	struct phy *serdes;
 49
 50	struct ocelot_port_tc tc;
 51};
 52
 53struct ocelot_dump_ctx {
 54	struct net_device *dev;
 55	struct sk_buff *skb;
 56	struct netlink_callback *cb;
 57	int idx;
 58};
 59
 60/* MAC table entry types.
 61 * ENTRYTYPE_NORMAL is subject to aging.
 62 * ENTRYTYPE_LOCKED is not subject to aging.
 63 * ENTRYTYPE_MACv4 is not subject to aging. For IPv4 multicast.
 64 * ENTRYTYPE_MACv6 is not subject to aging. For IPv6 multicast.
 65 */
 66enum macaccess_entry_type {
 67	ENTRYTYPE_NORMAL = 0,
 68	ENTRYTYPE_LOCKED,
 69	ENTRYTYPE_MACv4,
 70	ENTRYTYPE_MACv6,
 71};
 72
 73/* A (PGID) port mask structure, encoding the 2^ocelot->num_phys_ports
 74 * possibilities of egress port masks for L2 multicast traffic.
 75 * For a switch with 9 user ports, there are 512 possible port masks, but the
 76 * hardware only has 46 individual PGIDs that it can forward multicast traffic
 77 * to. So we need a structure that maps the limited PGID indices to the port
 78 * destinations requested by the user for L2 multicast.
 79 */
 80struct ocelot_pgid {
 81	unsigned long ports;
 82	int index;
 83	refcount_t refcount;
 84	struct list_head list;
 85};
 86
 87struct ocelot_multicast {
 88	struct list_head list;
 89	enum macaccess_entry_type entry_type;
 90	unsigned char addr[ETH_ALEN];
 91	u16 vid;
 92	u16 ports;
 93	struct ocelot_pgid *pgid;
 94};
 95
 96int ocelot_port_fdb_do_dump(const unsigned char *addr, u16 vid,
 97			    bool is_static, void *data);
 
 
 
 
 
 
 
 
 
 
 98int ocelot_mact_learn(struct ocelot *ocelot, int port,
 99		      const unsigned char mac[ETH_ALEN],
100		      unsigned int vid, enum macaccess_entry_type type);
101int ocelot_mact_forget(struct ocelot *ocelot,
102		       const unsigned char mac[ETH_ALEN], unsigned int vid);
103struct net_device *ocelot_port_to_netdev(struct ocelot *ocelot, int port);
104int ocelot_netdev_to_port(struct net_device *dev);
105
106u32 ocelot_port_readl(struct ocelot_port *port, u32 reg);
107void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);
108
109int ocelot_probe_port(struct ocelot *ocelot, int port, struct regmap *target,
110		      struct phy_device *phy);
111void ocelot_release_port(struct ocelot_port *ocelot_port);
112int ocelot_devlink_init(struct ocelot *ocelot);
113void ocelot_devlink_teardown(struct ocelot *ocelot);
114int ocelot_port_devlink_init(struct ocelot *ocelot, int port,
115			     enum devlink_port_flavour flavour);
116void ocelot_port_devlink_teardown(struct ocelot *ocelot, int port);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
118extern struct notifier_block ocelot_netdevice_nb;
119extern struct notifier_block ocelot_switchdev_nb;
120extern struct notifier_block ocelot_switchdev_blocking_nb;
121extern const struct devlink_ops ocelot_devlink_ops;
122
123#endif