Blame view

include/net/dsa.h 12.1 KB
91da11f87   Lennert Buytenhek   net: Distributed ...
1
2
  /*
   * include/net/dsa.h - Driver for Distributed Switch Architecture switch chips
e84665c9c   Lennert Buytenhek   dsa: add switch c...
3
   * Copyright (c) 2008-2009 Marvell Semiconductor
91da11f87   Lennert Buytenhek   net: Distributed ...
4
5
6
7
8
9
10
11
12
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation; either version 2 of the License, or
   * (at your option) any later version.
   */
  
  #ifndef __LINUX_NET_DSA_H
  #define __LINUX_NET_DSA_H
4d56a29f1   Russell King   net: dsa: remove ...
13
  #include <linux/if.h>
ea1f51bef   Axel Lin   dsa: Include linu...
14
  #include <linux/if_ether.h>
c8f0b8699   Ben Hutchings   dsa: Move all def...
15
  #include <linux/list.h>
f515f192a   Vivien Didelot   net: dsa: add swi...
16
  #include <linux/notifier.h>
cf50dcc24   Ben Hutchings   dsa: Change dsa_u...
17
18
  #include <linux/timer.h>
  #include <linux/workqueue.h>
fa981d9af   Florian Fainelli   net: dsa: provide...
19
  #include <linux/of.h>
a28205437   Florian Fainelli   net: dsa: add inc...
20
  #include <linux/ethtool.h>
96567d5da   Andrew Lunn   net: dsa: dsa2: A...
21
  #include <net/devlink.h>
f0c24ccf4   Vivien Didelot   net: dsa: include...
22
  #include <net/switchdev.h>
cf50dcc24   Ben Hutchings   dsa: Change dsa_u...
23

f50f21274   Florian Fainelli   net: dsa: Add plu...
24
  struct tc_action;
4d56a29f1   Russell King   net: dsa: remove ...
25
26
  struct phy_device;
  struct fixed_phy_status;
f50f21274   Florian Fainelli   net: dsa: Add plu...
27

ac7a04c33   Florian Fainelli   net: dsa: change ...
28
29
  enum dsa_tag_protocol {
  	DSA_TAG_PROTO_NONE = 0,
eb7b72112   Andrew Lunn   net: dsa: Sort DS...
30
  	DSA_TAG_PROTO_BRCM,
ac7a04c33   Florian Fainelli   net: dsa: change ...
31
  	DSA_TAG_PROTO_DSA,
ac7a04c33   Florian Fainelli   net: dsa: change ...
32
  	DSA_TAG_PROTO_EDSA,
8b8010fb7   Woojung Huh   dsa: add support ...
33
  	DSA_TAG_PROTO_KSZ,
e8fe177a6   Juergen Beisert   net: dsa: add sup...
34
  	DSA_TAG_PROTO_LAN9303,
eb7b72112   Andrew Lunn   net: dsa: Sort DS...
35
36
37
  	DSA_TAG_PROTO_MTK,
  	DSA_TAG_PROTO_QCA,
  	DSA_TAG_PROTO_TRAILER,
39a7f2a4e   Andrew Lunn   net: dsa: Refacto...
38
  	DSA_TAG_LAST,		/* MUST BE LAST */
ac7a04c33   Florian Fainelli   net: dsa: change ...
39
  };
5037d532b   Florian Fainelli   net: dsa: add Bro...
40

e84665c9c   Lennert Buytenhek   dsa: add switch c...
41
42
  #define DSA_MAX_SWITCHES	4
  #define DSA_MAX_PORTS		12
d390238c4   Vivien Didelot   net: dsa: initial...
43
  #define DSA_RTABLE_NONE		-1
