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 23f50f2127SFlorian Fainelli struct tc_action; 24f50f2127SFlorian Fainelli 25ac7a04c3SFlorian Fainelli enum dsa_tag_protocol { 26ac7a04c3SFlorian Fainelli DSA_TAG_PROTO_NONE = 0, 27ac7a04c3SFlorian Fainelli DSA_TAG_PROTO_DSA, 28ac7a04c3SFlorian Fainelli DSA_TAG_PROTO_TRAILER, 29ac7a04c3SFlorian Fainelli DSA_TAG_PROTO_EDSA, 30ac7a04c3SFlorian Fainelli DSA_TAG_PROTO_BRCM, 31cafdc45cSJohn Crispin DSA_TAG_PROTO_QCA, 3239a7f2a4SAndrew Lunn DSA_TAG_LAST, /* MUST BE LAST */ 33ac7a04c3SFlorian Fainelli }; 345037d532SFlorian Fainelli 35e84665c9SLennert Buytenhek #define DSA_MAX_SWITCHES 4 3691da11f8SLennert Buytenhek #define DSA_MAX_PORTS 12 3791da11f8SLennert Buytenhek 38d390238cSVivien Didelot #define DSA_RTABLE_NONE -1 39d390238cSVivien Didelot 40e84665c9SLennert Buytenhek struct dsa_chip_data { 41e84665c9SLennert Buytenhek /* 42e84665c9SLennert Buytenhek * How to access the switch configuration registers. 43e84665c9SLennert Buytenhek */ 44b4d2394dSAlexander Duyck struct device *host_dev; 45e84665c9SLennert Buytenhek int sw_addr; 46e84665c9SLennert Buytenhek 476793abb4SGuenter Roeck /* set to size of eeprom if supported by the switch */ 486793abb4SGuenter Roeck int eeprom_len; 496793abb4SGuenter Roeck 50fa981d9aSFlorian Fainelli /* Device tree node pointer for this specific switch chip 51fa981d9aSFlorian Fainelli * used during switch setup in case additional properties 52fa981d9aSFlorian Fainelli * and resources needs to be used 53fa981d9aSFlorian Fainelli */ 54fa981d9aSFlorian Fainelli struct device_node *of_node; 55fa981d9aSFlorian Fainelli 56e84665c9SLennert Buytenhek /* 57e84665c9SLennert Buytenhek * The names of the switch's ports. Use "cpu" to 58e84665c9SLennert Buytenhek * designate the switch port that the cpu is connected to, 59e84665c9SLennert Buytenhek * "dsa" to indicate that this port is a DSA link to 60e84665c9SLennert Buytenhek * another switch, NULL to indicate the port is unused, 61e84665c9SLennert Buytenhek * or any other string to indicate this is a physical port. 62e84665c9SLennert Buytenhek */ 63e84665c9SLennert Buytenhek char *port_names[DSA_MAX_PORTS]; 64bd47497aSFlorian Fainelli struct device_node *port_dn[DSA_MAX_PORTS]; 65e84665c9SLennert Buytenhek 66e84665c9SLennert Buytenhek /* 674a7704ffSAndrew Lunn * An array of which element [a] indicates which port on this 684a7704ffSAndrew Lunn * switch should be used to send packets to that are destined 694a7704ffSAndrew Lunn * for switch a. Can be NULL if there is only one switch chip. 70e84665c9SLennert Buytenhek */ 714a7704ffSAndrew Lunn s8 rtable[DSA_MAX_SWITCHES]; 72e84665c9SLennert Buytenhek }; 73e84665c9SLennert Buytenhek 7491da11f8SLennert Buytenhek struct dsa_platform_data { 7591da11f8SLennert Buytenhek /* 7691da11f8SLennert Buytenhek * Reference to a Linux network interface that connects 77e84665c9SLennert Buytenhek * to the root switch chip of the tree. 7891da11f8SLennert Buytenhek */ 7991da11f8SLennert Buytenhek struct device *netdev; 80769a0202SFlorian Fainelli struct net_device *of_netdev; 8191da11f8SLennert Buytenhek 8291da11f8SLennert Buytenhek /* 83e84665c9SLennert Buytenhek * Info structs describing each of the switch chips 84e84665c9SLennert Buytenhek * connected via this network interface. 8591da11f8SLennert Buytenhek */ 86e84665c9SLennert Buytenhek int nr_chips; 87e84665c9SLennert Buytenhek struct dsa_chip_data *chip; 8891da11f8SLennert Buytenhek }; 8991da11f8SLennert Buytenhek 905075314eSAlexander Duyck struct packet_type; 913e8a72d1SFlorian Fainelli 92cf50dcc2SBen Hutchings struct dsa_switch_tree { 9383c0afaeSAndrew Lunn struct list_head list; 9483c0afaeSAndrew Lunn 9583c0afaeSAndrew Lunn /* Tree identifier */ 9683c0afaeSAndrew Lunn u32 tree; 9783c0afaeSAndrew Lunn 9883c0afaeSAndrew Lunn /* Number of switches attached to this tree */ 9983c0afaeSAndrew Lunn struct kref refcount; 10083c0afaeSAndrew Lunn 10183c0afaeSAndrew Lunn /* Has this tree been applied to the hardware? */ 10283c0afaeSAndrew Lunn bool applied; 10383c0afaeSAndrew Lunn 104cf50dcc2SBen Hutchings /* 105cf50dcc2SBen Hutchings * Configuration data for the platform device that owns 106cf50dcc2SBen Hutchings * this dsa switch tree instance. 107cf50dcc2SBen Hutchings */ 108cf50dcc2SBen Hutchings struct dsa_platform_data *pd; 109cf85d08fSLennert Buytenhek 110cf50dcc2SBen Hutchings /* 111cf50dcc2SBen Hutchings * Reference to network device to use, and which tagging 112cf50dcc2SBen Hutchings * protocol to use. 113cf50dcc2SBen Hutchings */ 114cf50dcc2SBen Hutchings struct net_device *master_netdev; 1155075314eSAlexander Duyck int (*rcv)(struct sk_buff *skb, 1165075314eSAlexander Duyck struct net_device *dev, 1175075314eSAlexander Duyck struct packet_type *pt, 1185075314eSAlexander Duyck struct net_device *orig_dev); 119cf50dcc2SBen Hutchings 120cf50dcc2SBen Hutchings /* 121badf3adaSFlorian Fainelli * Original copy of the master netdev ethtool_ops 122badf3adaSFlorian Fainelli */ 123badf3adaSFlorian Fainelli struct ethtool_ops master_ethtool_ops; 1240c73c523SFlorian Fainelli const struct ethtool_ops *master_orig_ethtool_ops; 125badf3adaSFlorian Fainelli 126badf3adaSFlorian Fainelli /* 127cf50dcc2SBen Hutchings * The switch and port to which the CPU is attached. 128cf50dcc2SBen Hutchings */ 129b22de490SVivien Didelot struct dsa_switch *cpu_switch; 130cf50dcc2SBen Hutchings s8 cpu_port; 131cf50dcc2SBen Hutchings 132cf50dcc2SBen Hutchings /* 133cf50dcc2SBen Hutchings * Data for the individual switch chips. 134cf50dcc2SBen Hutchings */ 135cf50dcc2SBen Hutchings struct dsa_switch *ds[DSA_MAX_SWITCHES]; 13639a7f2a4SAndrew Lunn 13739a7f2a4SAndrew Lunn /* 13839a7f2a4SAndrew Lunn * Tagging protocol operations for adding and removing an 13939a7f2a4SAndrew Lunn * encapsulation tag. 14039a7f2a4SAndrew Lunn */ 14139a7f2a4SAndrew Lunn const struct dsa_device_ops *tag_ops; 142cf50dcc2SBen Hutchings }; 143cf50dcc2SBen Hutchings 144f50f2127SFlorian Fainelli /* TC matchall action types, only mirroring for now */ 145f50f2127SFlorian Fainelli enum dsa_port_mall_action_type { 146f50f2127SFlorian Fainelli DSA_PORT_MALL_MIRROR, 147f50f2127SFlorian Fainelli }; 148f50f2127SFlorian Fainelli 149f50f2127SFlorian Fainelli /* TC mirroring entry */ 150f50f2127SFlorian Fainelli struct dsa_mall_mirror_tc_entry { 151f50f2127SFlorian Fainelli u8 to_local_port; 152f50f2127SFlorian Fainelli bool ingress; 153f50f2127SFlorian Fainelli }; 154f50f2127SFlorian Fainelli 155f50f2127SFlorian Fainelli /* TC matchall entry */ 156f50f2127SFlorian Fainelli struct dsa_mall_tc_entry { 157f50f2127SFlorian Fainelli struct list_head list; 158f50f2127SFlorian Fainelli unsigned long cookie; 159f50f2127SFlorian Fainelli enum dsa_port_mall_action_type type; 160f50f2127SFlorian Fainelli union { 161f50f2127SFlorian Fainelli struct dsa_mall_mirror_tc_entry mirror; 162f50f2127SFlorian Fainelli }; 163f50f2127SFlorian Fainelli }; 164f50f2127SFlorian Fainelli 165f50f2127SFlorian Fainelli 166c8b09808SAndrew Lunn struct dsa_port { 167818be848SVivien Didelot struct dsa_switch *ds; 168818be848SVivien Didelot unsigned int index; 169c8b09808SAndrew Lunn struct net_device *netdev; 170189b0d93SAndrew Lunn struct device_node *dn; 17134a79f63SVivien Didelot unsigned int ageing_time; 172732f794cSVivien Didelot u8 stp_state; 173a5e9a02eSVivien Didelot struct net_device *bridge_dev; 174c8b09808SAndrew Lunn }; 175c8b09808SAndrew Lunn 176c8f0b869SBen Hutchings struct dsa_switch { 177c33063d6SAndrew Lunn struct device *dev; 178c33063d6SAndrew Lunn 179c8f0b869SBen Hutchings /* 180c8f0b869SBen Hutchings * Parent switch tree, and switch index. 181c8f0b869SBen Hutchings */ 182c8f0b869SBen Hutchings struct dsa_switch_tree *dst; 183c8f0b869SBen Hutchings int index; 184c8f0b869SBen Hutchings 185c8f0b869SBen Hutchings /* 1867543a6d5SAndrew Lunn * Give the switch driver somewhere to hang its private data 1877543a6d5SAndrew Lunn * structure. 1887543a6d5SAndrew Lunn */ 1897543a6d5SAndrew Lunn void *priv; 1907543a6d5SAndrew Lunn 1917543a6d5SAndrew Lunn /* 192c8f0b869SBen Hutchings * Configuration data for this switch. 193c8f0b869SBen Hutchings */ 194ff04955cSAndrew Lunn struct dsa_chip_data *cd; 195c8f0b869SBen Hutchings 196c8f0b869SBen Hutchings /* 1979d490b4eSVivien Didelot * The switch operations. 198c8f0b869SBen Hutchings */ 199a82f67afSFlorian Fainelli const struct dsa_switch_ops *ops; 200c8f0b869SBen Hutchings 20166472fc0SAndrew Lunn /* 20266472fc0SAndrew Lunn * An array of which element [a] indicates which port on this 20366472fc0SAndrew Lunn * switch should be used to send packets to that are destined 20466472fc0SAndrew Lunn * for switch a. Can be NULL if there is only one switch chip. 20566472fc0SAndrew Lunn */ 20666472fc0SAndrew Lunn s8 rtable[DSA_MAX_SWITCHES]; 20766472fc0SAndrew Lunn 208c8f0b869SBen Hutchings /* 20983c0afaeSAndrew Lunn * The lower device this switch uses to talk to the host 21083c0afaeSAndrew Lunn */ 21183c0afaeSAndrew Lunn struct net_device *master_netdev; 21283c0afaeSAndrew Lunn 21383c0afaeSAndrew Lunn /* 214c8f0b869SBen Hutchings * Slave mii_bus and devices for the individual ports. 215c8f0b869SBen Hutchings */ 216c8f0b869SBen Hutchings u32 dsa_port_mask; 21783c0afaeSAndrew Lunn u32 cpu_port_mask; 21874c3e2a5SAndrew Lunn u32 enabled_port_mask; 2190d8bcdd3SFlorian Fainelli u32 phys_mii_mask; 220c8f0b869SBen Hutchings struct mii_bus *slave_mii_bus; 221a0c02161SVivien Didelot 222a0c02161SVivien Didelot /* Dynamically allocated ports, keep last */ 223a0c02161SVivien Didelot size_t num_ports; 224a0c02161SVivien Didelot struct dsa_port ports[]; 225c8f0b869SBen Hutchings }; 226c8f0b869SBen Hutchings 227c8f0b869SBen Hutchings static inline bool dsa_is_cpu_port(struct dsa_switch *ds, int p) 228c8f0b869SBen Hutchings { 229b22de490SVivien Didelot return !!(ds == ds->dst->cpu_switch && p == ds->dst->cpu_port); 230c8f0b869SBen Hutchings } 231c8f0b869SBen Hutchings 23260045cbfSAndrew Lunn static inline bool dsa_is_dsa_port(struct dsa_switch *ds, int p) 23360045cbfSAndrew Lunn { 23460045cbfSAndrew Lunn return !!((ds->dsa_port_mask) & (1 << p)); 23560045cbfSAndrew Lunn } 23660045cbfSAndrew Lunn 237d79d2107SGuenter Roeck static inline bool dsa_is_port_initialized(struct dsa_switch *ds, int p) 238d79d2107SGuenter Roeck { 239c8b09808SAndrew Lunn return ds->enabled_port_mask & (1 << p) && ds->ports[p].netdev; 240d79d2107SGuenter Roeck } 241d79d2107SGuenter Roeck 242c8f0b869SBen Hutchings static inline u8 dsa_upstream_port(struct dsa_switch *ds) 243c8f0b869SBen Hutchings { 244c8f0b869SBen Hutchings struct dsa_switch_tree *dst = ds->dst; 245c8f0b869SBen Hutchings 246c8f0b869SBen Hutchings /* 247c8f0b869SBen Hutchings * If this is the root switch (i.e. the switch that connects 248c8f0b869SBen Hutchings * to the CPU), return the cpu port number on this switch. 249c8f0b869SBen Hutchings * Else return the (DSA) port number that connects to the 250c8f0b869SBen Hutchings * switch that is one hop closer to the cpu. 251c8f0b869SBen Hutchings */ 252b22de490SVivien Didelot if (dst->cpu_switch == ds) 253c8f0b869SBen Hutchings return dst->cpu_port; 254c8f0b869SBen Hutchings else 255b22de490SVivien Didelot return ds->rtable[dst->cpu_switch->index]; 256c8f0b869SBen Hutchings } 257c8f0b869SBen Hutchings 258146a3206SVivien Didelot struct switchdev_trans; 259ea70ba98SVivien Didelot struct switchdev_obj; 260146a3206SVivien Didelot struct switchdev_obj_port_fdb; 2618df30255SVivien Didelot struct switchdev_obj_port_mdb; 26276e398a6SVivien Didelot struct switchdev_obj_port_vlan; 263146a3206SVivien Didelot 2649d490b4eSVivien Didelot struct dsa_switch_ops { 265c8f0b869SBen Hutchings /* 266c8f0b869SBen Hutchings * Probing and setup. 267c8f0b869SBen Hutchings */ 2680209d144SVivien Didelot const char *(*probe)(struct device *dsa_dev, 2690209d144SVivien Didelot struct device *host_dev, int sw_addr, 2700209d144SVivien Didelot void **priv); 2717b314362SAndrew Lunn 2727b314362SAndrew Lunn enum dsa_tag_protocol (*get_tag_protocol)(struct dsa_switch *ds); 2737b314362SAndrew Lunn 274c8f0b869SBen Hutchings int (*setup)(struct dsa_switch *ds); 275c8f0b869SBen Hutchings int (*set_addr)(struct dsa_switch *ds, u8 *addr); 2766819563eSFlorian Fainelli u32 (*get_phy_flags)(struct dsa_switch *ds, int port); 277c8f0b869SBen Hutchings 278c8f0b869SBen Hutchings /* 279c8f0b869SBen Hutchings * Access to the switch's PHY registers. 280c8f0b869SBen Hutchings */ 281c8f0b869SBen Hutchings int (*phy_read)(struct dsa_switch *ds, int port, int regnum); 282c8f0b869SBen Hutchings int (*phy_write)(struct dsa_switch *ds, int port, 283c8f0b869SBen Hutchings int regnum, u16 val); 284c8f0b869SBen Hutchings 285c8f0b869SBen Hutchings /* 286ec9436baSFlorian Fainelli * Link state adjustment (called from libphy) 287ec9436baSFlorian Fainelli */ 288ec9436baSFlorian Fainelli void (*adjust_link)(struct dsa_switch *ds, int port, 289ec9436baSFlorian Fainelli struct phy_device *phydev); 290ce31b31cSFlorian Fainelli void (*fixed_link_update)(struct dsa_switch *ds, int port, 291ce31b31cSFlorian Fainelli struct fixed_phy_status *st); 292ec9436baSFlorian Fainelli 293ec9436baSFlorian Fainelli /* 294c8f0b869SBen Hutchings * ethtool hardware statistics. 295c8f0b869SBen Hutchings */ 296c8f0b869SBen Hutchings void (*get_strings)(struct dsa_switch *ds, int port, uint8_t *data); 297c8f0b869SBen Hutchings void (*get_ethtool_stats)(struct dsa_switch *ds, 298c8f0b869SBen Hutchings int port, uint64_t *data); 299c8f0b869SBen Hutchings int (*get_sset_count)(struct dsa_switch *ds); 30024462549SFlorian Fainelli 30124462549SFlorian Fainelli /* 30219e57c4eSFlorian Fainelli * ethtool Wake-on-LAN 30319e57c4eSFlorian Fainelli */ 30419e57c4eSFlorian Fainelli void (*get_wol)(struct dsa_switch *ds, int port, 30519e57c4eSFlorian Fainelli struct ethtool_wolinfo *w); 30619e57c4eSFlorian Fainelli int (*set_wol)(struct dsa_switch *ds, int port, 30719e57c4eSFlorian Fainelli struct ethtool_wolinfo *w); 30819e57c4eSFlorian Fainelli 30919e57c4eSFlorian Fainelli /* 31024462549SFlorian Fainelli * Suspend and resume 31124462549SFlorian Fainelli */ 31224462549SFlorian Fainelli int (*suspend)(struct dsa_switch *ds); 31324462549SFlorian Fainelli int (*resume)(struct dsa_switch *ds); 314b2f2af21SFlorian Fainelli 315b2f2af21SFlorian Fainelli /* 316b2f2af21SFlorian Fainelli * Port enable/disable 317b2f2af21SFlorian Fainelli */ 318b2f2af21SFlorian Fainelli int (*port_enable)(struct dsa_switch *ds, int port, 319b2f2af21SFlorian Fainelli struct phy_device *phy); 320b2f2af21SFlorian Fainelli void (*port_disable)(struct dsa_switch *ds, int port, 321b2f2af21SFlorian Fainelli struct phy_device *phy); 3227905288fSFlorian Fainelli 3237905288fSFlorian Fainelli /* 3247905288fSFlorian Fainelli * EEE setttings 3257905288fSFlorian Fainelli */ 3267905288fSFlorian Fainelli int (*set_eee)(struct dsa_switch *ds, int port, 3277905288fSFlorian Fainelli struct phy_device *phydev, 3287905288fSFlorian Fainelli struct ethtool_eee *e); 3297905288fSFlorian Fainelli int (*get_eee)(struct dsa_switch *ds, int port, 3307905288fSFlorian Fainelli struct ethtool_eee *e); 33151579c3fSGuenter Roeck 3326793abb4SGuenter Roeck /* EEPROM access */ 3336793abb4SGuenter Roeck int (*get_eeprom_len)(struct dsa_switch *ds); 3346793abb4SGuenter Roeck int (*get_eeprom)(struct dsa_switch *ds, 3356793abb4SGuenter Roeck struct ethtool_eeprom *eeprom, u8 *data); 3366793abb4SGuenter Roeck int (*set_eeprom)(struct dsa_switch *ds, 3376793abb4SGuenter Roeck struct ethtool_eeprom *eeprom, u8 *data); 3383d762a0fSGuenter Roeck 3393d762a0fSGuenter Roeck /* 3403d762a0fSGuenter Roeck * Register access. 3413d762a0fSGuenter Roeck */ 3423d762a0fSGuenter Roeck int (*get_regs_len)(struct dsa_switch *ds, int port); 3433d762a0fSGuenter Roeck void (*get_regs)(struct dsa_switch *ds, int port, 3443d762a0fSGuenter Roeck struct ethtool_regs *regs, void *p); 345b73adef6SFlorian Fainelli 346b73adef6SFlorian Fainelli /* 347b73adef6SFlorian Fainelli * Bridge integration 348b73adef6SFlorian Fainelli */ 34934a79f63SVivien Didelot int (*set_ageing_time)(struct dsa_switch *ds, unsigned int msecs); 35071327a4eSVivien Didelot int (*port_bridge_join)(struct dsa_switch *ds, int port, 351a6692754SVivien Didelot struct net_device *bridge); 352f123f2fbSVivien Didelot void (*port_bridge_leave)(struct dsa_switch *ds, int port, 353f123f2fbSVivien Didelot struct net_device *bridge); 35443c44a9fSVivien Didelot void (*port_stp_state_set)(struct dsa_switch *ds, int port, 355b73adef6SFlorian Fainelli u8 state); 356732f794cSVivien Didelot void (*port_fast_age)(struct dsa_switch *ds, int port); 3572a778e1bSVivien Didelot 3582a778e1bSVivien Didelot /* 35911149536SVivien Didelot * VLAN support 36011149536SVivien Didelot */ 361fb2dabadSVivien Didelot int (*port_vlan_filtering)(struct dsa_switch *ds, int port, 362fb2dabadSVivien Didelot bool vlan_filtering); 36376e398a6SVivien Didelot int (*port_vlan_prepare)(struct dsa_switch *ds, int port, 36476e398a6SVivien Didelot const struct switchdev_obj_port_vlan *vlan, 36576e398a6SVivien Didelot struct switchdev_trans *trans); 3664d5770b3SVivien Didelot void (*port_vlan_add)(struct dsa_switch *ds, int port, 36776e398a6SVivien Didelot const struct switchdev_obj_port_vlan *vlan, 36876e398a6SVivien Didelot struct switchdev_trans *trans); 36976e398a6SVivien Didelot int (*port_vlan_del)(struct dsa_switch *ds, int port, 37076e398a6SVivien Didelot const struct switchdev_obj_port_vlan *vlan); 37165aebfc0SVivien Didelot int (*port_vlan_dump)(struct dsa_switch *ds, int port, 37265aebfc0SVivien Didelot struct switchdev_obj_port_vlan *vlan, 37365aebfc0SVivien Didelot int (*cb)(struct switchdev_obj *obj)); 37411149536SVivien Didelot 37511149536SVivien Didelot /* 3762a778e1bSVivien Didelot * Forwarding database 3772a778e1bSVivien Didelot */ 378146a3206SVivien Didelot int (*port_fdb_prepare)(struct dsa_switch *ds, int port, 379146a3206SVivien Didelot const struct switchdev_obj_port_fdb *fdb, 380146a3206SVivien Didelot struct switchdev_trans *trans); 3818497aa61SVivien Didelot void (*port_fdb_add)(struct dsa_switch *ds, int port, 3821f36faf2SVivien Didelot const struct switchdev_obj_port_fdb *fdb, 3831f36faf2SVivien Didelot struct switchdev_trans *trans); 3842a778e1bSVivien Didelot int (*port_fdb_del)(struct dsa_switch *ds, int port, 3858057b3e7SVivien Didelot const struct switchdev_obj_port_fdb *fdb); 386ea70ba98SVivien Didelot int (*port_fdb_dump)(struct dsa_switch *ds, int port, 387ea70ba98SVivien Didelot struct switchdev_obj_port_fdb *fdb, 388ea70ba98SVivien Didelot int (*cb)(struct switchdev_obj *obj)); 3898df30255SVivien Didelot 3908df30255SVivien Didelot /* 3918df30255SVivien Didelot * Multicast database 3928df30255SVivien Didelot */ 3938df30255SVivien Didelot int (*port_mdb_prepare)(struct dsa_switch *ds, int port, 3948df30255SVivien Didelot const struct switchdev_obj_port_mdb *mdb, 3958df30255SVivien Didelot struct switchdev_trans *trans); 3968df30255SVivien Didelot void (*port_mdb_add)(struct dsa_switch *ds, int port, 3978df30255SVivien Didelot const struct switchdev_obj_port_mdb *mdb, 3988df30255SVivien Didelot struct switchdev_trans *trans); 3998df30255SVivien Didelot int (*port_mdb_del)(struct dsa_switch *ds, int port, 4008df30255SVivien Didelot const struct switchdev_obj_port_mdb *mdb); 4018df30255SVivien Didelot int (*port_mdb_dump)(struct dsa_switch *ds, int port, 4028df30255SVivien Didelot struct switchdev_obj_port_mdb *mdb, 4038df30255SVivien Didelot int (*cb)(struct switchdev_obj *obj)); 404bf9f2648SFlorian Fainelli 405bf9f2648SFlorian Fainelli /* 406bf9f2648SFlorian Fainelli * RXNFC 407bf9f2648SFlorian Fainelli */ 408bf9f2648SFlorian Fainelli int (*get_rxnfc)(struct dsa_switch *ds, int port, 409bf9f2648SFlorian Fainelli struct ethtool_rxnfc *nfc, u32 *rule_locs); 410bf9f2648SFlorian Fainelli int (*set_rxnfc)(struct dsa_switch *ds, int port, 411bf9f2648SFlorian Fainelli struct ethtool_rxnfc *nfc); 412f50f2127SFlorian Fainelli 413f50f2127SFlorian Fainelli /* 414f50f2127SFlorian Fainelli * TC integration 415f50f2127SFlorian Fainelli */ 416f50f2127SFlorian Fainelli int (*port_mirror_add)(struct dsa_switch *ds, int port, 417f50f2127SFlorian Fainelli struct dsa_mall_mirror_tc_entry *mirror, 418f50f2127SFlorian Fainelli bool ingress); 419f50f2127SFlorian Fainelli void (*port_mirror_del)(struct dsa_switch *ds, int port, 420f50f2127SFlorian Fainelli struct dsa_mall_mirror_tc_entry *mirror); 421c8f0b869SBen Hutchings }; 422c8f0b869SBen Hutchings 423ab3d408dSFlorian Fainelli struct dsa_switch_driver { 424ab3d408dSFlorian Fainelli struct list_head list; 425a82f67afSFlorian Fainelli const struct dsa_switch_ops *ops; 426ab3d408dSFlorian Fainelli }; 427ab3d408dSFlorian Fainelli 428ab3d408dSFlorian Fainelli void register_switch_driver(struct dsa_switch_driver *type); 429ab3d408dSFlorian Fainelli void unregister_switch_driver(struct dsa_switch_driver *type); 430b4d2394dSAlexander Duyck struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev); 431c8f0b869SBen Hutchings 4325aed85ceSFlorian Fainelli static inline bool dsa_uses_tagged_protocol(struct dsa_switch_tree *dst) 4335aed85ceSFlorian Fainelli { 4345075314eSAlexander Duyck return dst->rcv != NULL; 4355aed85ceSFlorian Fainelli } 43683c0afaeSAndrew Lunn 437a0c02161SVivien Didelot struct dsa_switch *dsa_switch_alloc(struct device *dev, size_t n); 43883c0afaeSAndrew Lunn void dsa_unregister_switch(struct dsa_switch *ds); 43955ed0ce0SFlorian Fainelli int dsa_register_switch(struct dsa_switch *ds, struct device *dev); 440ea825e70SFlorian Fainelli #ifdef CONFIG_PM_SLEEP 441ea825e70SFlorian Fainelli int dsa_switch_suspend(struct dsa_switch *ds); 442ea825e70SFlorian Fainelli int dsa_switch_resume(struct dsa_switch *ds); 443ea825e70SFlorian Fainelli #else 444ea825e70SFlorian Fainelli static inline int dsa_switch_suspend(struct dsa_switch *ds) 445ea825e70SFlorian Fainelli { 446ea825e70SFlorian Fainelli return 0; 447ea825e70SFlorian Fainelli } 448ea825e70SFlorian Fainelli static inline int dsa_switch_resume(struct dsa_switch *ds) 449ea825e70SFlorian Fainelli { 450ea825e70SFlorian Fainelli return 0; 451ea825e70SFlorian Fainelli } 452ea825e70SFlorian Fainelli #endif /* CONFIG_PM_SLEEP */ 453ea825e70SFlorian Fainelli 45491da11f8SLennert Buytenhek #endif 455