xref: /linux/include/net/dsa.h (revision 66472fc04e8be62858f29c7798ed17e984c1ab3b)
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,
29ac7a04c3SFlorian Fainelli };
305037d532SFlorian Fainelli 
31e84665c9SLennert Buytenhek #define DSA_MAX_SWITCHES	4
3291da11f8SLennert Buytenhek #define DSA_MAX_PORTS		12
3391da11f8SLennert Buytenhek 
34e84665c9SLennert Buytenhek struct dsa_chip_data {
35e84665c9SLennert Buytenhek 	/*
36e84665c9SLennert Buytenhek 	 * How to access the switch configuration registers.
37e84665c9SLennert Buytenhek 	 */
38b4d2394dSAlexander Duyck 	struct device	*host_dev;
39e84665c9SLennert Buytenhek 	int		sw_addr;
40e84665c9SLennert Buytenhek 
416793abb4SGuenter Roeck 	/* set to size of eeprom if supported by the switch */
426793abb4SGuenter Roeck 	int		eeprom_len;
436793abb4SGuenter Roeck 
44fa981d9aSFlorian Fainelli 	/* Device tree node pointer for this specific switch chip
45fa981d9aSFlorian Fainelli 	 * used during switch setup in case additional properties
46fa981d9aSFlorian Fainelli 	 * and resources needs to be used
47fa981d9aSFlorian Fainelli 	 */
48fa981d9aSFlorian Fainelli 	struct device_node *of_node;
49fa981d9aSFlorian Fainelli 
50e84665c9SLennert Buytenhek 	/*
51e84665c9SLennert Buytenhek 	 * The names of the switch's ports.  Use "cpu" to
52e84665c9SLennert Buytenhek 	 * designate the switch port that the cpu is connected to,
53e84665c9SLennert Buytenhek 	 * "dsa" to indicate that this port is a DSA link to
54e84665c9SLennert Buytenhek 	 * another switch, NULL to indicate the port is unused,
55e84665c9SLennert Buytenhek 	 * or any other string to indicate this is a physical port.
56e84665c9SLennert Buytenhek 	 */
57e84665c9SLennert Buytenhek 	char		*port_names[DSA_MAX_PORTS];
58bd47497aSFlorian Fainelli 	struct device_node *port_dn[DSA_MAX_PORTS];
59e84665c9SLennert Buytenhek 
60e84665c9SLennert Buytenhek 	/*
614a7704ffSAndrew Lunn 	 * An array of which element [a] indicates which port on this
624a7704ffSAndrew Lunn 	 * switch should be used to send packets to that are destined
634a7704ffSAndrew Lunn 	 * for switch a. Can be NULL if there is only one switch chip.
64e84665c9SLennert Buytenhek 	 */
654a7704ffSAndrew Lunn 	s8		rtable[DSA_MAX_SWITCHES];
66e84665c9SLennert Buytenhek };
67e84665c9SLennert Buytenhek 
6891da11f8SLennert Buytenhek struct dsa_platform_data {
6991da11f8SLennert Buytenhek 	/*
7091da11f8SLennert Buytenhek 	 * Reference to a Linux network interface that connects
71e84665c9SLennert Buytenhek 	 * to the root switch chip of the tree.
7291da11f8SLennert Buytenhek 	 */
7391da11f8SLennert Buytenhek 	struct device	*netdev;
74769a0202SFlorian Fainelli 	struct net_device *of_netdev;
7591da11f8SLennert Buytenhek 
7691da11f8SLennert Buytenhek 	/*
77e84665c9SLennert Buytenhek 	 * Info structs describing each of the switch chips
78e84665c9SLennert Buytenhek 	 * connected via this network interface.
7991da11f8SLennert Buytenhek 	 */
80e84665c9SLennert Buytenhek 	int		nr_chips;
81e84665c9SLennert Buytenhek 	struct dsa_chip_data	*chip;
8291da11f8SLennert Buytenhek };
8391da11f8SLennert Buytenhek 
845075314eSAlexander Duyck struct packet_type;
853e8a72d1SFlorian Fainelli 
86cf50dcc2SBen Hutchings struct dsa_switch_tree {
87cf50dcc2SBen Hutchings 	/*
88cf50dcc2SBen Hutchings 	 * Configuration data for the platform device that owns
89cf50dcc2SBen Hutchings 	 * this dsa switch tree instance.
90cf50dcc2SBen Hutchings 	 */
91cf50dcc2SBen Hutchings 	struct dsa_platform_data	*pd;
92cf85d08fSLennert Buytenhek 
93cf50dcc2SBen Hutchings 	/*
94cf50dcc2SBen Hutchings 	 * Reference to network device to use, and which tagging
95cf50dcc2SBen Hutchings 	 * protocol to use.
96cf50dcc2SBen Hutchings 	 */
97cf50dcc2SBen Hutchings 	struct net_device	*master_netdev;
985075314eSAlexander Duyck 	int			(*rcv)(struct sk_buff *skb,
995075314eSAlexander Duyck 				       struct net_device *dev,
1005075314eSAlexander Duyck 				       struct packet_type *pt,
1015075314eSAlexander Duyck 				       struct net_device *orig_dev);
102ac7a04c3SFlorian Fainelli 	enum dsa_tag_protocol	tag_protocol;
103cf50dcc2SBen Hutchings 
104cf50dcc2SBen Hutchings 	/*
105badf3adaSFlorian Fainelli 	 * Original copy of the master netdev ethtool_ops
106badf3adaSFlorian Fainelli 	 */
107badf3adaSFlorian Fainelli 	struct ethtool_ops	master_ethtool_ops;
108badf3adaSFlorian Fainelli 
109badf3adaSFlorian Fainelli 	/*
110cf50dcc2SBen Hutchings 	 * The switch and port to which the CPU is attached.
111cf50dcc2SBen Hutchings 	 */
112cf50dcc2SBen Hutchings 	s8			cpu_switch;
113cf50dcc2SBen Hutchings 	s8			cpu_port;
114cf50dcc2SBen Hutchings 
115cf50dcc2SBen Hutchings 	/*
116cf50dcc2SBen Hutchings 	 * Data for the individual switch chips.
117cf50dcc2SBen Hutchings 	 */
118cf50dcc2SBen Hutchings 	struct dsa_switch	*ds[DSA_MAX_SWITCHES];
119cf50dcc2SBen Hutchings };
120cf50dcc2SBen Hutchings 
121c8b09808SAndrew Lunn struct dsa_port {
122c8b09808SAndrew Lunn 	struct net_device	*netdev;
123189b0d93SAndrew Lunn 	struct device_node	*dn;
124c8b09808SAndrew Lunn };
125c8b09808SAndrew Lunn 
126c8f0b869SBen Hutchings struct dsa_switch {
127c33063d6SAndrew Lunn 	struct device *dev;
128c33063d6SAndrew Lunn 
129c8f0b869SBen Hutchings 	/*
130c8f0b869SBen Hutchings 	 * Parent switch tree, and switch index.
131c8f0b869SBen Hutchings 	 */
132c8f0b869SBen Hutchings 	struct dsa_switch_tree	*dst;
133c8f0b869SBen Hutchings 	int			index;
134c8f0b869SBen Hutchings 
135c8f0b869SBen Hutchings 	/*
1367543a6d5SAndrew Lunn 	 * Give the switch driver somewhere to hang its private data
1377543a6d5SAndrew Lunn 	 * structure.
1387543a6d5SAndrew Lunn 	 */
1397543a6d5SAndrew Lunn 	void *priv;
1407543a6d5SAndrew Lunn 
1417543a6d5SAndrew Lunn 	/*
142c8f0b869SBen Hutchings 	 * Configuration data for this switch.
143c8f0b869SBen Hutchings 	 */
144ff04955cSAndrew Lunn 	struct dsa_chip_data	*cd;
145c8f0b869SBen Hutchings 
146c8f0b869SBen Hutchings 	/*
147c8f0b869SBen Hutchings 	 * The used switch driver.
148c8f0b869SBen Hutchings 	 */
149c8f0b869SBen Hutchings 	struct dsa_switch_driver	*drv;
150c8f0b869SBen Hutchings 
151*66472fc0SAndrew Lunn 	/*
152*66472fc0SAndrew Lunn 	 * An array of which element [a] indicates which port on this
153*66472fc0SAndrew Lunn 	 * switch should be used to send packets to that are destined
154*66472fc0SAndrew Lunn 	 * for switch a. Can be NULL if there is only one switch chip.
155*66472fc0SAndrew Lunn 	 */
156*66472fc0SAndrew Lunn 	s8		rtable[DSA_MAX_SWITCHES];
157*66472fc0SAndrew Lunn 
15851579c3fSGuenter Roeck #ifdef CONFIG_NET_DSA_HWMON
15951579c3fSGuenter Roeck 	/*
16051579c3fSGuenter Roeck 	 * Hardware monitoring information
16151579c3fSGuenter Roeck 	 */
16251579c3fSGuenter Roeck 	char			hwmon_name[IFNAMSIZ + 8];
16351579c3fSGuenter Roeck 	struct device		*hwmon_dev;
16451579c3fSGuenter Roeck #endif
16551579c3fSGuenter Roeck 
166c8f0b869SBen Hutchings 	/*
167c8f0b869SBen Hutchings 	 * Slave mii_bus and devices for the individual ports.
168c8f0b869SBen Hutchings 	 */
169c8f0b869SBen Hutchings 	u32			dsa_port_mask;
17074c3e2a5SAndrew Lunn 	u32			enabled_port_mask;
1710d8bcdd3SFlorian Fainelli 	u32			phys_mii_mask;
172c8b09808SAndrew Lunn 	struct dsa_port		ports[DSA_MAX_PORTS];
173c8f0b869SBen Hutchings 	struct mii_bus		*slave_mii_bus;
174c8f0b869SBen Hutchings };
175c8f0b869SBen Hutchings 
176c8f0b869SBen Hutchings static inline bool dsa_is_cpu_port(struct dsa_switch *ds, int p)
177c8f0b869SBen Hutchings {
178c8f0b869SBen Hutchings 	return !!(ds->index == ds->dst->cpu_switch && p == ds->dst->cpu_port);
179c8f0b869SBen Hutchings }
180c8f0b869SBen Hutchings 
18160045cbfSAndrew Lunn static inline bool dsa_is_dsa_port(struct dsa_switch *ds, int p)
18260045cbfSAndrew Lunn {
18360045cbfSAndrew Lunn 	return !!((ds->dsa_port_mask) & (1 << p));
18460045cbfSAndrew Lunn }
18560045cbfSAndrew Lunn 
186d79d2107SGuenter Roeck static inline bool dsa_is_port_initialized(struct dsa_switch *ds, int p)
187d79d2107SGuenter Roeck {
188c8b09808SAndrew Lunn 	return ds->enabled_port_mask & (1 << p) && ds->ports[p].netdev;
189d79d2107SGuenter Roeck }
190d79d2107SGuenter Roeck 
191c8f0b869SBen Hutchings static inline u8 dsa_upstream_port(struct dsa_switch *ds)
192c8f0b869SBen Hutchings {
193c8f0b869SBen Hutchings 	struct dsa_switch_tree *dst = ds->dst;
194c8f0b869SBen Hutchings 
195c8f0b869SBen Hutchings 	/*
196c8f0b869SBen Hutchings 	 * If this is the root switch (i.e. the switch that connects
197c8f0b869SBen Hutchings 	 * to the CPU), return the cpu port number on this switch.
198c8f0b869SBen Hutchings 	 * Else return the (DSA) port number that connects to the
199c8f0b869SBen Hutchings 	 * switch that is one hop closer to the cpu.
200c8f0b869SBen Hutchings 	 */
201c8f0b869SBen Hutchings 	if (dst->cpu_switch == ds->index)
202c8f0b869SBen Hutchings 		return dst->cpu_port;
203c8f0b869SBen Hutchings 	else
204*66472fc0SAndrew Lunn 		return ds->rtable[dst->cpu_switch];
205c8f0b869SBen Hutchings }
206c8f0b869SBen Hutchings 
207146a3206SVivien Didelot struct switchdev_trans;
208ea70ba98SVivien Didelot struct switchdev_obj;
209146a3206SVivien Didelot struct switchdev_obj_port_fdb;
21076e398a6SVivien Didelot struct switchdev_obj_port_vlan;
211146a3206SVivien Didelot 
212c8f0b869SBen Hutchings struct dsa_switch_driver {
213c8f0b869SBen Hutchings 	struct list_head	list;
214c8f0b869SBen Hutchings 
215ac7a04c3SFlorian Fainelli 	enum dsa_tag_protocol	tag_protocol;
216c8f0b869SBen Hutchings 
217c8f0b869SBen Hutchings 	/*
218c8f0b869SBen Hutchings 	 * Probing and setup.
219c8f0b869SBen Hutchings 	 */
2200209d144SVivien Didelot 	const char	*(*probe)(struct device *dsa_dev,
2210209d144SVivien Didelot 				  struct device *host_dev, int sw_addr,
2220209d144SVivien Didelot 				  void **priv);
223c8f0b869SBen Hutchings 	int	(*setup)(struct dsa_switch *ds);
224c8f0b869SBen Hutchings 	int	(*set_addr)(struct dsa_switch *ds, u8 *addr);
2256819563eSFlorian Fainelli 	u32	(*get_phy_flags)(struct dsa_switch *ds, int port);
226c8f0b869SBen Hutchings 
227c8f0b869SBen Hutchings 	/*
228c8f0b869SBen Hutchings 	 * Access to the switch's PHY registers.
229c8f0b869SBen Hutchings 	 */
230c8f0b869SBen Hutchings 	int	(*phy_read)(struct dsa_switch *ds, int port, int regnum);
231c8f0b869SBen Hutchings 	int	(*phy_write)(struct dsa_switch *ds, int port,
232c8f0b869SBen Hutchings 			     int regnum, u16 val);
233c8f0b869SBen Hutchings 
234c8f0b869SBen Hutchings 	/*
235ec9436baSFlorian Fainelli 	 * Link state adjustment (called from libphy)
236ec9436baSFlorian Fainelli 	 */
237ec9436baSFlorian Fainelli 	void	(*adjust_link)(struct dsa_switch *ds, int port,
238ec9436baSFlorian Fainelli 				struct phy_device *phydev);
239ce31b31cSFlorian Fainelli 	void	(*fixed_link_update)(struct dsa_switch *ds, int port,
240ce31b31cSFlorian Fainelli 				struct fixed_phy_status *st);
241ec9436baSFlorian Fainelli 
242ec9436baSFlorian Fainelli 	/*
243c8f0b869SBen Hutchings 	 * ethtool hardware statistics.
244c8f0b869SBen Hutchings 	 */
245c8f0b869SBen Hutchings 	void	(*get_strings)(struct dsa_switch *ds, int port, uint8_t *data);
246c8f0b869SBen Hutchings 	void	(*get_ethtool_stats)(struct dsa_switch *ds,
247c8f0b869SBen Hutchings 				     int port, uint64_t *data);
248c8f0b869SBen Hutchings 	int	(*get_sset_count)(struct dsa_switch *ds);
24924462549SFlorian Fainelli 
25024462549SFlorian Fainelli 	/*
25119e57c4eSFlorian Fainelli 	 * ethtool Wake-on-LAN
25219e57c4eSFlorian Fainelli 	 */
25319e57c4eSFlorian Fainelli 	void	(*get_wol)(struct dsa_switch *ds, int port,
25419e57c4eSFlorian Fainelli 			   struct ethtool_wolinfo *w);
25519e57c4eSFlorian Fainelli 	int	(*set_wol)(struct dsa_switch *ds, int port,
25619e57c4eSFlorian Fainelli 			   struct ethtool_wolinfo *w);
25719e57c4eSFlorian Fainelli 
25819e57c4eSFlorian Fainelli 	/*
25924462549SFlorian Fainelli 	 * Suspend and resume
26024462549SFlorian Fainelli 	 */
26124462549SFlorian Fainelli 	int	(*suspend)(struct dsa_switch *ds);
26224462549SFlorian Fainelli 	int	(*resume)(struct dsa_switch *ds);
263b2f2af21SFlorian Fainelli 
264b2f2af21SFlorian Fainelli 	/*
265b2f2af21SFlorian Fainelli 	 * Port enable/disable
266b2f2af21SFlorian Fainelli 	 */
267b2f2af21SFlorian Fainelli 	int	(*port_enable)(struct dsa_switch *ds, int port,
268b2f2af21SFlorian Fainelli 			       struct phy_device *phy);
269b2f2af21SFlorian Fainelli 	void	(*port_disable)(struct dsa_switch *ds, int port,
270b2f2af21SFlorian Fainelli 				struct phy_device *phy);
2717905288fSFlorian Fainelli 
2727905288fSFlorian Fainelli 	/*
2737905288fSFlorian Fainelli 	 * EEE setttings
2747905288fSFlorian Fainelli 	 */
2757905288fSFlorian Fainelli 	int	(*set_eee)(struct dsa_switch *ds, int port,
2767905288fSFlorian Fainelli 			   struct phy_device *phydev,
2777905288fSFlorian Fainelli 			   struct ethtool_eee *e);
2787905288fSFlorian Fainelli 	int	(*get_eee)(struct dsa_switch *ds, int port,
2797905288fSFlorian Fainelli 			   struct ethtool_eee *e);
28051579c3fSGuenter Roeck 
28151579c3fSGuenter Roeck #ifdef CONFIG_NET_DSA_HWMON
28251579c3fSGuenter Roeck 	/* Hardware monitoring */
28351579c3fSGuenter Roeck 	int	(*get_temp)(struct dsa_switch *ds, int *temp);
28451579c3fSGuenter Roeck 	int	(*get_temp_limit)(struct dsa_switch *ds, int *temp);
28551579c3fSGuenter Roeck 	int	(*set_temp_limit)(struct dsa_switch *ds, int temp);
28651579c3fSGuenter Roeck 	int	(*get_temp_alarm)(struct dsa_switch *ds, bool *alarm);
28751579c3fSGuenter Roeck #endif
2886793abb4SGuenter Roeck 
2896793abb4SGuenter Roeck 	/* EEPROM access */
2906793abb4SGuenter Roeck 	int	(*get_eeprom_len)(struct dsa_switch *ds);
2916793abb4SGuenter Roeck 	int	(*get_eeprom)(struct dsa_switch *ds,
2926793abb4SGuenter Roeck 			      struct ethtool_eeprom *eeprom, u8 *data);
2936793abb4SGuenter Roeck 	int	(*set_eeprom)(struct dsa_switch *ds,
2946793abb4SGuenter Roeck 			      struct ethtool_eeprom *eeprom, u8 *data);
2953d762a0fSGuenter Roeck 
2963d762a0fSGuenter Roeck 	/*
2973d762a0fSGuenter Roeck 	 * Register access.
2983d762a0fSGuenter Roeck 	 */
2993d762a0fSGuenter Roeck 	int	(*get_regs_len)(struct dsa_switch *ds, int port);
3003d762a0fSGuenter Roeck 	void	(*get_regs)(struct dsa_switch *ds, int port,
3013d762a0fSGuenter Roeck 			    struct ethtool_regs *regs, void *p);
302b73adef6SFlorian Fainelli 
303b73adef6SFlorian Fainelli 	/*
304b73adef6SFlorian Fainelli 	 * Bridge integration
305b73adef6SFlorian Fainelli 	 */
30671327a4eSVivien Didelot 	int	(*port_bridge_join)(struct dsa_switch *ds, int port,
307a6692754SVivien Didelot 				    struct net_device *bridge);
30816bfa702SVivien Didelot 	void	(*port_bridge_leave)(struct dsa_switch *ds, int port);
30943c44a9fSVivien Didelot 	void	(*port_stp_state_set)(struct dsa_switch *ds, int port,
310b73adef6SFlorian Fainelli 				      u8 state);
3112a778e1bSVivien Didelot 
3122a778e1bSVivien Didelot 	/*
31311149536SVivien Didelot 	 * VLAN support
31411149536SVivien Didelot 	 */
315fb2dabadSVivien Didelot 	int	(*port_vlan_filtering)(struct dsa_switch *ds, int port,
316fb2dabadSVivien Didelot 				       bool vlan_filtering);
31776e398a6SVivien Didelot 	int	(*port_vlan_prepare)(struct dsa_switch *ds, int port,
31876e398a6SVivien Didelot 				     const struct switchdev_obj_port_vlan *vlan,
31976e398a6SVivien Didelot 				     struct switchdev_trans *trans);
3204d5770b3SVivien Didelot 	void	(*port_vlan_add)(struct dsa_switch *ds, int port,
32176e398a6SVivien Didelot 				 const struct switchdev_obj_port_vlan *vlan,
32276e398a6SVivien Didelot 				 struct switchdev_trans *trans);
32376e398a6SVivien Didelot 	int	(*port_vlan_del)(struct dsa_switch *ds, int port,
32476e398a6SVivien Didelot 				 const struct switchdev_obj_port_vlan *vlan);
32565aebfc0SVivien Didelot 	int	(*port_vlan_dump)(struct dsa_switch *ds, int port,
32665aebfc0SVivien Didelot 				  struct switchdev_obj_port_vlan *vlan,
32765aebfc0SVivien Didelot 				  int (*cb)(struct switchdev_obj *obj));
32811149536SVivien Didelot 
32911149536SVivien Didelot 	/*
3302a778e1bSVivien Didelot 	 * Forwarding database
3312a778e1bSVivien Didelot 	 */
332146a3206SVivien Didelot 	int	(*port_fdb_prepare)(struct dsa_switch *ds, int port,
333146a3206SVivien Didelot 				    const struct switchdev_obj_port_fdb *fdb,
334146a3206SVivien Didelot 				    struct switchdev_trans *trans);
3358497aa61SVivien Didelot 	void	(*port_fdb_add)(struct dsa_switch *ds, int port,
3361f36faf2SVivien Didelot 				const struct switchdev_obj_port_fdb *fdb,
3371f36faf2SVivien Didelot 				struct switchdev_trans *trans);
3382a778e1bSVivien Didelot 	int	(*port_fdb_del)(struct dsa_switch *ds, int port,
3398057b3e7SVivien Didelot 				const struct switchdev_obj_port_fdb *fdb);
340ea70ba98SVivien Didelot 	int	(*port_fdb_dump)(struct dsa_switch *ds, int port,
341ea70ba98SVivien Didelot 				 struct switchdev_obj_port_fdb *fdb,
342ea70ba98SVivien Didelot 				 int (*cb)(struct switchdev_obj *obj));
343c8f0b869SBen Hutchings };
344c8f0b869SBen Hutchings 
345c8f0b869SBen Hutchings void register_switch_driver(struct dsa_switch_driver *type);
346c8f0b869SBen Hutchings void unregister_switch_driver(struct dsa_switch_driver *type);
347b4d2394dSAlexander Duyck struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev);
348c8f0b869SBen Hutchings 
3497fa857edSFlorian Fainelli static inline void *ds_to_priv(struct dsa_switch *ds)
3507fa857edSFlorian Fainelli {
3517543a6d5SAndrew Lunn 	return ds->priv;
3527fa857edSFlorian Fainelli }
3537fa857edSFlorian Fainelli 
3545aed85ceSFlorian Fainelli static inline bool dsa_uses_tagged_protocol(struct dsa_switch_tree *dst)
3555aed85ceSFlorian Fainelli {
3565075314eSAlexander Duyck 	return dst->rcv != NULL;
3575aed85ceSFlorian Fainelli }
35891da11f8SLennert Buytenhek #endif
359