e84665c9c   Lennert Buytenhek   dsa: add switch c...
44
45
46
47
  struct dsa_chip_data {
  	/*
  	 * How to access the switch configuration registers.
  	 */
b4d2394d0   Alexander Duyck   dsa: Replace mii_...
48
  	struct device	*host_dev;
e84665c9c   Lennert Buytenhek   dsa: add switch c...
49
  	int		sw_addr;
71e0bbde0   Florian Fainelli   net: dsa: Add sup...
50
51
52
53
  	/*
  	 * Reference to network devices
  	 */
  	struct device	*netdev[DSA_MAX_PORTS];
6793abb4e   Guenter Roeck   net: dsa: Add sup...
54
55
  	/* set to size of eeprom if supported by the switch */
  	int		eeprom_len;
fa981d9af   Florian Fainelli   net: dsa: provide...
56
57
58
59
60
  	/* Device tree node pointer for this specific switch chip
  	 * used during switch setup in case additional properties
  	 * and resources needs to be used
  	 */
  	struct device_node *of_node;
e84665c9c   Lennert Buytenhek   dsa: add switch c...
61
62
63
64
65
66
67
68
  	/*
  	 * The names of the switch's ports.  Use "cpu" to
  	 * designate the switch port that the cpu is connected to,
  	 * "dsa" to indicate that this port is a DSA link to
  	 * another switch, NULL to indicate the port is unused,
  	 * or any other string to indicate this is a physical port.
  	 */
  	char		*port_names[DSA_MAX_PORTS];
bd47497a0   Florian Fainelli   net: dsa: retain ...
69
  	struct device_node *port_dn[DSA_MAX_PORTS];
e84665c9c   Lennert Buytenhek   dsa: add switch c...
70
71
  
  	/*
4a7704ffa   Andrew Lunn   net: dsa: Remove ...
72
73
74
  	 * An array of which element [a] indicates which port on this
  	 * switch should be used to send packets to that are destined
  	 * for switch a. Can be NULL if there is only one switch chip.
e84665c9c   Lennert Buytenhek   dsa: add switch c...
75
  	 */
4a7704ffa   Andrew Lunn   net: dsa: Remove ...
76
  	s8		rtable[DSA_MAX_SWITCHES];
e84665c9c   Lennert Buytenhek   dsa: add switch c...
77
  };
91da11f87   Lennert Buytenhek   net: Distributed ...
78
79
80
81
  
  struct dsa_platform_data {
  	/*
  	 * Reference to a Linux network interface that connects
e84665c9c   Lennert Buytenhek   dsa: add switch c...
82
  	 * to the root switch chip of the tree.
91da11f87   Lennert Buytenhek   net: Distributed ...
83
84
  	 */
  	struct device	*netdev;
769a02028   Florian Fainelli   net: dsa: utilize...
85
  	struct net_device *of_netdev;
91da11f87   Lennert Buytenhek   net: Distributed ...
86
87
  
  	/*
e84665c9c   Lennert Buytenhek   dsa: add switch c...
88
89
  	 * Info structs describing each of the switch chips
  	 * connected via this network interface.
91da11f87   Lennert Buytenhek   net: Distributed ...
90
  	 */
e84665c9c   Lennert Buytenhek   dsa: add switch c...
91
92
  	int		nr_chips;
  	struct dsa_chip_data	*chip;
91da11f87   Lennert Buytenhek   net: Distributed ...
93
  };
5075314e4   Alexander Duyck   dsa: Split ops up...
94
  struct packet_type;
3e8a72d1d   Florian Fainelli   net: dsa: reduce ...
95

68277a2c9   John Crispin   net-next: dsa: mo...
96
97
98
  struct dsa_device_ops {
  	struct sk_buff *(*xmit)(struct sk_buff *skb, struct net_device *dev);
  	struct sk_buff *(*rcv)(struct sk_buff *skb, struct net_device *dev,
89e49506b   Florian Westphal   dsa: remove unuse...
99
  			       struct packet_type *pt);
598a96801   John Crispin   net-next: dsa: ad...
100
101
  	int (*flow_dissect)(const struct sk_buff *skb, __be16 *proto,
  			    int *offset);
68277a2c9   John Crispin   net-next: dsa: mo...
102
  };
