aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/dsa.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/dsa.h')
-rw-r--r--include/net/dsa.h61
1 files changed, 37 insertions, 24 deletions
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 2a05738570d8..6cb602dd970c 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -296,31 +296,39 @@ static inline u32 dsa_user_ports(struct dsa_switch *ds)
296 return mask; 296 return mask;
297} 297}
298 298
299static inline u8 dsa_upstream_port(struct dsa_switch *ds) 299/* Return the local port used to reach an arbitrary switch port */
300static inline unsigned int dsa_towards_port(struct dsa_switch *ds, int device,
301 int port)
300{ 302{
301 struct dsa_switch_tree *dst = ds->dst; 303 if (device == ds->index)
302 304 return port;
303 /*
304 * If this is the root switch (i.e. the switch that connects
305 * to the CPU), return the cpu port number on this switch.
306 * Else return the (DSA) port number that connects to the
307 * switch that is one hop closer to the cpu.
308 */
309 if (dst->cpu_dp->ds == ds)
310 return dst->cpu_dp->index;
311 else 305 else
312 return ds->rtable[dst->cpu_dp->ds->index]; 306 return ds->rtable[device];
307}
308
309/* Return the local port used to reach the dedicated CPU port */
310static inline unsigned int dsa_upstream_port(struct dsa_switch *ds, int port)
311{
312 const struct dsa_port *dp = dsa_to_port(ds, port);
313 const struct dsa_port *cpu_dp = dp->cpu_dp;
314
315 if (!cpu_dp)
316 return port;
317
318 return dsa_towards_port(ds, cpu_dp->ds->index, cpu_dp->index);
313} 319}
314 320
315typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid, 321typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
316 bool is_static, void *data); 322 bool is_static, void *data);
317struct dsa_switch_ops { 323struct dsa_switch_ops {
324#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
318 /* 325 /*
319 * Legacy probing. 326 * Legacy probing.
320 */ 327 */
321 const char *(*probe)(struct device *dsa_dev, 328 const char *(*probe)(struct device *dsa_dev,
322 struct device *host_dev, int sw_addr, 329 struct device *host_dev, int sw_addr,
323 void **priv); 330 void **priv);
331#endif
324 332
325 enum dsa_tag_protocol (*get_tag_protocol)(struct dsa_switch *ds, 333 enum dsa_tag_protocol (*get_tag_protocol)(struct dsa_switch *ds,
326 int port); 334 int port);
@@ -412,12 +420,10 @@ struct dsa_switch_ops {
412 */ 420 */
413 int (*port_vlan_filtering)(struct dsa_switch *ds, int port, 421 int (*port_vlan_filtering)(struct dsa_switch *ds, int port,
414 bool vlan_filtering); 422 bool vlan_filtering);
415 int (*port_vlan_prepare)(struct dsa_switch *ds, int port, 423 int (*port_vlan_prepare)(struct dsa_switch *ds, int port,
416 const struct switchdev_obj_port_vlan *vlan, 424 const struct switchdev_obj_port_vlan *vlan);
417 struct switchdev_trans *trans); 425 void (*port_vlan_add)(struct dsa_switch *ds, int port,
418 void (*port_vlan_add)(struct dsa_switch *ds, int port, 426 const struct switchdev_obj_port_vlan *vlan);
419 const struct switchdev_obj_port_vlan *vlan,
420 struct switchdev_trans *trans);
421 int (*port_vlan_del)(struct dsa_switch *ds, int port, 427 int (*port_vlan_del)(struct dsa_switch *ds, int port,
422 const struct switchdev_obj_port_vlan *vlan); 428 const struct switchdev_obj_port_vlan *vlan);
423 /* 429 /*
@@ -433,12 +439,10 @@ struct dsa_switch_ops {
433 /* 439 /*
434 * Multicast database 440 * Multicast database
435 */ 441 */
436 int (*port_mdb_prepare)(struct dsa_switch *ds, int port, 442 int (*port_mdb_prepare)(struct dsa_switch *ds, int port,
437 const struct switchdev_obj_port_mdb *mdb, 443 const struct switchdev_obj_port_mdb *mdb);
438 struct switchdev_trans *trans); 444 void (*port_mdb_add)(struct dsa_switch *ds, int port,
439 void (*port_mdb_add)(struct dsa_switch *ds, int port, 445 const struct switchdev_obj_port_mdb *mdb);
440 const struct switchdev_obj_port_mdb *mdb,
441 struct switchdev_trans *trans);
442 int (*port_mdb_del)(struct dsa_switch *ds, int port, 446 int (*port_mdb_del)(struct dsa_switch *ds, int port,
443 const struct switchdev_obj_port_mdb *mdb); 447 const struct switchdev_obj_port_mdb *mdb);
444 /* 448 /*
@@ -472,11 +476,20 @@ struct dsa_switch_driver {
472 const struct dsa_switch_ops *ops; 476 const struct dsa_switch_ops *ops;
473}; 477};
474 478
479#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
475/* Legacy driver registration */ 480/* Legacy driver registration */
476void register_switch_driver(struct dsa_switch_driver *type); 481void register_switch_driver(struct dsa_switch_driver *type);
477void unregister_switch_driver(struct dsa_switch_driver *type); 482void unregister_switch_driver(struct dsa_switch_driver *type);
478struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev); 483struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev);
479 484
485#else
486static inline void register_switch_driver(struct dsa_switch_driver *type) { }
487static inline void unregister_switch_driver(struct dsa_switch_driver *type) { }
488static inline struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev)
489{
490 return NULL;
491}
492#endif
480struct net_device *dsa_dev_to_net_device(struct device *dev); 493struct net_device *dsa_dev_to_net_device(struct device *dev);
481 494
482/* Keep inline for faster access in hot path */ 495/* Keep inline for faster access in hot path */