xref: /openbmc/linux/include/net/dsa.h (revision 83c0afae)
191da11f8SLennert Buytenhek /*
291da11f8SLennert Buytenhek  * include/net/dsa.h - Driver for Distributed Switch Architecture switch chips
3e84665c9SLennert Buytenhek  * Copyright (c) 2008-2009 Marvell Semiconductor
491da11f8SLennert Buytenhek  *
591da11f8SLennert Buytenhek  * This program is free software; you can redistribute it and/or modify
691da11f8SLennert Buytenhek  * it under the terms of the GNU General Public License as published by
791da11f8SLennert Buytenhek  * the Free Software Foundation; either version 2 of the License, or
891da11f8SLennert Buytenhek  * (at your option) any later version.
991da11f8SLennert Buytenhek  */
1091da11f8SLennert Buytenhek 
1191da11f8SLennert Buytenhek #ifndef __LINUX_NET_DSA_H
1291da11f8SLennert Buytenhek #define __LINUX_NET_DSA_H
1391da11f8SLennert Buytenhek 
14ea1f51beSAxel Lin #include <linux/if_ether.h>
15c8f0b869SBen Hutchings #include <linux/list.h>
16cf50dcc2SBen Hutchings #include <linux/timer.h>
17cf50dcc2SBen Hutchings #include <linux/workqueue.h>
18fa981d9aSFlorian Fainelli #include <linux/of.h>
19ec9436baSFlorian Fainelli #include <linux/phy.h>
20ce31b31cSFlorian Fainelli #include <linux/phy_fixed.h>
21a2820543SFlorian Fainelli #include <linux/ethtool.h>
22cf50dcc2SBen Hutchings 
23ac7a04c3SFlorian Fainelli enum dsa_tag_protocol {
24ac7a04c3SFlorian Fainelli 	DSA_TAG_PROTO_NONE = 0,
25ac7a04c3SFlorian Fainelli 	DSA_TAG_PROTO_DSA,
26ac7a04c3SFlorian Fainelli 	DSA_TAG_PROTO_TRAILER,
27ac7a04c3SFlorian Fainelli 	DSA_TAG_PROTO_EDSA,
28ac7a04c3SFlorian Fainelli 	DSA_TAG_PROTO_BRCM,
2939a7f2a4SAndrew Lunn 	DSA_TAG_LAST,		/* MUST BE LAST */
30ac7a04c3SFlorian Fainelli };
315037d532SFlorian Fainelli 
32e84665c9SLennert Buytenhek #define DSA_MAX_SWITCHES	4
3391da11f8SLennert Buytenhek #define DSA_MAX_PORTS		12
3491da11f8SLennert Buytenhek 
35e84665c9SLennert Buytenhek struct dsa_chip_data {
36e84665c9SLennert Buytenhek 	/*
37e84665c9SLennert Buytenhek 	 * How to access the switch configuration registers.
38e84665c9SLennert Buytenhek 	 */
39b4d2394dSAlexander Duyck 	struct device	*host_dev;
40e84665c9SLennert Buytenhek 	int		sw_addr;
41e84665c9SLennert Buytenhek 
426793abb4SGuenter Roeck 	/* set to size of eeprom if supported by the switch */
436793abb4SGuenter Roeck 	int		eeprom_len;
446793abb4SGuenter Roeck 
45fa981d9aSFlorian Fainelli 	/* Device tree node pointer for this specific switch chip
46fa981d9aSFlorian Fainelli 	 * used during switch setup in case additional properties
47fa981d9aSFlorian Fainelli 	 * and resources needs to be used
48fa981d9aSFlorian Fainelli 	 */
49fa981d9aSFlorian Fainelli 	struct device_node *of_node;
50fa981d9aSFlorian Fainelli 
51e84665c9SLennert Buytenhek 	/*
52e84665c9SLennert Buytenhek 	 * The names of the switch's ports.  Use "cpu" to
53e84665c9SLennert Buytenhek 	 * designate the switch port that the cpu is connected to,
54e84665c9SLennert Buytenhek 	 * "dsa" to indicate that this port is a DSA link to
55e84665c9SLennert Buytenhek 	 * another switch, NULL to indicate the port is unused,
56e84665c9SLennert Buytenhek 	 * or any other string to indicate this is a physical port.
57e84665c9SLennert Buytenhek 	 */
58e84665c9SLennert Buytenhek 	char		*port_names[DSA_MAX_PORTS];
59bd47497aSFlorian Fainelli 	struct device_node *port_dn[DSA_MAX_PORTS];
60e84665c9SLennert Buytenhek 
61e84665c9SLennert Buytenhek 	/*
624a7704ffSAndrew Lunn 	 * An array of which element [a] indicates which port on this
634a7704ffSAndrew Lunn 	 * switch should be used to send packets to that are destined
644a7704ffSAndrew Lunn 	 * for switch a. Can be NULL if there is only one switch chip.
65e84665c9SLennert Buytenhek 	 */
664a7704ffSAndrew Lunn 	s8		rtable[DSA_MAX_SWITCHES];
67e84665c9SLennert Buytenhek };
68e84665c9SLennert Buytenhek 
6991da11f8SLennert Buytenhek struct dsa_platform_data {
7091da11f8SLennert Buytenhek 	/*
7191da11f8SLennert Buytenhek 	 * Reference to a Linux network interface that connects
72e84665c9SLennert Buytenhek 	 * to the root switch chip of the tree.
7391da11f8SLennert Buytenhek 	 */
7491da11f8SLennert Buytenhek 	struct device	*netdev;
75769a0202SFlorian Fainelli 	struct net_device *of_netdev;
7691da11f8SLennert Buytenhek 
7791da11f8SLennert Buytenhek 	/*
78e84665c9SLennert Buytenhek 	 * Info structs describing each of the switch chips
79e84665c9SLennert Buytenhek 	 * connected via this network interface.
8091da11f8SLennert Buytenhek 	 */
81e84665c9SLennert Buytenhek 	int		nr_chips;
82e84665c9SLennert Buytenhek 	struct dsa_chip_data	*chip;
8391da11f8SLennert Buytenhek };
8491da11f8SLennert Buytenhek 
855075314eSAlexander Duyck struct packet_type;
863e8a72d1SFlorian Fainelli 
87cf50dcc2SBen Hutchings struct dsa_switch_tree {
8883c0afaeSAndrew Lunn 	struct list_head	list;
8983c0afaeSAndrew Lunn 
9083c0afaeSAndrew Lunn 	/* Tree identifier */
9183c0afaeSAndrew Lunn 	u32 tree;
9283c0afaeSAndrew Lunn 
9383c0afaeSAndrew Lunn 	/* Number of switches attached to this tree */
9483c0afaeSAndrew Lunn 	struct kref refcount;
9583c0afaeSAndrew Lunn 
9683c0afaeSAndrew Lunn 	/* Has this tree been applied to the hardware? */
9783c0afaeSAndrew Lunn 	bool applied;
9883c0afaeSAndrew Lunn 
99cf50dcc2SBen Hutchings 	/*
100cf50dcc2SBen Hutchings 	 * Configuration data for the platform device that owns
101cf50dcc2SBen Hutchings 	 * this dsa switch tree instance.
102cf50dcc2SBen Hutchings 	 */
103cf50dcc2SBen Hutchings 	struct dsa_platform_data	*pd;
104cf85d08fSLennert Buytenhek 
105cf50dcc2SBen Hutchings 	/*
106cf50dcc2SBen Hutchings 	 * Reference to network device to use, and which tagging
107cf50dcc2SBen Hutchings 	 * protocol to use.
108cf50dcc2SBen Hutchings 	 */
109cf50dcc2SBen Hutchings 	struct net_device	*master_netdev;
1105075314eSAlexander Duyck 	int			(*rcv)(struct sk_buff *skb,
1115075314eSAlexander Duyck 				       struct net_device *dev,
1125075314eSAlexander Duyck 				       struct packet_type *pt,
1135075314eSAlexander Duyck 				       struct net_device *orig_dev);
114cf50dcc2SBen Hutchings 
115cf50dcc2SBen Hutchings 	/*
116badf3adaSFlorian Fainelli 	 * Original copy of the master netdev ethtool_ops
117badf3adaSFlorian Fainelli 	 */
118badf3adaSFlorian Fainelli 	struct ethtool_ops	master_ethtool_ops;
119badf3adaSFlorian Fainelli 
120badf3adaSFlorian Fainelli 	/*
121cf50dcc2SBen Hutchings 	 * The switch and port to which the CPU is attached.
122cf50dcc2SBen Hutchings 	 */
123cf50dcc2SBen Hutchings 	s8			cpu_switch;
124cf50dcc2SBen Hutchings 	s8			cpu_port;
125cf50dcc2SBen Hutchings 
126cf50dcc2SBen Hutchings 	/*
127cf50dcc2SBen Hutchings 	 * Data for the individual switch chips.
128cf50dcc2SBen Hutchings 	 */
129cf50dcc2SBen Hutchings 	struct dsa_switch	*ds[DSA_MAX_SWITCHES];
13039a7f2a4SAndrew Lunn 
13139a7f2a4SAndrew Lunn 	/*
13239a7f2a4SAndrew Lunn 	 * Tagging protocol operations for adding and removing an
13339a7f2a4SAndrew Lunn 	 * encapsulation tag.
13439a7f2a4SAndrew Lunn 	 */
13539a7f2a4SAndrew Lunn 	const struct dsa_device_ops *tag_ops;
136cf50dcc2SBen Hutchings };
137cf50dcc2SBen Hutchings 
138c8b09808SAndrew Lunn struct dsa_port {
139c8b09808SAndrew Lunn 	struct net_device	*netdev;
140189b0d93SAndrew Lunn 	struct device_node	*dn;
141c8b09808SAndrew Lunn };
142c8b09808SAndrew Lunn 
143c8f0b869SBen Hutchings struct dsa_switch {
144c33063d6SAndrew Lunn 	struct device *dev;
145c33063d6SAndrew Lunn 
146c8f0b869SBen Hutchings 	/*
147c8f0b869SBen Hutchings 	 * Parent switch tree, and switch index.
148c8f0b869SBen Hutchings 	 */
149c8f0b869SBen Hutchings 	struct dsa_switch_tree	*dst;
150c8f0b869SBen Hutchings 	int			index;
151c8f0b869SBen Hutchings 
152c8f0b869SBen Hutchings 	/*
1537543a6d5SAndrew Lunn 	 * Give the switch driver somewhere to hang its private data
1547543a6d5SAndrew Lunn 	 * structure.
1557543a6d5SAndrew Lunn 	 */
1567543a6d5SAndrew Lunn 	void *priv;
1577543a6d5SAndrew Lunn 
1587543a6d5SAndrew Lunn 	/*
159c8f0b869SBen Hutchings 	 * Configuration data for this switch.
160c8f0b869SBen Hutchings 	 */
161ff04955cSAndrew Lunn 	struct dsa_chip_data	*cd;
162c8f0b869SBen Hutchings 
163c8f0b869SBen Hutchings 	/*
164c8f0b869SBen Hutchings 	 * The used switch driver.
165c8f0b869SBen Hutchings 	 */
166c8f0b869SBen Hutchings 	struct dsa_switch_driver	*drv;
167c8f0b869SBen Hutchings 
16866472fc0SAndrew Lunn 	/*
16966472fc0SAndrew Lunn 	 * An array of which element [a] indicates which port on this
17066472fc0SAndrew Lunn 	 * switch should be used to send packets to that are destined
17166472fc0SAndrew Lunn 	 * for switch a. Can be NULL if there is only one switch chip.
17266472fc0SAndrew Lunn 	 */
17366472fc0SAndrew Lunn 	s8		rtable[DSA_MAX_SWITCHES];
17466472fc0SAndrew Lunn 
17551579c3fSGuenter Roeck #ifdef CONFIG_NET_DSA_HWMON
17651579c3fSGuenter Roeck 	/*
17751579c3fSGuenter Roeck 	 * Hardware monitoring information
17851579c3fSGuenter Roeck 	 */
17951579c3fSGuenter Roeck 	char			hwmon_name[IFNAMSIZ + 8];
18051579c3fSGuenter Roeck 	struct device		*hwmon_dev;
18151579c3fSGuenter Roeck #endif
18251579c3fSGuenter Roeck 
183c8f0b869SBen Hutchings 	/*
18483c0afaeSAndrew Lunn 	 * The lower device this switch uses to talk to the host
18583c0afaeSAndrew Lunn 	 */
18683c0afaeSAndrew Lunn 	struct net_device *master_netdev;
18783c0afaeSAndrew Lunn 
18883c0afaeSAndrew Lunn 	/*
189c8f0b869SBen Hutchings 	 * Slave mii_bus and devices for the individual ports.
190c8f0b869SBen Hutchings 	 */
191c8f0b869SBen Hutchings 	u32			dsa_port_mask;
19283c0afaeSAndrew Lunn 	u32			cpu_port_mask;
19374c3e2a5SAndrew Lunn 	u32			enabled_port_mask;
1940d8bcdd3SFlorian Fainelli 	u32			phys_mii_mask;
195c8b09808SAndrew Lunn 	struct dsa_port		ports[DSA_MAX_PORTS];
196c8f0b869SBen Hutchings 	struct mii_bus		*slave_mii_bus;
197c8f0b869SBen Hutchings };
198c8f0b869SBen Hutchings 
199c8f0b869SBen Hutchings static inline bool dsa_is_cpu_port(struct dsa_switch *ds, int p)
200c8f0b869SBen Hutchings {
201c8f0b869SBen Hutchings 	return !!(ds->index == ds->dst->cpu_switch && p == ds->dst->cpu_port);
202c8f0b869SBen Hutchings }
203c8f0b869SBen Hutchings 
20460045cbfSAndrew Lunn static inline bool dsa_is_dsa_port(struct dsa_switch *ds, int p)
20560045cbfSAndrew Lunn {
20660045cbfSAndrew Lunn 	return !!((ds->dsa_port_mask) & (1 << p));
20760045cbfSAndrew Lunn }
20860045cbfSAndrew Lunn 
209d79d2107SGuenter Roeck static inline bool dsa_is_port_initialized(struct dsa_switch *ds, int p)
210d79d2107SGuenter Roeck {
211c8b09808SAndrew Lunn 	return ds->enabled_port_mask & (1 << p) && ds->ports[p].netdev;
212d79d2107SGuenter Roeck }
213d79d2107SGuenter Roeck 
214c8f0b869SBen Hutchings static inline u8 dsa_upstream_port(struct dsa_switch *ds)
215c8f0b869SBen Hutchings {
216c8f0b869SBen Hutchings 	struct dsa_switch_tree *dst = ds->dst;
217c8f0b869SBen Hutchings 
218c8f0b869SBen Hutchings 	/*
219c8f0b869SBen Hutchings 	 * If this is the root switch (i.e. the switch that connects
220c8f0b869SBen Hutchings 	 * to the CPU), return the cpu port number on this switch.
221c8f0b869SBen Hutchings 	 * Else return the (DSA) port number that connects to the
222c8f0b869SBen Hutchings 	 * switch that is one hop closer to the cpu.
223c8f0b869SBen Hutchings 	 */
224c8f0b869SBen Hutchings 	if (dst->cpu_switch == ds->index)
225c8f0b869SBen Hutchings 		return dst->cpu_port;
226c8f0b869SBen Hutchings 	else
22766472fc0SAndrew Lunn 		return ds->rtable[dst->cpu_switch];
228c8f0b869SBen Hutchings }
229c8f0b869SBen Hutchings 
230146a3206SVivien Didelot struct switchdev_trans;
231ea70ba98SVivien Didelot struct switchdev_obj;
232146a3206SVivien Didelot struct switchdev_obj_port_fdb;
23376e398a6SVivien Didelot struct switchdev_obj_port_vlan;
234146a3206SVivien Didelot 
235c8f0b869SBen Hutchings struct dsa_switch_driver {
236c8f0b869SBen Hutchings 	struct list_head	list;
237c8f0b869SBen Hutchings 
238ac7a04c3SFlorian Fainelli 	enum dsa_tag_protocol	tag_protocol;
239c8f0b869SBen Hutchings 
240c8f0b869SBen Hutchings 	/*
241c8f0b869SBen Hutchings 	 * Probing and setup.
242c8f0b869SBen Hutchings 	 */
2430209d144SVivien Didelot 	const char	*(*probe)(struct device *dsa_dev,
2440209d144SVivien Didelot 				  struct device *host_dev, int sw_addr,
2450209d144SVivien Didelot 				  void **priv);
246c8f0b869SBen Hutchings 	int	(*setup)(struct dsa_switch *ds);
247c8f0b869SBen Hutchings 	int	(*set_addr)(struct dsa_switch *ds, u8 *addr);
2486819563eSFlorian Fainelli 	u32	(*get_phy_flags)(struct dsa_switch *ds, int port);
249c8f0b869SBen Hutchings 
250c8f0b869SBen Hutchings 	/*
251c8f0b869SBen Hutchings 	 * Access to the switch's PHY registers.
252c8f0b869SBen Hutchings 	 */
253c8f0b869SBen Hutchings 	int	(*phy_read)(struct dsa_switch *ds, int port, int regnum);
254c8f0b869SBen Hutchings 	int	(*phy_write)(struct dsa_switch *ds, int port,
255c8f0b869SBen Hutchings 			     int regnum, u16 val);
256c8f0b869SBen Hutchings 
257c8f0b869SBen Hutchings 	/*
258ec9436baSFlorian Fainelli 	 * Link state adjustment (called from libphy)
259ec9436baSFlorian Fainelli 	 */
260ec9436baSFlorian Fainelli 	void	(*adjust_link)(struct dsa_switch *ds, int port,
261ec9436baSFlorian Fainelli 				struct phy_device *phydev);
262ce31b31cSFlorian Fainelli 	void	(*fixed_link_update)(struct dsa_switch *ds, int port,
263ce31b31cSFlorian Fainelli 				struct fixed_phy_status *st);
264ec9436baSFlorian Fainelli 
265ec9436baSFlorian Fainelli 	/*
266c8f0b869SBen Hutchings 	 * ethtool hardware statistics.
267c8f0b869SBen Hutchings 	 */
268c8f0b869SBen Hutchings 	void	(*get_strings)(struct dsa_switch *ds, int port, uint8_t *data);
269c8f0b869SBen Hutchings 	void	(*get_ethtool_stats)(struct dsa_switch *ds,
270c8f0b869SBen Hutchings 				     int port, uint64_t *data);
271c8f0b869SBen Hutchings 	int	(*get_sset_count)(struct dsa_switch *ds);
27224462549SFlorian Fainelli 
27324462549SFlorian Fainelli 	/*
27419e57c4eSFlorian Fainelli 	 * ethtool Wake-on-LAN
27519e57c4eSFlorian Fainelli 	 */
27619e57c4eSFlorian Fainelli 	void	(*get_wol)(struct dsa_switch *ds, int port,
27719e57c4eSFlorian Fainelli 			   struct ethtool_wolinfo *w);
27819e57c4eSFlorian Fainelli 	int	(*set_wol)(struct dsa_switch *ds, int port,
27919e57c4eSFlorian Fainelli 			   struct ethtool_wolinfo *w);
28019e57c4eSFlorian Fainelli 
28119e57c4eSFlorian Fainelli 	/*
28224462549SFlorian Fainelli 	 * Suspend and resume
28324462549SFlorian Fainelli 	 */
28424462549SFlorian Fainelli 	int	(*suspend)(struct dsa_switch *ds);
28524462549SFlorian Fainelli 	int	(*resume)(struct dsa_switch *ds);
286b2f2af21SFlorian Fainelli 
287b2f2af21SFlorian Fainelli 	/*
288b2f2af21SFlorian Fainelli 	 * Port enable/disable
289b2f2af21SFlorian Fainelli 	 */
290b2f2af21SFlorian Fainelli 	int	(*port_enable)(struct dsa_switch *ds, int port,
291b2f2af21SFlorian Fainelli 			       struct phy_device *phy);
292b2f2af21SFlorian Fainelli 	void	(*port_disable)(struct dsa_switch *ds, int port,
293b2f2af21SFlorian Fainelli 				struct phy_device *phy);
2947905288fSFlorian Fainelli 
2957905288fSFlorian Fainelli 	/*
2967905288fSFlorian Fainelli 	 * EEE setttings
2977905288fSFlorian Fainelli 	 */
2987905288fSFlorian Fainelli 	int	(*set_eee)(struct dsa_switch *ds, int port,
2997905288fSFlorian Fainelli 			   struct phy_device *phydev,
3007905288fSFlorian Fainelli 			   struct ethtool_eee *e);
3017905288fSFlorian Fainelli 	int	(*get_eee)(struct dsa_switch *ds, int port,
3027905288fSFlorian Fainelli 			   struct ethtool_eee *e);
30351579c3fSGuenter Roeck 
30451579c3fSGuenter Roeck #ifdef CONFIG_NET_DSA_HWMON
30551579c3fSGuenter Roeck 	/* Hardware monitoring */
30651579c3fSGuenter Roeck 	int	(*get_temp)(struct dsa_switch *ds, int *temp);
30751579c3fSGuenter Roeck 	int	(*get_temp_limit)(struct dsa_switch *ds, int *temp);
30851579c3fSGuenter Roeck 	int	(*set_temp_limit)(struct dsa_switch *ds, int temp);
30951579c3fSGuenter Roeck 	int	(*get_temp_alarm)(struct dsa_switch *ds, bool *alarm);
31051579c3fSGuenter Roeck #endif
3116793abb4SGuenter Roeck 
3126793abb4SGuenter Roeck 	/* EEPROM access */
3136793abb4SGuenter Roeck 	int	(*get_eeprom_len)(struct dsa_switch *ds);
3146793abb4SGuenter Roeck 	int	(*get_eeprom)(struct dsa_switch *ds,
3156793abb4SGuenter Roeck 			      struct ethtool_eeprom *eeprom, u8 *data);
3166793abb4SGuenter Roeck 	int	(*set_eeprom)(struct dsa_switch *ds,
3176793abb4SGuenter Roeck 			      struct ethtool_eeprom *eeprom, u8 *data);
3183d762a0fSGuenter Roeck 
3193d762a0fSGuenter Roeck 	/*
3203d762a0fSGuenter Roeck 	 * Register access.
3213d762a0fSGuenter Roeck 	 */
3223d762a0fSGuenter Roeck 	int	(*get_regs_len)(struct dsa_switch *ds, int port);
3233d762a0fSGuenter Roeck 	void	(*get_regs)(struct dsa_switch *ds, int port,
3243d762a0fSGuenter Roeck 			    struct ethtool_regs *regs, void *p);
325b73adef6SFlorian Fainelli 
326b73adef6SFlorian Fainelli 	/*
327b73adef6SFlorian Fainelli 	 * Bridge integration
328b73adef6SFlorian Fainelli 	 */
32971327a4eSVivien Didelot 	int	(*port_bridge_join)(struct dsa_switch *ds, int port,
330a6692754SVivien Didelot 				    struct net_device *bridge);
33116bfa702SVivien Didelot 	void	(*port_bridge_leave)(struct dsa_switch *ds, int port);
33243c44a9fSVivien Didelot 	void	(*port_stp_state_set)(struct dsa_switch *ds, int port,
333b73adef6SFlorian Fainelli 				      u8 state);
3342a778e1bSVivien Didelot 
3352a778e1bSVivien Didelot 	/*
33611149536SVivien Didelot 	 * VLAN support
33711149536SVivien Didelot 	 */
338fb2dabadSVivien Didelot 	int	(*port_vlan_filtering)(struct dsa_switch *ds, int port,
339fb2dabadSVivien Didelot 				       bool vlan_filtering);
34076e398a6SVivien Didelot 	int	(*port_vlan_prepare)(struct dsa_switch *ds, int port,
34176e398a6SVivien Didelot 				     const struct switchdev_obj_port_vlan *vlan,
34276e398a6SVivien Didelot 				     struct switchdev_trans *trans);
3434d5770b3SVivien Didelot 	void	(*port_vlan_add)(struct dsa_switch *ds, int port,
34476e398a6SVivien Didelot 				 const struct switchdev_obj_port_vlan *vlan,
34576e398a6SVivien Didelot 				 struct switchdev_trans *trans);
34676e398a6SVivien Didelot 	int	(*port_vlan_del)(struct dsa_switch *ds, int port,
34776e398a6SVivien Didelot 				 const struct switchdev_obj_port_vlan *vlan);
34865aebfc0SVivien Didelot 	int	(*port_vlan_dump)(struct dsa_switch *ds, int port,
34965aebfc0SVivien Didelot 				  struct switchdev_obj_port_vlan *vlan,
35065aebfc0SVivien Didelot 				  int (*cb)(struct switchdev_obj *obj));
35111149536SVivien Didelot 
35211149536SVivien Didelot 	/*
3532a778e1bSVivien Didelot 	 * Forwarding database
3542a778e1bSVivien Didelot 	 */
355146a3206SVivien Didelot 	int	(*port_fdb_prepare)(struct dsa_switch *ds, int port,
356146a3206SVivien Didelot 				    const struct switchdev_obj_port_fdb *fdb,
357146a3206SVivien Didelot 				    struct switchdev_trans *trans);
3588497aa61SVivien Didelot 	void	(*port_fdb_add)(struct dsa_switch *ds, int port,
3591f36faf2SVivien Didelot 				const struct switchdev_obj_port_fdb *fdb,
3601f36faf2SVivien Didelot 				struct switchdev_trans *trans);
3612a778e1bSVivien Didelot 	int	(*port_fdb_del)(struct dsa_switch *ds, int port,
3628057b3e7SVivien Didelot 				const struct switchdev_obj_port_fdb *fdb);
363ea70ba98SVivien Didelot 	int	(*port_fdb_dump)(struct dsa_switch *ds, int port,
364ea70ba98SVivien Didelot 				 struct switchdev_obj_port_fdb *fdb,
365ea70ba98SVivien Didelot 				 int (*cb)(struct switchdev_obj *obj));
366c8f0b869SBen Hutchings };
367c8f0b869SBen Hutchings 
368c8f0b869SBen Hutchings void register_switch_driver(struct dsa_switch_driver *type);
369c8f0b869SBen Hutchings void unregister_switch_driver(struct dsa_switch_driver *type);
370b4d2394dSAlexander Duyck struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev);
371c8f0b869SBen Hutchings 
3727fa857edSFlorian Fainelli static inline void *ds_to_priv(struct dsa_switch *ds)
3737fa857edSFlorian Fainelli {
3747543a6d5SAndrew Lunn 	return ds->priv;
3757fa857edSFlorian Fainelli }
3767fa857edSFlorian Fainelli 
3775aed85ceSFlorian Fainelli static inline bool dsa_uses_tagged_protocol(struct dsa_switch_tree *dst)
3785aed85ceSFlorian Fainelli {
3795075314eSAlexander Duyck 	return dst->rcv != NULL;
3805aed85ceSFlorian Fainelli }
38183c0afaeSAndrew Lunn 
38283c0afaeSAndrew Lunn void dsa_unregister_switch(struct dsa_switch *ds);
38383c0afaeSAndrew Lunn int dsa_register_switch(struct dsa_switch *ds, struct device_node *np);
38491da11f8SLennert Buytenhek #endif
385