cf50dcc24   Ben Hutchings   dsa: Change dsa_u...
103
  struct dsa_switch_tree {
83c0afaec   Andrew Lunn   net: dsa: Add new...
104
  	struct list_head	list;
f515f192a   Vivien Didelot   net: dsa: add swi...
105
106
  	/* Notifier chain for switch-wide events */
  	struct raw_notifier_head	nh;
83c0afaec   Andrew Lunn   net: dsa: Add new...
107
108
109
110
111
112
113
114
  	/* Tree identifier */
  	u32 tree;
  
  	/* Number of switches attached to this tree */
  	struct kref refcount;
  
  	/* Has this tree been applied to the hardware? */
  	bool applied;
cf50dcc24   Ben Hutchings   dsa: Change dsa_u...
115
116
117
118
119
  	/*
  	 * Configuration data for the platform device that owns
  	 * this dsa switch tree instance.
  	 */
  	struct dsa_platform_data	*pd;
73a7ece8f   Vivien Didelot   net: dsa: comment...
120
  	/* Copy of tag_ops->rcv for faster access in hot path */
a86d8becc   Florian Fainelli   net: dsa: Factor ...
121
  	struct sk_buff *	(*rcv)(struct sk_buff *skb,
5075314e4   Alexander Duyck   dsa: Split ops up...
122
  				       struct net_device *dev,
89e49506b   Florian Westphal   dsa: remove unuse...
123
  				       struct packet_type *pt);
cf50dcc24   Ben Hutchings   dsa: Change dsa_u...
124
125
  
  	/*
8b0d3ea55   Vivien Didelot   net: dsa: store C...
126
  	 * The switch port to which the CPU is attached.
cf50dcc24   Ben Hutchings   dsa: Change dsa_u...
127
  	 */
8b0d3ea55   Vivien Didelot   net: dsa: store C...
128
  	struct dsa_port		*cpu_dp;
cf50dcc24   Ben Hutchings   dsa: Change dsa_u...
129
130
  
  	/*
cf50dcc24   Ben Hutchings   dsa: Change dsa_u...
131
132
133
  	 * Data for the individual switch chips.
  	 */
  	struct dsa_switch	*ds[DSA_MAX_SWITCHES];
39a7f2a4e   Andrew Lunn   net: dsa: Refacto...
134
135
136
137
138
139
  
  	/*
  	 * Tagging protocol operations for adding and removing an
  	 * encapsulation tag.
  	 */
  	const struct dsa_device_ops *tag_ops;
cf50dcc24   Ben Hutchings   dsa: Change dsa_u...
140
  };
f50f21274   Florian Fainelli   net: dsa: Add plu...
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
  /* TC matchall action types, only mirroring for now */
  enum dsa_port_mall_action_type {
  	DSA_PORT_MALL_MIRROR,
  };
  
  /* TC mirroring entry */
  struct dsa_mall_mirror_tc_entry {
  	u8 to_local_port;
  	bool ingress;
  };
  
  /* TC matchall entry */
  struct dsa_mall_tc_entry {
  	struct list_head list;
  	unsigned long cookie;
  	enum dsa_port_mall_action_type type;
  	union {
  		struct dsa_mall_mirror_tc_entry mirror;
  	};
  };
