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, 29cafdc45cSJohn Crispin DSA_TAG_PROTO_QCA, 3039a7f2a4SAndrew Lunn DSA_TAG_LAST, /* MUST BE LAST */ 31ac7a04c3SFlorian Fainelli }; 325037d532SFlorian Fainelli 33e84665c9SLennert Buytenhek #define DSA_MAX_SWITCHES 4 3491da11f8SLennert Buytenhek #define DSA_MAX_PORTS 12 3591da11f8SLennert Buytenhek 36d390238cSVivien Didelot #define DSA_RTABLE_NONE -1 37d390238cSVivien Didelot 38e84665c9SLennert Buytenhek struct dsa_chip_data { 39e84665c9SLennert Buytenhek /* 40e84665c9SLennert Buytenhek * How to access the switch configuration registers. 41e84665c9SLennert Buytenhek */ 42b4d2394dSAlexander Duyck struct device *host_dev; 43e84665c9SLennert Buytenhek int sw_addr; 44e84665c9SLennert Buytenhek 456793abb4SGuenter Roeck /* set to size of eeprom if supported by the switch */ 466793abb4SGuenter Roeck int eeprom_len; 476793abb4SGuenter Roeck 48fa981d9aSFlorian Fainelli /* Device tree node pointer for this specific switch chip 49fa981d9aSFlorian Fainelli * used during switch setup in case additional properties 50fa981d9aSFlorian Fainelli * and resources needs to be used 51fa981d9aSFlorian Fainelli */ 52fa981d9aSFlorian Fainelli struct device_node *of_node; 53fa981d9aSFlorian Fainelli 54e84665c9SLennert Buytenhek /* 55e84665c9SLennert Buytenhek * The names of the switch's ports. Use "cpu" to 56e84665c9SLennert Buytenhek * designate the switch port that the cpu is connected to, 57e84665c9SLennert Buytenhek * "dsa" to indicate that this port is a DSA link to 58e84665c9SLennert Buytenhek * another switch, NULL to indicate the port is unused, 59e84665c9SLennert Buytenhek * or any other string to indicate this is a physical port. 60e84665c9SLennert Buytenhek */ 61e84665c9SLennert Buytenhek char *port_names[DSA_MAX_PORTS]; 62bd47497aSFlorian Fainelli struct device_node *port_dn[DSA_MAX_PORTS]; 63e84665c9SLennert Buytenhek 64e84665c9SLennert Buytenhek /* 654a7704ffSAndrew Lunn * An array of which element [a] indicates which port on this 664a7704ffSAndrew Lunn * switch should be used to send packets to that are destined 674a7704ffSAndrew Lunn * for switch a. Can be NULL if there is only one switch chip. 68e84665c9SLennert Buytenhek */ 694a7704ffSAndrew Lunn s8 rtable[DSA_MAX_SWITCHES]; 70e84665c9SLennert Buytenhek }; 71e84665c9SLennert Buytenhek 7291da11f8SLennert Buytenhek struct dsa_platform_data { 7391da11f8SLennert Buytenhek /* 7491da11f8SLennert Buytenhek * Reference to a Linux network interface that connects 75e84665c9SLennert Buytenhek * to the root switch chip of the tree. 7691da11f8SLennert Buytenhek */ 7791da11f8SLennert Buytenhek struct device *netdev; 78769a0202SFlorian Fainelli struct net_device *of_netdev; 7991da11f8SLennert Buytenhek 8091da11f8SLennert Buytenhek /* 81e84665c9SLennert Buytenhek * Info structs describing each of the switch chips 82e84665c9SLennert Buytenhek * connected via this network interface. 8391da11f8SLennert Buytenhek */ 84e84665c9SLennert Buytenhek int nr_chips; 85e84665c9SLennert Buytenhek struct dsa_chip_data *chip; 8691da11f8SLennert Buytenhek }; 8791da11f8SLennert Buytenhek 885075314eSAlexander Duyck struct packet_type; 893e8a72d1SFlorian Fainelli 90cf50dcc2SBen Hutchings struct dsa_switch_tree { 9183c0afaeSAndrew Lunn struct list_head list; 9283c0afaeSAndrew Lunn 9383c0afaeSAndrew Lunn /* Tree identifier */ 9483c0afaeSAndrew Lunn u32 tree; 9583c0afaeSAndrew Lunn 9683c0afaeSAndrew Lunn /* Number of switches attached to this tree */ 9783c0afaeSAndrew Lunn struct kref refcount; 9883c0afaeSAndrew Lunn 9983c0afaeSAndrew Lunn /* Has this tree been applied to the hardware? */ 10083c0afaeSAndrew Lunn bool applied; 10183c0afaeSAndrew Lunn 102cf50dcc2SBen Hutchings /* 103cf50dcc2SBen Hutchings * Configuration data for the platform device that owns 104cf50dcc2SBen Hutchings * this dsa switch tree instance. 105cf50dcc2SBen Hutchings */ 106cf50dcc2SBen Hutchings struct dsa_platform_data *pd; 107cf85d08fSLennert Buytenhek 108cf50dcc2SBen Hutchings /* 109cf50dcc2SBen Hutchings * Reference to network device to use, and which tagging 110cf50dcc2SBen Hutchings * protocol to use. 111cf50dcc2SBen Hutchings */ 112cf50dcc2SBen Hutchings struct net_device *master_netdev; 1135075314eSAlexander Duyck int (*rcv)(struct sk_buff *skb, 1145075314eSAlexander Duyck struct net_device *dev, 1155075314eSAlexander Duyck struct packet_type *pt, 1165075314eSAlexander Duyck struct net_device *orig_dev); 117cf50dcc2SBen Hutchings 118cf50dcc2SBen Hutchings /* 119badf3adaSFlorian Fainelli * Original copy of the master netdev ethtool_ops 120badf3adaSFlorian Fainelli */ 121badf3adaSFlorian Fainelli struct ethtool_ops master_ethtool_ops; 1220c73c523SFlorian Fainelli const struct ethtool_ops *master_orig_ethtool_ops; 123badf3adaSFlorian Fainelli 124badf3adaSFlorian Fainelli /* 125cf50dcc2SBen Hutchings * The switch and port to which the CPU is attached. 126cf50dcc2SBen Hutchings */ 127b22de490SVivien Didelot struct dsa_switch *cpu_switch; 128cf50dcc2SBen Hutchings s8 cpu_port; 129cf50dcc2SBen Hutchings 130cf50dcc2SBen Hutchings /* 131cf50dcc2SBen Hutchings * Data for the individual switch chips. 132cf50dcc2SBen Hutchings */ 133cf50dcc2SBen Hutchings struct dsa_switch *ds[DSA_MAX_SWITCHES]; 13439a7f2a4SAndrew Lunn 13539a7f2a4SAndrew Lunn /* 13639a7f2a4SAndrew Lunn * Tagging protocol operations for adding and removing an 13739a7f2a4SAndrew Lunn * encapsulation tag. 13839a7f2a4SAndrew Lunn */ 13939a7f2a4SAndrew Lunn const struct dsa_device_ops *tag_ops; 140cf50dcc2SBen Hutchings }; 141cf50dcc2SBen Hutchings 142c8b09808SAndrew Lunn struct dsa_port { 143818be848SVivien Didelot struct dsa_switch *ds; 144818be848SVivien Didelot unsigned int index; 145c8b09808SAndrew Lunn struct net_device *netdev; 146189b0d93SAndrew Lunn struct device_node *dn; 14734a79f63SVivien Didelot unsigned int ageing_time; 148732f794cSVivien Didelot u8 stp_state; 149a5e9a02eSVivien Didelot struct net_device *bridge_dev; 150c8b09808SAndrew Lunn }; 151c8b09808SAndrew Lunn 152c8f0b869SBen Hutchings struct dsa_switch { 153c33063d6SAndrew Lunn struct device *dev; 154c33063d6SAndrew Lunn 155c8f0b869SBen Hutchings /* 156c8f0b869SBen Hutchings * Parent switch tree, and switch index. 157c8f0b869SBen Hutchings */ 158c8f0b869SBen Hutchings struct dsa_switch_tree *dst; 159c8f0b869SBen Hutchings int index; 160c8f0b869SBen Hutchings 161c8f0b869SBen Hutchings /* 1627543a6d5SAndrew Lunn * Give the switch driver somewhere to hang its private data 1637543a6d5SAndrew Lunn * structure. 1647543a6d5SAndrew Lunn */ 1657543a6d5SAndrew Lunn void *priv; 1667543a6d5SAndrew Lunn 1677543a6d5SAndrew Lunn /* 168c8f0b869SBen Hutchings * Configuration data for this switch. 169c8f0b869SBen Hutchings */ 170ff04955cSAndrew Lunn struct dsa_chip_data *cd; 171c8f0b869SBen Hutchings 172c8f0b869SBen Hutchings /* 1739d490b4eSVivien Didelot * The switch operations. 174c8f0b869SBen Hutchings */ 175a82f67afSFlorian Fainelli const struct dsa_switch_ops *ops; 176c8f0b869SBen Hutchings 17766472fc0SAndrew Lunn /* 17866472fc0SAndrew Lunn * An array of which element [a] indicates which port on this 17966472fc0SAndrew Lunn * switch should be used to send packets to that are destined 18066472fc0SAndrew Lunn * for switch a. Can be NULL if there is only one switch chip. 18166472fc0SAndrew Lunn */ 18266472fc0SAndrew Lunn s8 rtable[DSA_MAX_SWITCHES]; 18366472fc0SAndrew Lunn 184c8f0b869SBen Hutchings /* 18583c0afaeSAndrew Lunn * The lower device this switch uses to talk to the host 18683c0afaeSAndrew Lunn */ 18783c0afaeSAndrew Lunn struct net_device *master_netdev; 18883c0afaeSAndrew Lunn 18983c0afaeSAndrew Lunn /* 190c8f0b869SBen Hutchings * Slave mii_bus and devices for the individual ports. 191c8f0b869SBen Hutchings */ 192c8f0b869SBen Hutchings u32 dsa_port_mask; 19383c0afaeSAndrew Lunn u32 cpu_port_mask; 19474c3e2a5SAndrew Lunn u32 enabled_port_mask; 1950d8bcdd3SFlorian Fainelli u32 phys_mii_mask; 196c8f0b869SBen Hutchings struct mii_bus *slave_mii_bus; 197a0c02161SVivien Didelot 198a0c02161SVivien Didelot /* Dynamically allocated ports, keep last */ 199a0c02161SVivien Didelot size_t num_ports; 200a0c02161SVivien Didelot struct dsa_port ports[]; 201c8f0b869SBen Hutchings }; 202c8f0b869SBen Hutchings 203c8f0b869SBen Hutchings static inline bool dsa_is_cpu_port(struct dsa_switch *ds, int p) 204c8f0b869SBen Hutchings { 205b22de490SVivien Didelot return !!(ds == ds->dst->cpu_switch && p == ds->dst->cpu_port); 206c8f0b869SBen Hutchings } 207c8f0b869SBen Hutchings 20860045cbfSAndrew Lunn static inline bool dsa_is_dsa_port(struct dsa_switch *ds, int p) 20960045cbfSAndrew Lunn { 21060045cbfSAndrew Lunn return !!((ds->dsa_port_mask) & (1 << p)); 21160045cbfSAndrew Lunn } 21260045cbfSAndrew Lunn 213d79d2107SGuenter Roeck static inline bool dsa_is_port_initialized(struct dsa_switch *ds, int p) 214d79d2107SGuenter Roeck { 215c8b09808SAndrew Lunn return ds->enabled_port_mask & (1 << p) && ds->ports[p].netdev; 216d79d2107SGuenter Roeck } 217d79d2107SGuenter Roeck 218c8f0b869SBen Hutchings static inline u8 dsa_upstream_port(struct dsa_switch *ds) 219c8f0b869SBen Hutchings { 220c8f0b869SBen Hutchings struct dsa_switch_tree *dst = ds->dst; 221c8f0b869SBen Hutchings 222c8f0b869SBen Hutchings /* 223c8f0b869SBen Hutchings * If this is the root switch (i.e. the switch that connects 224c8f0b869SBen Hutchings * to the CPU), return the cpu port number on this switch. 225c8f0b869SBen Hutchings * Else return the (DSA) port number that connects to the 226c8f0b869SBen Hutchings * switch that is one hop closer to the cpu. 227c8f0b869SBen Hutchings */ 228b22de490SVivien Didelot if (dst->cpu_switch == ds) 229c8f0b869SBen Hutchings return dst->cpu_port; 230c8f0b869SBen Hutchings else 231b22de490SVivien Didelot return ds->rtable[dst->cpu_switch->index]; 232c8f0b869SBen Hutchings } 233c8f0b869SBen Hutchings 234146a3206SVivien Didelot struct switchdev_trans; 235ea70ba98SVivien Didelot struct switchdev_obj; 236146a3206SVivien Didelot struct switchdev_obj_port_fdb; 2378df30255SVivien Didelot struct switchdev_obj_port_mdb; 23876e398a6SVivien Didelot struct switchdev_obj_port_vlan; 239146a3206SVivien Didelot 2409d490b4eSVivien Didelot struct dsa_switch_ops { 241c8f0b869SBen Hutchings /* 242c8f0b869SBen Hutchings * Probing and setup. 243c8f0b869SBen Hutchings */ 2440209d144SVivien Didelot const char *(*probe)(struct device *dsa_dev, 2450209d144SVivien Didelot struct device *host_dev, int sw_addr, 2460209d144SVivien Didelot void **priv); 2477b314362SAndrew Lunn 2487b314362SAndrew Lunn enum dsa_tag_protocol (*get_tag_protocol)(struct dsa_switch *ds); 2497b314362SAndrew Lunn 250c8f0b869SBen Hutchings int (*setup)(struct dsa_switch *ds); 251c8f0b869SBen Hutchings int (*set_addr)(struct dsa_switch *ds, u8 *addr); 2526819563eSFlorian Fainelli u32 (*get_phy_flags)(struct dsa_switch *ds, int port); 253c8f0b869SBen Hutchings 254c8f0b869SBen Hutchings /* 255c8f0b869SBen Hutchings * Access to the switch's PHY registers. 256c8f0b869SBen Hutchings */ 257c8f0b869SBen Hutchings int (*phy_read)(struct dsa_switch *ds, int port, int regnum); 258c8f0b869SBen Hutchings int (*phy_write)(struct dsa_switch *ds, int port, 259c8f0b869SBen Hutchings int regnum, u16 val); 260c8f0b869SBen Hutchings 261c8f0b869SBen Hutchings /* 262ec9436baSFlorian Fainelli * Link state adjustment (called from libphy) 263ec9436baSFlorian Fainelli */ 264ec9436baSFlorian Fainelli void (*adjust_link)(struct dsa_switch *ds, int port, 265ec9436baSFlorian Fainelli struct phy_device *phydev); 266ce31b31cSFlorian Fainelli void (*fixed_link_update)(struct dsa_switch *ds, int port, 267ce31b31cSFlorian Fainelli struct fixed_phy_status *st); 268ec9436baSFlorian Fainelli 269ec9436baSFlorian Fainelli /* 270c8f0b869SBen Hutchings * ethtool hardware statistics. 271c8f0b869SBen Hutchings */ 272c8f0b869SBen Hutchings void (*get_strings)(struct dsa_switch *ds, int port, uint8_t *data); 273c8f0b869SBen Hutchings void (*get_ethtool_stats)(struct dsa_switch *ds, 274c8f0b869SBen Hutchings int port, uint64_t *data); 275c8f0b869SBen Hutchings int (*get_sset_count)(struct dsa_switch *ds); 27624462549SFlorian Fainelli 27724462549SFlorian Fainelli /* 27819e57c4eSFlorian Fainelli * ethtool Wake-on-LAN 27919e57c4eSFlorian Fainelli */ 28019e57c4eSFlorian Fainelli void (*get_wol)(struct dsa_switch *ds, int port, 28119e57c4eSFlorian Fainelli struct ethtool_wolinfo *w); 28219e57c4eSFlorian Fainelli int (*set_wol)(struct dsa_switch *ds, int port, 28319e57c4eSFlorian Fainelli struct ethtool_wolinfo *w); 28419e57c4eSFlorian Fainelli 28519e57c4eSFlorian Fainelli /* 28624462549SFlorian Fainelli * Suspend and resume 28724462549SFlorian Fainelli */ 28824462549SFlorian Fainelli int (*suspend)(struct dsa_switch *ds); 28924462549SFlorian Fainelli int (*resume)(struct dsa_switch *ds); 290b2f2af21SFlorian Fainelli 291b2f2af21SFlorian Fainelli /* 292b2f2af21SFlorian Fainelli * Port enable/disable 293b2f2af21SFlorian Fainelli */ 294b2f2af21SFlorian Fainelli int (*port_enable)(struct dsa_switch *ds, int port, 295b2f2af21SFlorian Fainelli struct phy_device *phy); 296b2f2af21SFlorian Fainelli void (*port_disable)(struct dsa_switch *ds, int port, 297b2f2af21SFlorian Fainelli struct phy_device *phy); 2987905288fSFlorian Fainelli 2997905288fSFlorian Fainelli /* 3007905288fSFlorian Fainelli * EEE setttings 3017905288fSFlorian Fainelli */ 3027905288fSFlorian Fainelli int (*set_eee)(struct dsa_switch *ds, int port, 3037905288fSFlorian Fainelli struct phy_device *phydev, 3047905288fSFlorian Fainelli struct ethtool_eee *e); 3057905288fSFlorian Fainelli int (*get_eee)(struct dsa_switch *ds, int port, 3067905288fSFlorian Fainelli struct ethtool_eee *e); 30751579c3fSGuenter Roeck 3086793abb4SGuenter Roeck /* EEPROM access */ 3096793abb4SGuenter Roeck int (*get_eeprom_len)(struct dsa_switch *ds); 3106793abb4SGuenter Roeck int (*get_eeprom)(struct dsa_switch *ds, 3116793abb4SGuenter Roeck struct ethtool_eeprom *eeprom, u8 *data); 3126793abb4SGuenter Roeck int (*set_eeprom)(struct dsa_switch *ds, 3136793abb4SGuenter Roeck struct ethtool_eeprom *eeprom, u8 *data); 3143d762a0fSGuenter Roeck 3153d762a0fSGuenter Roeck /* 3163d762a0fSGuenter Roeck * Register access. 3173d762a0fSGuenter Roeck */ 3183d762a0fSGuenter Roeck int (*get_regs_len)(struct dsa_switch *ds, int port); 3193d762a0fSGuenter Roeck void (*get_regs)(struct dsa_switch *ds, int port, 3203d762a0fSGuenter Roeck struct ethtool_regs *regs, void *p); 321b73adef6SFlorian Fainelli 322b73adef6SFlorian Fainelli /* 323b73adef6SFlorian Fainelli * Bridge integration 324b73adef6SFlorian Fainelli */ 32534a79f63SVivien Didelot int (*set_ageing_time)(struct dsa_switch *ds, unsigned int msecs); 32671327a4eSVivien Didelot int (*port_bridge_join)(struct dsa_switch *ds, int port, 327a6692754SVivien Didelot struct net_device *bridge); 32816bfa702SVivien Didelot void (*port_bridge_leave)(struct dsa_switch *ds, int port); 32943c44a9fSVivien Didelot void (*port_stp_state_set)(struct dsa_switch *ds, int port, 330b73adef6SFlorian Fainelli u8 state); 331732f794cSVivien Didelot void (*port_fast_age)(struct dsa_switch *ds, int port); 3322a778e1bSVivien Didelot 3332a778e1bSVivien Didelot /* 33411149536SVivien Didelot * VLAN support 33511149536SVivien Didelot */ 336fb2dabadSVivien Didelot int (*port_vlan_filtering)(struct dsa_switch *ds, int port, 337fb2dabadSVivien Didelot bool vlan_filtering); 33876e398a6SVivien Didelot int (*port_vlan_prepare)(struct dsa_switch *ds, int port, 33976e398a6SVivien Didelot const struct switchdev_obj_port_vlan *vlan, 34076e398a6SVivien Didelot struct switchdev_trans *trans); 3414d5770b3SVivien Didelot void (*port_vlan_add)(struct dsa_switch *ds, int port, 34276e398a6SVivien Didelot const struct switchdev_obj_port_vlan *vlan, 34376e398a6SVivien Didelot struct switchdev_trans *trans); 34476e398a6SVivien Didelot int (*port_vlan_del)(struct dsa_switch *ds, int port, 34576e398a6SVivien Didelot const struct switchdev_obj_port_vlan *vlan); 34665aebfc0SVivien Didelot int (*port_vlan_dump)(struct dsa_switch *ds, int port, 34765aebfc0SVivien Didelot struct switchdev_obj_port_vlan *vlan, 34865aebfc0SVivien Didelot int (*cb)(struct switchdev_obj *obj)); 34911149536SVivien Didelot 35011149536SVivien Didelot /* 3512a778e1bSVivien Didelot * Forwarding database 3522a778e1bSVivien Didelot */ 353146a3206SVivien Didelot int (*port_fdb_prepare)(struct dsa_switch *ds, int port, 354146a3206SVivien Didelot const struct switchdev_obj_port_fdb *fdb, 355146a3206SVivien Didelot struct switchdev_trans *trans); 3568497aa61SVivien Didelot void (*port_fdb_add)(struct dsa_switch *ds, int port, 3571f36faf2SVivien Didelot const struct switchdev_obj_port_fdb *fdb, 3581f36faf2SVivien Didelot struct switchdev_trans *trans); 3592a778e1bSVivien Didelot int (*port_fdb_del)(struct dsa_switch *ds, int port, 3608057b3e7SVivien Didelot const struct switchdev_obj_port_fdb *fdb); 361ea70ba98SVivien Didelot int (*port_fdb_dump)(struct dsa_switch *ds, int port, 362ea70ba98SVivien Didelot struct switchdev_obj_port_fdb *fdb, 363ea70ba98SVivien Didelot int (*cb)(struct switchdev_obj *obj)); 3648df30255SVivien Didelot 3658df30255SVivien Didelot /* 3668df30255SVivien Didelot * Multicast database 3678df30255SVivien Didelot */ 3688df30255SVivien Didelot int (*port_mdb_prepare)(struct dsa_switch *ds, int port, 3698df30255SVivien Didelot const struct switchdev_obj_port_mdb *mdb, 3708df30255SVivien Didelot struct switchdev_trans *trans); 3718df30255SVivien Didelot void (*port_mdb_add)(struct dsa_switch *ds, int port, 3728df30255SVivien Didelot const struct switchdev_obj_port_mdb *mdb, 3738df30255SVivien Didelot struct switchdev_trans *trans); 3748df30255SVivien Didelot int (*port_mdb_del)(struct dsa_switch *ds, int port, 3758df30255SVivien Didelot const struct switchdev_obj_port_mdb *mdb); 3768df30255SVivien Didelot int (*port_mdb_dump)(struct dsa_switch *ds, int port, 3778df30255SVivien Didelot struct switchdev_obj_port_mdb *mdb, 3788df30255SVivien Didelot int (*cb)(struct switchdev_obj *obj)); 379c8f0b869SBen Hutchings }; 380c8f0b869SBen Hutchings 381ab3d408dSFlorian Fainelli struct dsa_switch_driver { 382ab3d408dSFlorian Fainelli struct list_head list; 383a82f67afSFlorian Fainelli const struct dsa_switch_ops *ops; 384ab3d408dSFlorian Fainelli }; 385ab3d408dSFlorian Fainelli 386ab3d408dSFlorian Fainelli void register_switch_driver(struct dsa_switch_driver *type); 387ab3d408dSFlorian Fainelli void unregister_switch_driver(struct dsa_switch_driver *type); 388b4d2394dSAlexander Duyck struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev); 389c8f0b869SBen Hutchings 3905aed85ceSFlorian Fainelli static inline bool dsa_uses_tagged_protocol(struct dsa_switch_tree *dst) 3915aed85ceSFlorian Fainelli { 3925075314eSAlexander Duyck return dst->rcv != NULL; 3935aed85ceSFlorian Fainelli } 39483c0afaeSAndrew Lunn 395a0c02161SVivien Didelot struct dsa_switch *dsa_switch_alloc(struct device *dev, size_t n); 39683c0afaeSAndrew Lunn void dsa_unregister_switch(struct dsa_switch *ds); 39755ed0ce0SFlorian Fainelli int dsa_register_switch(struct dsa_switch *ds, struct device *dev); 398ea825e70SFlorian Fainelli #ifdef CONFIG_PM_SLEEP 399ea825e70SFlorian Fainelli int dsa_switch_suspend(struct dsa_switch *ds); 400ea825e70SFlorian Fainelli int dsa_switch_resume(struct dsa_switch *ds); 401ea825e70SFlorian Fainelli #else 402ea825e70SFlorian Fainelli static inline int dsa_switch_suspend(struct dsa_switch *ds) 403ea825e70SFlorian Fainelli { 404ea825e70SFlorian Fainelli return 0; 405ea825e70SFlorian Fainelli } 406ea825e70SFlorian Fainelli static inline int dsa_switch_resume(struct dsa_switch *ds) 407ea825e70SFlorian Fainelli { 408ea825e70SFlorian Fainelli return 0; 409ea825e70SFlorian Fainelli } 410ea825e70SFlorian Fainelli #endif /* CONFIG_PM_SLEEP */ 411ea825e70SFlorian Fainelli 41291da11f8SLennert Buytenhek #endif 413