dsa.h (d0300e5e8d2fb74852f8116f26546e12cfa66735) dsa.h (2a93c1a3651fb41b580676c849887b68af6da02b)
1/*
2 * include/net/dsa.h - Driver for Distributed Switch Architecture switch chips
3 * Copyright (c) 2008-2009 Marvell Semiconductor
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.

--- 282 unchanged lines hidden (view full) ---

291
292 for (p = 0; p < ds->num_ports; p++)
293 if (dsa_is_user_port(ds, p))
294 mask |= BIT(p);
295
296 return mask;
297}
298
1/*
2 * include/net/dsa.h - Driver for Distributed Switch Architecture switch chips
3 * Copyright (c) 2008-2009 Marvell Semiconductor
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.

--- 282 unchanged lines hidden (view full) ---

291
292 for (p = 0; p < ds->num_ports; p++)
293 if (dsa_is_user_port(ds, p))
294 mask |= BIT(p);
295
296 return mask;
297}
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;
302
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;
303 if (device == ds->index)
304 return port;
311 else
305 else
312 return ds->rtable[dst->cpu_dp->ds->index];
306 return ds->rtable[device];
313}
314
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);
319}
320
315typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
316 bool is_static, void *data);
317struct dsa_switch_ops {
321typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
322 bool is_static, void *data);
323struct dsa_switch_ops {
324#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
318 /*
319 * Legacy probing.
320 */
321 const char *(*probe)(struct device *dsa_dev,
322 struct device *host_dev, int sw_addr,
323 void **priv);
325 /*
326 * Legacy probing.
327 */
328 const char *(*probe)(struct device *dsa_dev,
329 struct device *host_dev, int sw_addr,
330 void **priv);
331#endif
324
325 enum dsa_tag_protocol (*get_tag_protocol)(struct dsa_switch *ds,
326 int port);
327
328 int (*setup)(struct dsa_switch *ds);
329 u32 (*get_phy_flags)(struct dsa_switch *ds, int port);
330
331 /*

--- 75 unchanged lines hidden (view full) ---

407 u8 state);
408 void (*port_fast_age)(struct dsa_switch *ds, int port);
409
410 /*
411 * VLAN support
412 */
413 int (*port_vlan_filtering)(struct dsa_switch *ds, int port,
414 bool vlan_filtering);
332
333 enum dsa_tag_protocol (*get_tag_protocol)(struct dsa_switch *ds,
334 int port);
335
336 int (*setup)(struct dsa_switch *ds);
337 u32 (*get_phy_flags)(struct dsa_switch *ds, int port);
338
339 /*

--- 75 unchanged lines hidden (view full) ---

415 u8 state);
416 void (*port_fast_age)(struct dsa_switch *ds, int port);
417
418 /*
419 * VLAN support
420 */
421 int (*port_vlan_filtering)(struct dsa_switch *ds, int port,
422 bool vlan_filtering);
415 int (*port_vlan_prepare)(struct dsa_switch *ds, int port,
416 const struct switchdev_obj_port_vlan *vlan,
417 struct switchdev_trans *trans);
418 void (*port_vlan_add)(struct dsa_switch *ds, int port,
419 const struct switchdev_obj_port_vlan *vlan,
420 struct switchdev_trans *trans);
423 int (*port_vlan_prepare)(struct dsa_switch *ds, int port,
424 const struct switchdev_obj_port_vlan *vlan);
425 void (*port_vlan_add)(struct dsa_switch *ds, int port,
426 const struct switchdev_obj_port_vlan *vlan);
421 int (*port_vlan_del)(struct dsa_switch *ds, int port,
422 const struct switchdev_obj_port_vlan *vlan);
423 /*
424 * Forwarding database
425 */
426 int (*port_fdb_add)(struct dsa_switch *ds, int port,
427 const unsigned char *addr, u16 vid);
428 int (*port_fdb_del)(struct dsa_switch *ds, int port,
429 const unsigned char *addr, u16 vid);
430 int (*port_fdb_dump)(struct dsa_switch *ds, int port,
431 dsa_fdb_dump_cb_t *cb, void *data);
432
433 /*
434 * Multicast database
435 */
427 int (*port_vlan_del)(struct dsa_switch *ds, int port,
428 const struct switchdev_obj_port_vlan *vlan);
429 /*
430 * Forwarding database
431 */
432 int (*port_fdb_add)(struct dsa_switch *ds, int port,
433 const unsigned char *addr, u16 vid);
434 int (*port_fdb_del)(struct dsa_switch *ds, int port,
435 const unsigned char *addr, u16 vid);
436 int (*port_fdb_dump)(struct dsa_switch *ds, int port,
437 dsa_fdb_dump_cb_t *cb, void *data);
438
439 /*
440 * Multicast database
441 */
436 int (*port_mdb_prepare)(struct dsa_switch *ds, int port,
437 const struct switchdev_obj_port_mdb *mdb,
438 struct switchdev_trans *trans);
439 void (*port_mdb_add)(struct dsa_switch *ds, int port,
440 const struct switchdev_obj_port_mdb *mdb,
441 struct switchdev_trans *trans);
442 int (*port_mdb_prepare)(struct dsa_switch *ds, int port,
443 const struct switchdev_obj_port_mdb *mdb);
444 void (*port_mdb_add)(struct dsa_switch *ds, int port,
445 const struct switchdev_obj_port_mdb *mdb);
442 int (*port_mdb_del)(struct dsa_switch *ds, int port,
443 const struct switchdev_obj_port_mdb *mdb);
444 /*
445 * RXNFC
446 */
447 int (*get_rxnfc)(struct dsa_switch *ds, int port,
448 struct ethtool_rxnfc *nfc, u32 *rule_locs);
449 int (*set_rxnfc)(struct dsa_switch *ds, int port,

--- 17 unchanged lines hidden (view full) ---

467 int port, struct net_device *br);
468};
469
470struct dsa_switch_driver {
471 struct list_head list;
472 const struct dsa_switch_ops *ops;
473};
474
446 int (*port_mdb_del)(struct dsa_switch *ds, int port,
447 const struct switchdev_obj_port_mdb *mdb);
448 /*
449 * RXNFC
450 */
451 int (*get_rxnfc)(struct dsa_switch *ds, int port,
452 struct ethtool_rxnfc *nfc, u32 *rule_locs);
453 int (*set_rxnfc)(struct dsa_switch *ds, int port,

--- 17 unchanged lines hidden (view full) ---

471 int port, struct net_device *br);
472};
473
474struct dsa_switch_driver {
475 struct list_head list;
476 const struct dsa_switch_ops *ops;
477};
478
479#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
475/* Legacy driver registration */
476void register_switch_driver(struct dsa_switch_driver *type);
477void unregister_switch_driver(struct dsa_switch_driver *type);
478struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev);
479
480/* Legacy driver registration */
481void register_switch_driver(struct dsa_switch_driver *type);
482void unregister_switch_driver(struct dsa_switch_driver *type);
483struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev);
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);
481
482/* Keep inline for faster access in hot path */
483static inline bool netdev_uses_dsa(struct net_device *dev)
484{
485#if IS_ENABLED(CONFIG_NET_DSA)
486 return dev->dsa_ptr && dev->dsa_ptr->rcv;
487#endif

--- 71 unchanged lines hidden ---
493struct net_device *dsa_dev_to_net_device(struct device *dev);
494
495/* Keep inline for faster access in hot path */
496static inline bool netdev_uses_dsa(struct net_device *dev)
497{
498#if IS_ENABLED(CONFIG_NET_DSA)
499 return dev->dsa_ptr && dev->dsa_ptr->rcv;
500#endif

--- 71 unchanged lines hidden ---