c8b098086   Andrew Lunn   net: dsa: Add a p...
161
  struct dsa_port {
818be8489   Vivien Didelot   net: dsa: add ds ...
162
163
  	struct dsa_switch	*ds;
  	unsigned int		index;
71e0bbde0   Florian Fainelli   net: dsa: Add sup...
164
  	const char		*name;
a29342e73   Florian Fainelli   net: dsa: Associa...
165
  	struct dsa_port		*cpu_dp;
c8b098086   Andrew Lunn   net: dsa: Add a p...
166
  	struct net_device	*netdev;
189b0d93e   Andrew Lunn   net: dsa: Move po...
167
  	struct device_node	*dn;
34a79f63b   Vivien Didelot   net: dsa: support...
168
  	unsigned int		ageing_time;
732f794c1   Vivien Didelot   net: dsa: add por...
169
  	u8			stp_state;
a5e9a02e1   Vivien Didelot   net: dsa: move br...
170
  	struct net_device	*bridge_dev;
96567d5da   Andrew Lunn   net: dsa: dsa2: A...
171
  	struct devlink_port	devlink_port;
67dbb9d43   Florian Fainelli   net: dsa: Relocat...
172
173
174
175
176
  	/*
  	 * Original copy of the master netdev ethtool_ops
  	 */
  	struct ethtool_ops	ethtool_ops;
  	const struct ethtool_ops *orig_ethtool_ops;
c8b098086   Andrew Lunn   net: dsa: Add a p...
177
  };
c8f0b8699   Ben Hutchings   dsa: Move all def...
178
  struct dsa_switch {
c33063d6a   Andrew Lunn   dsa: Remove maste...
179
  	struct device *dev;
c8f0b8699   Ben Hutchings   dsa: Move all def...
180
181
182
183
184
  	/*
  	 * Parent switch tree, and switch index.
  	 */
  	struct dsa_switch_tree	*dst;
  	int			index;
f515f192a   Vivien Didelot   net: dsa: add swi...
185
186
  	/* Listener for switch fabric events */
  	struct notifier_block	nb;
c8f0b8699   Ben Hutchings   dsa: Move all def...
187
  	/*
7543a6d53   Andrew Lunn   net: dsa: Have th...
188
189
190
191
192
193
  	 * Give the switch driver somewhere to hang its private data
  	 * structure.
  	 */
  	void *priv;
  
  	/*
c8f0b8699   Ben Hutchings   dsa: Move all def...
194
195
  	 * Configuration data for this switch.
  	 */
ff04955c2   Andrew Lunn   dsa: Rename switc...
196
  	struct dsa_chip_data	*cd;
c8f0b8699   Ben Hutchings   dsa: Move all def...
197
198
  
  	/*
9d490b4ee   Vivien Didelot   net: dsa: rename ...
199
  	 * The switch operations.
c8f0b8699   Ben Hutchings   dsa: Move all def...
200
  	 */
a82f67afe   Florian Fainelli   net: dsa: Make ds...
201
  	const struct dsa_switch_ops	*ops;
c8f0b8699   Ben Hutchings   dsa: Move all def...
202

66472fc04   Andrew Lunn   net: dsa: Copy th...
203
204
205
206
207
208
  	/*
  	 * An array of which element [a] indicates which port on this
  	 * switch should be used to send packets to that are destined
  	 * for switch a. Can be NULL if there is only one switch chip.
  	 */
  	s8		rtable[DSA_MAX_SWITCHES];
c8f0b8699   Ben Hutchings   dsa: Move all def...
209
210
211
212
  	/*
  	 * Slave mii_bus and devices for the individual ports.
  	 */
  	u32			dsa_port_mask;
83c0afaec   Andrew Lunn   net: dsa: Add new...
213
  	u32			cpu_port_mask;
74c3e2a54   Andrew Lunn   dsa: Rename phys_...
214
  	u32			enabled_port_mask;
0d8bcdd38   Florian Fainelli   net: dsa: allow f...
215
  	u32			phys_mii_mask;
c8f0b8699   Ben Hutchings   dsa: Move all def...
216
  	struct mii_bus		*slave_mii_bus;
a0c02161e   Vivien Didelot   net: dsa: variabl...
217

0f3da6afe   Vivien Didelot   net: dsa: check o...
218
219
220
  	/* Ageing Time limits in msecs */
  	unsigned int ageing_time_min;
  	unsigned int ageing_time_max;
96567d5da   Andrew Lunn   net: dsa: dsa2: A...
221
222
  	/* devlink used to represent this switch device */
  	struct devlink		*devlink;
55199df6d   Florian Fainelli   net: dsa: Allow s...
223
224
  	/* Number of switch port queues */
  	unsigned int		num_tx_queues;
a0c02161e   Vivien Didelot   net: dsa: variabl...
225
226
227
  	/* Dynamically allocated ports, keep last */
  	size_t num_ports;
  	struct dsa_port ports[];
c8f0b8699   Ben Hutchings   dsa: Move all def...
228
229
230
231
  };
  
  static inline bool dsa_is_cpu_port(struct dsa_switch *ds, int p)
  {
14be36c2c   Florian Fainelli   net: dsa: Initial...
232
  	return !!(ds->cpu_port_mask & (1 << p));
c8f0b8699   Ben Hutchings   dsa: Move all def...
233
  }
60045cbfc   Andrew Lunn   net: dsa: Add dsa...
234
235
236
237
  static inline bool dsa_is_dsa_port(struct dsa_switch *ds, int p)
  {
  	return !!((ds->dsa_port_mask) & (1 << p));
  }
6cd456f38   Vivien Didelot   net: dsa: add dsa...
238
239
240
241
  static inline bool dsa_is_normal_port(struct dsa_switch *ds, int p)
  {
  	return !dsa_is_cpu_port(ds, p) && !dsa_is_dsa_port(ds, p);
  }
c8f0b8699   Ben Hutchings   dsa: Move all def...
242
243
244
245
246
247
248
249
250
251
  static inline u8 dsa_upstream_port(struct dsa_switch *ds)
  {
  	struct dsa_switch_tree *dst = ds->dst;
  
  	/*
  	 * If this is the root switch (i.e. the switch that connects
  	 * to the CPU), return the cpu port number on this switch.
  	 * Else return the (DSA) port number that connects to the
  	 * switch that is one hop closer to the cpu.
  	 */
8b0d3ea55   Vivien Didelot   net: dsa: store C...
252
253
  	if (dst->cpu_dp->ds == ds)
  		return dst->cpu_dp->index;
c8f0b8699   Ben Hutchings   dsa: Move all def...
254
  	else
8b0d3ea55   Vivien Didelot   net: dsa: store C...
255
  		return ds->rtable[dst->cpu_dp->ds->index];
c8f0b8699   Ben Hutchings   dsa: Move all def...
256
  }
2bedde1ab   Arkadi Sharshevsky   net: dsa: Move FD...
257
258
  typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
  			      bool is_static, void *data);
9d490b4ee   Vivien Didelot   net: dsa: rename ...
259
  struct dsa_switch_ops {
c8f0b8699   Ben Hutchings   dsa: Move all def...
260
  	/*
a6a71f19f   Vivien Didelot   net: dsa: isolate...
261
  	 * Legacy probing.
c8f0b8699   Ben Hutchings   dsa: Move all def...
262
  	 */
0209d144e   Vivien Didelot   net: dsa: constif...
263
264
265
  	const char	*(*probe)(struct device *dsa_dev,
  				  struct device *host_dev, int sw_addr,
  				  void **priv);
7b314362a   Andrew Lunn   net: dsa: Allow t...
266
267
  
  	enum dsa_tag_protocol (*get_tag_protocol)(struct dsa_switch *ds);
c8f0b8699   Ben Hutchings   dsa: Move all def...
268
269
  	int	(*setup)(struct dsa_switch *ds);
  	int	(*set_addr)(struct dsa_switch *ds, u8 *addr);
6819563e6   Florian Fainelli   net: dsa: allow s...
270
  	u32	(*get_phy_flags)(struct dsa_switch *ds, int port);
c8f0b8699   Ben Hutchings   dsa: Move all def...
271
272
273
274
275
276
277
278
279
  
  	/*
  	 * Access to the switch's PHY registers.
  	 */
  	int	(*phy_read)(struct dsa_switch *ds, int port, int regnum);
  	int	(*phy_write)(struct dsa_switch *ds, int port,
  			     int regnum, u16 val);
  
  	/*
ec9436bae   Florian Fainelli   net: dsa: allow d...
280
281
282
283
  	 * Link state adjustment (called from libphy)
  	 */
  	void	(*adjust_link)(struct dsa_switch *ds, int port,
  				struct phy_device *phydev);
ce31b31c6   Florian Fainelli   net: dsa: allow u...
284
285
  	void	(*fixed_link_update)(struct dsa_switch *ds, int port,
  				struct fixed_phy_status *st);
ec9436bae   Florian Fainelli   net: dsa: allow d...
286
287
  
  	/*
c8f0b8699   Ben Hutchings   dsa: Move all def...
288
289
290
291
292
293
  	 * ethtool hardware statistics.
  	 */
  	void	(*get_strings)(struct dsa_switch *ds, int port, uint8_t *data);
  	void	(*get_ethtool_stats)(struct dsa_switch *ds,
  				     int port, uint64_t *data);
  	int	(*get_sset_count)(struct dsa_switch *ds);
244625491   Florian Fainelli   net: dsa: allow s...
294
295
  
  	/*
19e57c4e6   Florian Fainelli   net: dsa: add {ge...
296
297
298
299
300
301
302
303
  	 * ethtool Wake-on-LAN
  	 */
  	void	(*get_wol)(struct dsa_switch *ds, int port,
  			   struct ethtool_wolinfo *w);
  	int	(*set_wol)(struct dsa_switch *ds, int port,
  			   struct ethtool_wolinfo *w);
  
  	/*
244625491   Florian Fainelli   net: dsa: allow s...
304
305
306
307
  	 * Suspend and resume
  	 */
  	int	(*suspend)(struct dsa_switch *ds);
  	int	(*resume)(struct dsa_switch *ds);
b2f2af21e   Florian Fainelli   net: dsa: allow e...
308
309
310
311
312
313
314
315
  
  	/*
  	 * Port enable/disable
  	 */
  	int	(*port_enable)(struct dsa_switch *ds, int port,
  			       struct phy_device *phy);
  	void	(*port_disable)(struct dsa_switch *ds, int port,
  				struct phy_device *phy);
7905288f0   Florian Fainelli   net: dsa: allow s...
316
317
  
  	/*
08f500610   Vivien Didelot   net: dsa: rename ...
318
  	 * Port's MAC EEE settings
7905288f0   Florian Fainelli   net: dsa: allow s...
319
  	 */
08f500610   Vivien Didelot   net: dsa: rename ...
320
321
322
323
  	int	(*set_mac_eee)(struct dsa_switch *ds, int port,
  			       struct ethtool_eee *e);
  	int	(*get_mac_eee)(struct dsa_switch *ds, int port,
  			       struct ethtool_eee *e);
51579c3f1   Guenter Roeck   net: dsa: Add sup...
324

6793abb4e   Guenter Roeck   net: dsa: Add sup...
325
326
327
328
329
330
  	/* EEPROM access */
  	int	(*get_eeprom_len)(struct dsa_switch *ds);
  	int	(*get_eeprom)(struct dsa_switch *ds,
  			      struct ethtool_eeprom *eeprom, u8 *data);
  	int	(*set_eeprom)(struct dsa_switch *ds,
  			      struct ethtool_eeprom *eeprom, u8 *data);
3d762a0f0   Guenter Roeck   net: dsa: Add sup...
331
332
333
334
335
336
337
  
  	/*
  	 * Register access.
  	 */
  	int	(*get_regs_len)(struct dsa_switch *ds, int port);
  	void	(*get_regs)(struct dsa_switch *ds, int port,
  			    struct ethtool_regs *regs, void *p);
b73adef67   Florian Fainelli   net: dsa: integra...
338
339
340
341
  
  	/*
  	 * Bridge integration
  	 */
34a79f63b   Vivien Didelot   net: dsa: support...
342
  	int	(*set_ageing_time)(struct dsa_switch *ds, unsigned int msecs);
71327a4e7   Vivien Didelot   net: dsa: rename ...
343
  	int	(*port_bridge_join)(struct dsa_switch *ds, int port,
a6692754d   Vivien Didelot   net: dsa: pass br...
344
  				    struct net_device *bridge);
f123f2fbe   Vivien Didelot   net: dsa: pass br...
345
346
  	void	(*port_bridge_leave)(struct dsa_switch *ds, int port,
  				     struct net_device *bridge);
43c44a9f6   Vivien Didelot   net: dsa: make th...
347
348
  	void	(*port_stp_state_set)(struct dsa_switch *ds, int port,
  				      u8 state);
732f794c1   Vivien Didelot   net: dsa: add por...
349
  	void	(*port_fast_age)(struct dsa_switch *ds, int port);
2a778e1b5   Vivien Didelot   net: dsa: change ...
350
351
  
  	/*
111495361   Vivien Didelot   net: dsa: add sup...
352
353
  	 * VLAN support
  	 */
fb2dabad6   Vivien Didelot   net: dsa: support...
354
355
  	int	(*port_vlan_filtering)(struct dsa_switch *ds, int port,
  				       bool vlan_filtering);
76e398a62   Vivien Didelot   net: dsa: use swi...
356
357
358
  	int	(*port_vlan_prepare)(struct dsa_switch *ds, int port,
  				     const struct switchdev_obj_port_vlan *vlan,
  				     struct switchdev_trans *trans);
4d5770b39   Vivien Didelot   net: dsa: make th...
359
  	void	(*port_vlan_add)(struct dsa_switch *ds, int port,
76e398a62   Vivien Didelot   net: dsa: use swi...
360
361
362
363
  				 const struct switchdev_obj_port_vlan *vlan,
  				 struct switchdev_trans *trans);
  	int	(*port_vlan_del)(struct dsa_switch *ds, int port,
  				 const struct switchdev_obj_port_vlan *vlan);
111495361   Vivien Didelot   net: dsa: add sup...
364
  	/*
2a778e1b5   Vivien Didelot   net: dsa: change ...
365
366
  	 * Forwarding database
  	 */
1b6dd556c   Arkadi Sharshevsky   net: dsa: Remove ...
367
  	int	(*port_fdb_add)(struct dsa_switch *ds, int port,
6c2c1dcb1   Arkadi Sharshevsky   net: dsa: Change ...
368
  				const unsigned char *addr, u16 vid);
2a778e1b5   Vivien Didelot   net: dsa: change ...
369
  	int	(*port_fdb_del)(struct dsa_switch *ds, int port,
6c2c1dcb1   Arkadi Sharshevsky   net: dsa: Change ...
370
  				const unsigned char *addr, u16 vid);
ea70ba980   Vivien Didelot   net: dsa: add por...
371
  	int	(*port_fdb_dump)(struct dsa_switch *ds, int port,
2bedde1ab   Arkadi Sharshevsky   net: dsa: Move FD...
372
  				 dsa_fdb_dump_cb_t *cb, void *data);
8df302552   Vivien Didelot   net: dsa: add MDB...
373
374
375
376
377
378
379
380
381
382
383
384
  
  	/*
  	 * Multicast database
  	 */
  	int	(*port_mdb_prepare)(struct dsa_switch *ds, int port,
  				    const struct switchdev_obj_port_mdb *mdb,
  				    struct switchdev_trans *trans);
  	void	(*port_mdb_add)(struct dsa_switch *ds, int port,
  				const struct switchdev_obj_port_mdb *mdb,
  				struct switchdev_trans *trans);
  	int	(*port_mdb_del)(struct dsa_switch *ds, int port,
  				const struct switchdev_obj_port_mdb *mdb);
bf9f26485   Florian Fainelli   net: dsa: Hook {g...
385
386
387
388
389
390
391
  	/*
  	 * RXNFC
  	 */
  	int	(*get_rxnfc)(struct dsa_switch *ds, int port,
  			     struct ethtool_rxnfc *nfc, u32 *rule_locs);
  	int	(*set_rxnfc)(struct dsa_switch *ds, int port,
  			     struct ethtool_rxnfc *nfc);
f50f21274   Florian Fainelli   net: dsa: Add plu...
392
393
394
395
396
397
398
399
400
  
  	/*
  	 * TC integration
  	 */
  	int	(*port_mirror_add)(struct dsa_switch *ds, int port,
  				   struct dsa_mall_mirror_tc_entry *mirror,
  				   bool ingress);
  	void	(*port_mirror_del)(struct dsa_switch *ds, int port,
  				   struct dsa_mall_mirror_tc_entry *mirror);
40ef2c933   Vivien Didelot   net: dsa: add cro...
401
402
403
404
405
406
407
408
  
  	/*
  	 * Cross-chip operations
  	 */
  	int	(*crosschip_bridge_join)(struct dsa_switch *ds, int sw_index,
  					 int port, struct net_device *br);
  	void	(*crosschip_bridge_leave)(struct dsa_switch *ds, int sw_index,
  					  int port, struct net_device *br);
c8f0b8699   Ben Hutchings   dsa: Move all def...
409
  };
ab3d408d3   Florian Fainelli   net: dsa: Encapsu...
410
411
  struct dsa_switch_driver {
  	struct list_head	list;
a82f67afe   Florian Fainelli   net: dsa: Make ds...
412
  	const struct dsa_switch_ops *ops;
ab3d408d3   Florian Fainelli   net: dsa: Encapsu...
413
  };
a6a71f19f   Vivien Didelot   net: dsa: isolate...
414
  /* Legacy driver registration */
ab3d408d3   Florian Fainelli   net: dsa: Encapsu...
415
416
  void register_switch_driver(struct dsa_switch_driver *type);
  void unregister_switch_driver(struct dsa_switch_driver *type);
b4d2394d0   Alexander Duyck   dsa: Replace mii_...
417
  struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev);
a6a71f19f   Vivien Didelot   net: dsa: isolate...
418

14b89f36e   Florian Fainelli   net: dsa: Rename ...
419
  struct net_device *dsa_dev_to_net_device(struct device *dev);
c8f0b8699   Ben Hutchings   dsa: Move all def...
420

73a7ece8f   Vivien Didelot   net: dsa: comment...
421
  /* Keep inline for faster access in hot path */
c6e970a04   Andrew Lunn   net: break includ...
422
423
424
  static inline bool netdev_uses_dsa(struct net_device *dev)
  {
  #if IS_ENABLED(CONFIG_NET_DSA)
717ffbfb2   Vivien Didelot   net: dsa: remove ...
425
  	return dev->dsa_ptr && dev->dsa_ptr->rcv;
c6e970a04   Andrew Lunn   net: break includ...
426
427
428
  #endif
  	return false;
  }
a0c02161e   Vivien Didelot   net: dsa: variabl...
429
  struct dsa_switch *dsa_switch_alloc(struct device *dev, size_t n);
83c0afaec   Andrew Lunn   net: dsa: Add new...
430
  void dsa_unregister_switch(struct dsa_switch *ds);
23c9ee493   Vivien Didelot   net: dsa: remove ...
431
  int dsa_register_switch(struct dsa_switch *ds);
ea825e70d   Florian Fainelli   net: dsa: Export ...
432
433
434
435
436
437
438
439
440
441
442
443
444
  #ifdef CONFIG_PM_SLEEP
  int dsa_switch_suspend(struct dsa_switch *ds);
  int dsa_switch_resume(struct dsa_switch *ds);
  #else
  static inline int dsa_switch_suspend(struct dsa_switch *ds)
  {
  	return 0;
  }
  static inline int dsa_switch_resume(struct dsa_switch *ds)
  {
  	return 0;
  }
  #endif /* CONFIG_PM_SLEEP */
91da11f87   Lennert Buytenhek   net: Distributed ...
445
  #endif