12874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 291da11f8SLennert Buytenhek /* 391da11f8SLennert Buytenhek * include/net/dsa.h - Driver for Distributed Switch Architecture switch chips 4e84665c9SLennert Buytenhek * Copyright (c) 2008-2009 Marvell Semiconductor 591da11f8SLennert Buytenhek */ 691da11f8SLennert Buytenhek 791da11f8SLennert Buytenhek #ifndef __LINUX_NET_DSA_H 891da11f8SLennert Buytenhek #define __LINUX_NET_DSA_H 991da11f8SLennert Buytenhek 104d56a29fSRussell King #include <linux/if.h> 11ea1f51beSAxel Lin #include <linux/if_ether.h> 12c8f0b869SBen Hutchings #include <linux/list.h> 13f515f192SVivien Didelot #include <linux/notifier.h> 14cf50dcc2SBen Hutchings #include <linux/timer.h> 15cf50dcc2SBen Hutchings #include <linux/workqueue.h> 16fa981d9aSFlorian Fainelli #include <linux/of.h> 17a2820543SFlorian Fainelli #include <linux/ethtool.h> 180336369dSBrandon Streiff #include <linux/net_tstamp.h> 1911d8f3ddSFlorian Fainelli #include <linux/phy.h> 20ecfc9372SFlorian Fainelli #include <linux/platform_data/dsa.h> 2144cc27e4SIoana Ciornei #include <linux/phylink.h> 2296567d5dSAndrew Lunn #include <net/devlink.h> 23f0c24ccfSVivien Didelot #include <net/switchdev.h> 24cf50dcc2SBen Hutchings 25f50f2127SFlorian Fainelli struct tc_action; 264d56a29fSRussell King struct phy_device; 274d56a29fSRussell King struct fixed_phy_status; 2811d8f3ddSFlorian Fainelli struct phylink_link_state; 29f50f2127SFlorian Fainelli 300b42f033SAndrew Lunn #define DSA_TAG_PROTO_NONE_VALUE 0 310b42f033SAndrew Lunn #define DSA_TAG_PROTO_BRCM_VALUE 1 320b42f033SAndrew Lunn #define DSA_TAG_PROTO_BRCM_PREPEND_VALUE 2 330b42f033SAndrew Lunn #define DSA_TAG_PROTO_DSA_VALUE 3 340b42f033SAndrew Lunn #define DSA_TAG_PROTO_EDSA_VALUE 4 350b42f033SAndrew Lunn #define DSA_TAG_PROTO_GSWIP_VALUE 5 360b42f033SAndrew Lunn #define DSA_TAG_PROTO_KSZ9477_VALUE 6 370b42f033SAndrew Lunn #define DSA_TAG_PROTO_KSZ9893_VALUE 7 380b42f033SAndrew Lunn #define DSA_TAG_PROTO_LAN9303_VALUE 8 390b42f033SAndrew Lunn #define DSA_TAG_PROTO_MTK_VALUE 9 400b42f033SAndrew Lunn #define DSA_TAG_PROTO_QCA_VALUE 10 410b42f033SAndrew Lunn #define DSA_TAG_PROTO_TRAILER_VALUE 11 42f9bbe447SVladimir Oltean #define DSA_TAG_PROTO_8021Q_VALUE 12 43227d07a0SVladimir Oltean #define DSA_TAG_PROTO_SJA1105_VALUE 13 44016e43a2STristram Ha #define DSA_TAG_PROTO_KSZ8795_VALUE 14 450b42f033SAndrew Lunn 46ac7a04c3SFlorian Fainelli enum dsa_tag_protocol { 470b42f033SAndrew Lunn DSA_TAG_PROTO_NONE = DSA_TAG_PROTO_NONE_VALUE, 480b42f033SAndrew Lunn DSA_TAG_PROTO_BRCM = DSA_TAG_PROTO_BRCM_VALUE, 490b42f033SAndrew Lunn DSA_TAG_PROTO_BRCM_PREPEND = DSA_TAG_PROTO_BRCM_PREPEND_VALUE, 500b42f033SAndrew Lunn DSA_TAG_PROTO_DSA = DSA_TAG_PROTO_DSA_VALUE, 510b42f033SAndrew Lunn DSA_TAG_PROTO_EDSA = DSA_TAG_PROTO_EDSA_VALUE, 520b42f033SAndrew Lunn DSA_TAG_PROTO_GSWIP = DSA_TAG_PROTO_GSWIP_VALUE, 530b42f033SAndrew Lunn DSA_TAG_PROTO_KSZ9477 = DSA_TAG_PROTO_KSZ9477_VALUE, 540b42f033SAndrew Lunn DSA_TAG_PROTO_KSZ9893 = DSA_TAG_PROTO_KSZ9893_VALUE, 550b42f033SAndrew Lunn DSA_TAG_PROTO_LAN9303 = DSA_TAG_PROTO_LAN9303_VALUE, 560b42f033SAndrew Lunn DSA_TAG_PROTO_MTK = DSA_TAG_PROTO_MTK_VALUE, 570b42f033SAndrew Lunn DSA_TAG_PROTO_QCA = DSA_TAG_PROTO_QCA_VALUE, 580b42f033SAndrew Lunn DSA_TAG_PROTO_TRAILER = DSA_TAG_PROTO_TRAILER_VALUE, 59f9bbe447SVladimir Oltean DSA_TAG_PROTO_8021Q = DSA_TAG_PROTO_8021Q_VALUE, 60227d07a0SVladimir Oltean DSA_TAG_PROTO_SJA1105 = DSA_TAG_PROTO_SJA1105_VALUE, 61016e43a2STristram Ha DSA_TAG_PROTO_KSZ8795 = DSA_TAG_PROTO_KSZ8795_VALUE, 62ac7a04c3SFlorian Fainelli }; 635037d532SFlorian Fainelli 645075314eSAlexander Duyck struct packet_type; 6590af1059SBrandon Streiff struct dsa_switch; 663e8a72d1SFlorian Fainelli 6768277a2cSJohn Crispin struct dsa_device_ops { 6868277a2cSJohn Crispin struct sk_buff *(*xmit)(struct sk_buff *skb, struct net_device *dev); 6968277a2cSJohn Crispin struct sk_buff *(*rcv)(struct sk_buff *skb, struct net_device *dev, 7089e49506SFlorian Westphal struct packet_type *pt); 71598a9680SJohn Crispin int (*flow_dissect)(const struct sk_buff *skb, __be16 *proto, 72598a9680SJohn Crispin int *offset); 73cc1939e4SVladimir Oltean /* Used to determine which traffic should match the DSA filter in 74cc1939e4SVladimir Oltean * eth_type_trans, and which, if any, should bypass it and be processed 75cc1939e4SVladimir Oltean * as regular on the master net device. 76cc1939e4SVladimir Oltean */ 77cc1939e4SVladimir Oltean bool (*filter)(const struct sk_buff *skb, struct net_device *dev); 78a5dd3087SAndrew Lunn unsigned int overhead; 79875138f8SAndrew Lunn const char *name; 80056eed2fSAndrew Lunn enum dsa_tag_protocol proto; 8168277a2cSJohn Crispin }; 8268277a2cSJohn Crispin 830b42f033SAndrew Lunn #define DSA_TAG_DRIVER_ALIAS "dsa_tag-" 840b42f033SAndrew Lunn #define MODULE_ALIAS_DSA_TAG_DRIVER(__proto) \ 850b42f033SAndrew Lunn MODULE_ALIAS(DSA_TAG_DRIVER_ALIAS __stringify(__proto##_VALUE)) 860b42f033SAndrew Lunn 87b68b0dd0SVladimir Oltean struct dsa_skb_cb { 88b68b0dd0SVladimir Oltean struct sk_buff *clone; 8997a69a0dSVladimir Oltean bool deferred_xmit; 90b68b0dd0SVladimir Oltean }; 91b68b0dd0SVladimir Oltean 92b68b0dd0SVladimir Oltean struct __dsa_skb_cb { 93b68b0dd0SVladimir Oltean struct dsa_skb_cb cb; 94b68b0dd0SVladimir Oltean u8 priv[48 - sizeof(struct dsa_skb_cb)]; 95b68b0dd0SVladimir Oltean }; 96b68b0dd0SVladimir Oltean 97b68b0dd0SVladimir Oltean #define DSA_SKB_CB(skb) ((struct dsa_skb_cb *)((skb)->cb)) 98b68b0dd0SVladimir Oltean 99b68b0dd0SVladimir Oltean #define DSA_SKB_CB_PRIV(skb) \ 100b68b0dd0SVladimir Oltean ((void *)(skb)->cb + offsetof(struct __dsa_skb_cb, priv)) 101b68b0dd0SVladimir Oltean 102cf50dcc2SBen Hutchings struct dsa_switch_tree { 10383c0afaeSAndrew Lunn struct list_head list; 10483c0afaeSAndrew Lunn 105f515f192SVivien Didelot /* Notifier chain for switch-wide events */ 106f515f192SVivien Didelot struct raw_notifier_head nh; 107f515f192SVivien Didelot 10883c0afaeSAndrew Lunn /* Tree identifier */ 10949463b7fSVivien Didelot unsigned int index; 11083c0afaeSAndrew Lunn 11183c0afaeSAndrew Lunn /* Number of switches attached to this tree */ 11283c0afaeSAndrew Lunn struct kref refcount; 11383c0afaeSAndrew Lunn 11483c0afaeSAndrew Lunn /* Has this tree been applied to the hardware? */ 115ec15dd42SVivien Didelot bool setup; 11683c0afaeSAndrew Lunn 117cf50dcc2SBen Hutchings /* 118cf50dcc2SBen Hutchings * Configuration data for the platform device that owns 119cf50dcc2SBen Hutchings * this dsa switch tree instance. 120cf50dcc2SBen Hutchings */ 121cf50dcc2SBen Hutchings struct dsa_platform_data *pd; 122cf85d08fSLennert Buytenhek 123cf50dcc2SBen Hutchings /* 1248b0d3ea5SVivien Didelot * The switch port to which the CPU is attached. 125cf50dcc2SBen Hutchings */ 1268b0d3ea5SVivien Didelot struct dsa_port *cpu_dp; 127cf50dcc2SBen Hutchings 128*ab8ccae1SVivien Didelot /* List of switch ports */ 129*ab8ccae1SVivien Didelot struct list_head ports; 130*ab8ccae1SVivien Didelot 131cf50dcc2SBen Hutchings /* 132cf50dcc2SBen Hutchings * Data for the individual switch chips. 133cf50dcc2SBen Hutchings */ 134cf50dcc2SBen Hutchings struct dsa_switch *ds[DSA_MAX_SWITCHES]; 135cf50dcc2SBen Hutchings }; 136cf50dcc2SBen Hutchings 137f50f2127SFlorian Fainelli /* TC matchall action types, only mirroring for now */ 138f50f2127SFlorian Fainelli enum dsa_port_mall_action_type { 139f50f2127SFlorian Fainelli DSA_PORT_MALL_MIRROR, 140f50f2127SFlorian Fainelli }; 141f50f2127SFlorian Fainelli 142f50f2127SFlorian Fainelli /* TC mirroring entry */ 143f50f2127SFlorian Fainelli struct dsa_mall_mirror_tc_entry { 144f50f2127SFlorian Fainelli u8 to_local_port; 145f50f2127SFlorian Fainelli bool ingress; 146f50f2127SFlorian Fainelli }; 147f50f2127SFlorian Fainelli 148f50f2127SFlorian Fainelli /* TC matchall entry */ 149f50f2127SFlorian Fainelli struct dsa_mall_tc_entry { 150f50f2127SFlorian Fainelli struct list_head list; 151f50f2127SFlorian Fainelli unsigned long cookie; 152f50f2127SFlorian Fainelli enum dsa_port_mall_action_type type; 153f50f2127SFlorian Fainelli union { 154f50f2127SFlorian Fainelli struct dsa_mall_mirror_tc_entry mirror; 155f50f2127SFlorian Fainelli }; 156f50f2127SFlorian Fainelli }; 157f50f2127SFlorian Fainelli 158f50f2127SFlorian Fainelli 159c8b09808SAndrew Lunn struct dsa_port { 160f8b8b1cdSVivien Didelot /* A CPU port is physically connected to a master device. 161f8b8b1cdSVivien Didelot * A user port exposed to userspace has a slave device. 162f8b8b1cdSVivien Didelot */ 163f8b8b1cdSVivien Didelot union { 164f8b8b1cdSVivien Didelot struct net_device *master; 165f8b8b1cdSVivien Didelot struct net_device *slave; 166f8b8b1cdSVivien Didelot }; 167f8b8b1cdSVivien Didelot 16815240248SVivien Didelot /* CPU port tagging operations used by master or slave devices */ 16915240248SVivien Didelot const struct dsa_device_ops *tag_ops; 17015240248SVivien Didelot 1713e41f93bSVivien Didelot /* Copies for faster access in master receive hot path */ 1723e41f93bSVivien Didelot struct dsa_switch_tree *dst; 1733e41f93bSVivien Didelot struct sk_buff *(*rcv)(struct sk_buff *skb, struct net_device *dev, 1743e41f93bSVivien Didelot struct packet_type *pt); 175cc1939e4SVladimir Oltean bool (*filter)(const struct sk_buff *skb, struct net_device *dev); 1763e41f93bSVivien Didelot 177057cad2cSVivien Didelot enum { 178057cad2cSVivien Didelot DSA_PORT_TYPE_UNUSED = 0, 179057cad2cSVivien Didelot DSA_PORT_TYPE_CPU, 180057cad2cSVivien Didelot DSA_PORT_TYPE_DSA, 181057cad2cSVivien Didelot DSA_PORT_TYPE_USER, 182057cad2cSVivien Didelot } type; 183057cad2cSVivien Didelot 184818be848SVivien Didelot struct dsa_switch *ds; 185818be848SVivien Didelot unsigned int index; 18671e0bbdeSFlorian Fainelli const char *name; 18768b2d4a8SVivien Didelot struct dsa_port *cpu_dp; 188a2c7023fSXiaofei Shen const char *mac; 189189b0d93SAndrew Lunn struct device_node *dn; 19034a79f63SVivien Didelot unsigned int ageing_time; 19133162e9aSVladimir Oltean bool vlan_filtering; 192732f794cSVivien Didelot u8 stp_state; 193a5e9a02eSVivien Didelot struct net_device *bridge_dev; 19496567d5dSAndrew Lunn struct devlink_port devlink_port; 195aab9c406SFlorian Fainelli struct phylink *pl; 19644cc27e4SIoana Ciornei struct phylink_config pl_config; 19797a69a0dSVladimir Oltean 19897a69a0dSVladimir Oltean struct work_struct xmit_work; 19997a69a0dSVladimir Oltean struct sk_buff_head xmit_queue; 20097a69a0dSVladimir Oltean 201*ab8ccae1SVivien Didelot struct list_head list; 202*ab8ccae1SVivien Didelot 20367dbb9d4SFlorian Fainelli /* 204c362beb0SVladimir Oltean * Give the switch driver somewhere to hang its per-port private data 205c362beb0SVladimir Oltean * structures (accessible from the tagger). 206c362beb0SVladimir Oltean */ 207c362beb0SVladimir Oltean void *priv; 208c362beb0SVladimir Oltean 209c362beb0SVladimir Oltean /* 21067dbb9d4SFlorian Fainelli * Original copy of the master netdev ethtool_ops 21167dbb9d4SFlorian Fainelli */ 21267dbb9d4SFlorian Fainelli const struct ethtool_ops *orig_ethtool_ops; 213da7b9e9bSFlorian Fainelli 214da7b9e9bSFlorian Fainelli /* 215da7b9e9bSFlorian Fainelli * Original copy of the master netdev net_device_ops 216da7b9e9bSFlorian Fainelli */ 217da7b9e9bSFlorian Fainelli const struct net_device_ops *orig_ndo_ops; 218c8b09808SAndrew Lunn }; 219c8b09808SAndrew Lunn 220c8f0b869SBen Hutchings struct dsa_switch { 221c33063d6SAndrew Lunn struct device *dev; 222c33063d6SAndrew Lunn 223c8f0b869SBen Hutchings /* 224c8f0b869SBen Hutchings * Parent switch tree, and switch index. 225c8f0b869SBen Hutchings */ 226c8f0b869SBen Hutchings struct dsa_switch_tree *dst; 22799feaafcSVivien Didelot unsigned int index; 228c8f0b869SBen Hutchings 229f515f192SVivien Didelot /* Listener for switch fabric events */ 230f515f192SVivien Didelot struct notifier_block nb; 231f515f192SVivien Didelot 232c8f0b869SBen Hutchings /* 2337543a6d5SAndrew Lunn * Give the switch driver somewhere to hang its private data 2347543a6d5SAndrew Lunn * structure. 2357543a6d5SAndrew Lunn */ 2367543a6d5SAndrew Lunn void *priv; 2377543a6d5SAndrew Lunn 2387543a6d5SAndrew Lunn /* 239c8f0b869SBen Hutchings * Configuration data for this switch. 240c8f0b869SBen Hutchings */ 241ff04955cSAndrew Lunn struct dsa_chip_data *cd; 242c8f0b869SBen Hutchings 243c8f0b869SBen Hutchings /* 2449d490b4eSVivien Didelot * The switch operations. 245c8f0b869SBen Hutchings */ 246a82f67afSFlorian Fainelli const struct dsa_switch_ops *ops; 247c8f0b869SBen Hutchings 24866472fc0SAndrew Lunn /* 24966472fc0SAndrew Lunn * An array of which element [a] indicates which port on this 25066472fc0SAndrew Lunn * switch should be used to send packets to that are destined 25166472fc0SAndrew Lunn * for switch a. Can be NULL if there is only one switch chip. 25266472fc0SAndrew Lunn */ 25366472fc0SAndrew Lunn s8 rtable[DSA_MAX_SWITCHES]; 25466472fc0SAndrew Lunn 255c8f0b869SBen Hutchings /* 256c8f0b869SBen Hutchings * Slave mii_bus and devices for the individual ports. 257c8f0b869SBen Hutchings */ 2580d8bcdd3SFlorian Fainelli u32 phys_mii_mask; 259c8f0b869SBen Hutchings struct mii_bus *slave_mii_bus; 260a0c02161SVivien Didelot 2610f3da6afSVivien Didelot /* Ageing Time limits in msecs */ 2620f3da6afSVivien Didelot unsigned int ageing_time_min; 2630f3da6afSVivien Didelot unsigned int ageing_time_max; 2640f3da6afSVivien Didelot 26596567d5dSAndrew Lunn /* devlink used to represent this switch device */ 26696567d5dSAndrew Lunn struct devlink *devlink; 26796567d5dSAndrew Lunn 26855199df6SFlorian Fainelli /* Number of switch port queues */ 26955199df6SFlorian Fainelli unsigned int num_tx_queues; 27055199df6SFlorian Fainelli 2718f5d16f6SVladimir Oltean /* Disallow bridge core from requesting different VLAN awareness 2728f5d16f6SVladimir Oltean * settings on ports if not hardware-supported 2738f5d16f6SVladimir Oltean */ 2748f5d16f6SVladimir Oltean bool vlan_filtering_is_global; 2758f5d16f6SVladimir Oltean 27614574676SVladimir Oltean /* In case vlan_filtering_is_global is set, the VLAN awareness state 27714574676SVladimir Oltean * should be retrieved from here and not from the per-port settings. 27814574676SVladimir Oltean */ 27914574676SVladimir Oltean bool vlan_filtering; 28014574676SVladimir Oltean 281a0c02161SVivien Didelot /* Dynamically allocated ports, keep last */ 282a0c02161SVivien Didelot size_t num_ports; 283a0c02161SVivien Didelot struct dsa_port ports[]; 284c8f0b869SBen Hutchings }; 285c8f0b869SBen Hutchings 28668bb8ea8SVivien Didelot static inline struct dsa_port *dsa_to_port(struct dsa_switch *ds, int p) 287c38c5a66SVivien Didelot { 288c38c5a66SVivien Didelot return &ds->ports[p]; 289c38c5a66SVivien Didelot } 290c38c5a66SVivien Didelot 291bff7b688SVivien Didelot static inline bool dsa_is_unused_port(struct dsa_switch *ds, int p) 292bff7b688SVivien Didelot { 293c38c5a66SVivien Didelot return dsa_to_port(ds, p)->type == DSA_PORT_TYPE_UNUSED; 294bff7b688SVivien Didelot } 295bff7b688SVivien Didelot 296c8f0b869SBen Hutchings static inline bool dsa_is_cpu_port(struct dsa_switch *ds, int p) 297c8f0b869SBen Hutchings { 298c38c5a66SVivien Didelot return dsa_to_port(ds, p)->type == DSA_PORT_TYPE_CPU; 299c8f0b869SBen Hutchings } 300c8f0b869SBen Hutchings 30160045cbfSAndrew Lunn static inline bool dsa_is_dsa_port(struct dsa_switch *ds, int p) 30260045cbfSAndrew Lunn { 303c38c5a66SVivien Didelot return dsa_to_port(ds, p)->type == DSA_PORT_TYPE_DSA; 30460045cbfSAndrew Lunn } 30560045cbfSAndrew Lunn 3062b3e9891SVivien Didelot static inline bool dsa_is_user_port(struct dsa_switch *ds, int p) 3076cd456f3SVivien Didelot { 308c38c5a66SVivien Didelot return dsa_to_port(ds, p)->type == DSA_PORT_TYPE_USER; 3096cd456f3SVivien Didelot } 3106cd456f3SVivien Didelot 31102bc6e54SVivien Didelot static inline u32 dsa_user_ports(struct dsa_switch *ds) 31202bc6e54SVivien Didelot { 313c38c5a66SVivien Didelot u32 mask = 0; 314c38c5a66SVivien Didelot int p; 31502bc6e54SVivien Didelot 316c38c5a66SVivien Didelot for (p = 0; p < ds->num_ports; p++) 317c38c5a66SVivien Didelot if (dsa_is_user_port(ds, p)) 318c38c5a66SVivien Didelot mask |= BIT(p); 319c38c5a66SVivien Didelot 320c38c5a66SVivien Didelot return mask; 321c8652c83SVivien Didelot } 322c8652c83SVivien Didelot 3233b8fac5dSVivien Didelot /* Return the local port used to reach an arbitrary switch port */ 3243b8fac5dSVivien Didelot static inline unsigned int dsa_towards_port(struct dsa_switch *ds, int device, 3253b8fac5dSVivien Didelot int port) 3263b8fac5dSVivien Didelot { 3273b8fac5dSVivien Didelot if (device == ds->index) 3283b8fac5dSVivien Didelot return port; 3293b8fac5dSVivien Didelot else 3303b8fac5dSVivien Didelot return ds->rtable[device]; 3313b8fac5dSVivien Didelot } 3323b8fac5dSVivien Didelot 3333b8fac5dSVivien Didelot /* Return the local port used to reach the dedicated CPU port */ 33407073c79SVivien Didelot static inline unsigned int dsa_upstream_port(struct dsa_switch *ds, int port) 335c8f0b869SBen Hutchings { 33607073c79SVivien Didelot const struct dsa_port *dp = dsa_to_port(ds, port); 33707073c79SVivien Didelot const struct dsa_port *cpu_dp = dp->cpu_dp; 33807073c79SVivien Didelot 33907073c79SVivien Didelot if (!cpu_dp) 34007073c79SVivien Didelot return port; 341c8f0b869SBen Hutchings 3423b8fac5dSVivien Didelot return dsa_towards_port(ds, cpu_dp->ds->index, cpu_dp->index); 343c8f0b869SBen Hutchings } 344c8f0b869SBen Hutchings 345cf2d45f5SVladimir Oltean static inline bool dsa_port_is_vlan_filtering(const struct dsa_port *dp) 346cf2d45f5SVladimir Oltean { 347cf2d45f5SVladimir Oltean const struct dsa_switch *ds = dp->ds; 348cf2d45f5SVladimir Oltean 349cf2d45f5SVladimir Oltean if (ds->vlan_filtering_is_global) 350cf2d45f5SVladimir Oltean return ds->vlan_filtering; 351cf2d45f5SVladimir Oltean else 352cf2d45f5SVladimir Oltean return dp->vlan_filtering; 353cf2d45f5SVladimir Oltean } 354cf2d45f5SVladimir Oltean 3552bedde1aSArkadi Sharshevsky typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid, 3562bedde1aSArkadi Sharshevsky bool is_static, void *data); 3579d490b4eSVivien Didelot struct dsa_switch_ops { 3585ed4e3ebSFlorian Fainelli enum dsa_tag_protocol (*get_tag_protocol)(struct dsa_switch *ds, 3595ed4e3ebSFlorian Fainelli int port); 3607b314362SAndrew Lunn 361c8f0b869SBen Hutchings int (*setup)(struct dsa_switch *ds); 3625e3f847aSVladimir Oltean void (*teardown)(struct dsa_switch *ds); 3636819563eSFlorian Fainelli u32 (*get_phy_flags)(struct dsa_switch *ds, int port); 364c8f0b869SBen Hutchings 365c8f0b869SBen Hutchings /* 366c8f0b869SBen Hutchings * Access to the switch's PHY registers. 367c8f0b869SBen Hutchings */ 368c8f0b869SBen Hutchings int (*phy_read)(struct dsa_switch *ds, int port, int regnum); 369c8f0b869SBen Hutchings int (*phy_write)(struct dsa_switch *ds, int port, 370c8f0b869SBen Hutchings int regnum, u16 val); 371c8f0b869SBen Hutchings 372c8f0b869SBen Hutchings /* 373ec9436baSFlorian Fainelli * Link state adjustment (called from libphy) 374ec9436baSFlorian Fainelli */ 375ec9436baSFlorian Fainelli void (*adjust_link)(struct dsa_switch *ds, int port, 376ec9436baSFlorian Fainelli struct phy_device *phydev); 377ce31b31cSFlorian Fainelli void (*fixed_link_update)(struct dsa_switch *ds, int port, 378ce31b31cSFlorian Fainelli struct fixed_phy_status *st); 379ec9436baSFlorian Fainelli 380ec9436baSFlorian Fainelli /* 38111d8f3ddSFlorian Fainelli * PHYLINK integration 38211d8f3ddSFlorian Fainelli */ 38311d8f3ddSFlorian Fainelli void (*phylink_validate)(struct dsa_switch *ds, int port, 38411d8f3ddSFlorian Fainelli unsigned long *supported, 38511d8f3ddSFlorian Fainelli struct phylink_link_state *state); 38611d8f3ddSFlorian Fainelli int (*phylink_mac_link_state)(struct dsa_switch *ds, int port, 38711d8f3ddSFlorian Fainelli struct phylink_link_state *state); 38811d8f3ddSFlorian Fainelli void (*phylink_mac_config)(struct dsa_switch *ds, int port, 38911d8f3ddSFlorian Fainelli unsigned int mode, 39011d8f3ddSFlorian Fainelli const struct phylink_link_state *state); 39111d8f3ddSFlorian Fainelli void (*phylink_mac_an_restart)(struct dsa_switch *ds, int port); 39211d8f3ddSFlorian Fainelli void (*phylink_mac_link_down)(struct dsa_switch *ds, int port, 39311d8f3ddSFlorian Fainelli unsigned int mode, 39411d8f3ddSFlorian Fainelli phy_interface_t interface); 39511d8f3ddSFlorian Fainelli void (*phylink_mac_link_up)(struct dsa_switch *ds, int port, 39611d8f3ddSFlorian Fainelli unsigned int mode, 39711d8f3ddSFlorian Fainelli phy_interface_t interface, 39811d8f3ddSFlorian Fainelli struct phy_device *phydev); 39911d8f3ddSFlorian Fainelli void (*phylink_fixed_state)(struct dsa_switch *ds, int port, 40011d8f3ddSFlorian Fainelli struct phylink_link_state *state); 40111d8f3ddSFlorian Fainelli /* 402c8f0b869SBen Hutchings * ethtool hardware statistics. 403c8f0b869SBen Hutchings */ 40489f09048SFlorian Fainelli void (*get_strings)(struct dsa_switch *ds, int port, 40589f09048SFlorian Fainelli u32 stringset, uint8_t *data); 406c8f0b869SBen Hutchings void (*get_ethtool_stats)(struct dsa_switch *ds, 407c8f0b869SBen Hutchings int port, uint64_t *data); 40889f09048SFlorian Fainelli int (*get_sset_count)(struct dsa_switch *ds, int port, int sset); 409cf963573SFlorian Fainelli void (*get_ethtool_phy_stats)(struct dsa_switch *ds, 410cf963573SFlorian Fainelli int port, uint64_t *data); 41124462549SFlorian Fainelli 41224462549SFlorian Fainelli /* 41319e57c4eSFlorian Fainelli * ethtool Wake-on-LAN 41419e57c4eSFlorian Fainelli */ 41519e57c4eSFlorian Fainelli void (*get_wol)(struct dsa_switch *ds, int port, 41619e57c4eSFlorian Fainelli struct ethtool_wolinfo *w); 41719e57c4eSFlorian Fainelli int (*set_wol)(struct dsa_switch *ds, int port, 41819e57c4eSFlorian Fainelli struct ethtool_wolinfo *w); 41919e57c4eSFlorian Fainelli 42019e57c4eSFlorian Fainelli /* 4210336369dSBrandon Streiff * ethtool timestamp info 4220336369dSBrandon Streiff */ 4230336369dSBrandon Streiff int (*get_ts_info)(struct dsa_switch *ds, int port, 4240336369dSBrandon Streiff struct ethtool_ts_info *ts); 4250336369dSBrandon Streiff 4260336369dSBrandon Streiff /* 42724462549SFlorian Fainelli * Suspend and resume 42824462549SFlorian Fainelli */ 42924462549SFlorian Fainelli int (*suspend)(struct dsa_switch *ds); 43024462549SFlorian Fainelli int (*resume)(struct dsa_switch *ds); 431b2f2af21SFlorian Fainelli 432b2f2af21SFlorian Fainelli /* 433b2f2af21SFlorian Fainelli * Port enable/disable 434b2f2af21SFlorian Fainelli */ 435b2f2af21SFlorian Fainelli int (*port_enable)(struct dsa_switch *ds, int port, 436b2f2af21SFlorian Fainelli struct phy_device *phy); 43775104db0SAndrew Lunn void (*port_disable)(struct dsa_switch *ds, int port); 4387905288fSFlorian Fainelli 4397905288fSFlorian Fainelli /* 44008f50061SVivien Didelot * Port's MAC EEE settings 4417905288fSFlorian Fainelli */ 44208f50061SVivien Didelot int (*set_mac_eee)(struct dsa_switch *ds, int port, 4437905288fSFlorian Fainelli struct ethtool_eee *e); 44408f50061SVivien Didelot int (*get_mac_eee)(struct dsa_switch *ds, int port, 4457905288fSFlorian Fainelli struct ethtool_eee *e); 44651579c3fSGuenter Roeck 4476793abb4SGuenter Roeck /* EEPROM access */ 4486793abb4SGuenter Roeck int (*get_eeprom_len)(struct dsa_switch *ds); 4496793abb4SGuenter Roeck int (*get_eeprom)(struct dsa_switch *ds, 4506793abb4SGuenter Roeck struct ethtool_eeprom *eeprom, u8 *data); 4516793abb4SGuenter Roeck int (*set_eeprom)(struct dsa_switch *ds, 4526793abb4SGuenter Roeck struct ethtool_eeprom *eeprom, u8 *data); 4533d762a0fSGuenter Roeck 4543d762a0fSGuenter Roeck /* 4553d762a0fSGuenter Roeck * Register access. 4563d762a0fSGuenter Roeck */ 4573d762a0fSGuenter Roeck int (*get_regs_len)(struct dsa_switch *ds, int port); 4583d762a0fSGuenter Roeck void (*get_regs)(struct dsa_switch *ds, int port, 4593d762a0fSGuenter Roeck struct ethtool_regs *regs, void *p); 460b73adef6SFlorian Fainelli 461b73adef6SFlorian Fainelli /* 462b73adef6SFlorian Fainelli * Bridge integration 463b73adef6SFlorian Fainelli */ 46434a79f63SVivien Didelot int (*set_ageing_time)(struct dsa_switch *ds, unsigned int msecs); 46571327a4eSVivien Didelot int (*port_bridge_join)(struct dsa_switch *ds, int port, 466a6692754SVivien Didelot struct net_device *bridge); 467f123f2fbSVivien Didelot void (*port_bridge_leave)(struct dsa_switch *ds, int port, 468f123f2fbSVivien Didelot struct net_device *bridge); 46943c44a9fSVivien Didelot void (*port_stp_state_set)(struct dsa_switch *ds, int port, 470b73adef6SFlorian Fainelli u8 state); 471732f794cSVivien Didelot void (*port_fast_age)(struct dsa_switch *ds, int port); 47257652796SRussell King int (*port_egress_floods)(struct dsa_switch *ds, int port, 47357652796SRussell King bool unicast, bool multicast); 4742a778e1bSVivien Didelot 4752a778e1bSVivien Didelot /* 47611149536SVivien Didelot * VLAN support 47711149536SVivien Didelot */ 478fb2dabadSVivien Didelot int (*port_vlan_filtering)(struct dsa_switch *ds, int port, 479fb2dabadSVivien Didelot bool vlan_filtering); 48076e398a6SVivien Didelot int (*port_vlan_prepare)(struct dsa_switch *ds, int port, 48180e02360SVivien Didelot const struct switchdev_obj_port_vlan *vlan); 4824d5770b3SVivien Didelot void (*port_vlan_add)(struct dsa_switch *ds, int port, 48380e02360SVivien Didelot const struct switchdev_obj_port_vlan *vlan); 48476e398a6SVivien Didelot int (*port_vlan_del)(struct dsa_switch *ds, int port, 48576e398a6SVivien Didelot const struct switchdev_obj_port_vlan *vlan); 48611149536SVivien Didelot /* 4872a778e1bSVivien Didelot * Forwarding database 4882a778e1bSVivien Didelot */ 4891b6dd556SArkadi Sharshevsky int (*port_fdb_add)(struct dsa_switch *ds, int port, 4906c2c1dcbSArkadi Sharshevsky const unsigned char *addr, u16 vid); 4912a778e1bSVivien Didelot int (*port_fdb_del)(struct dsa_switch *ds, int port, 4926c2c1dcbSArkadi Sharshevsky const unsigned char *addr, u16 vid); 493ea70ba98SVivien Didelot int (*port_fdb_dump)(struct dsa_switch *ds, int port, 4942bedde1aSArkadi Sharshevsky dsa_fdb_dump_cb_t *cb, void *data); 4958df30255SVivien Didelot 4968df30255SVivien Didelot /* 4978df30255SVivien Didelot * Multicast database 4988df30255SVivien Didelot */ 4998df30255SVivien Didelot int (*port_mdb_prepare)(struct dsa_switch *ds, int port, 5003709aadcSVivien Didelot const struct switchdev_obj_port_mdb *mdb); 5018df30255SVivien Didelot void (*port_mdb_add)(struct dsa_switch *ds, int port, 5023709aadcSVivien Didelot const struct switchdev_obj_port_mdb *mdb); 5038df30255SVivien Didelot int (*port_mdb_del)(struct dsa_switch *ds, int port, 5048df30255SVivien Didelot const struct switchdev_obj_port_mdb *mdb); 505bf9f2648SFlorian Fainelli /* 506bf9f2648SFlorian Fainelli * RXNFC 507bf9f2648SFlorian Fainelli */ 508bf9f2648SFlorian Fainelli int (*get_rxnfc)(struct dsa_switch *ds, int port, 509bf9f2648SFlorian Fainelli struct ethtool_rxnfc *nfc, u32 *rule_locs); 510bf9f2648SFlorian Fainelli int (*set_rxnfc)(struct dsa_switch *ds, int port, 511bf9f2648SFlorian Fainelli struct ethtool_rxnfc *nfc); 512f50f2127SFlorian Fainelli 513f50f2127SFlorian Fainelli /* 514f50f2127SFlorian Fainelli * TC integration 515f50f2127SFlorian Fainelli */ 516f50f2127SFlorian Fainelli int (*port_mirror_add)(struct dsa_switch *ds, int port, 517f50f2127SFlorian Fainelli struct dsa_mall_mirror_tc_entry *mirror, 518f50f2127SFlorian Fainelli bool ingress); 519f50f2127SFlorian Fainelli void (*port_mirror_del)(struct dsa_switch *ds, int port, 520f50f2127SFlorian Fainelli struct dsa_mall_mirror_tc_entry *mirror); 52147d23af2SVladimir Oltean int (*port_setup_tc)(struct dsa_switch *ds, int port, 52247d23af2SVladimir Oltean enum tc_setup_type type, void *type_data); 52340ef2c93SVivien Didelot 52440ef2c93SVivien Didelot /* 52540ef2c93SVivien Didelot * Cross-chip operations 52640ef2c93SVivien Didelot */ 52740ef2c93SVivien Didelot int (*crosschip_bridge_join)(struct dsa_switch *ds, int sw_index, 52840ef2c93SVivien Didelot int port, struct net_device *br); 52940ef2c93SVivien Didelot void (*crosschip_bridge_leave)(struct dsa_switch *ds, int sw_index, 53040ef2c93SVivien Didelot int port, struct net_device *br); 5310336369dSBrandon Streiff 5320336369dSBrandon Streiff /* 5330336369dSBrandon Streiff * PTP functionality 5340336369dSBrandon Streiff */ 5350336369dSBrandon Streiff int (*port_hwtstamp_get)(struct dsa_switch *ds, int port, 5360336369dSBrandon Streiff struct ifreq *ifr); 5370336369dSBrandon Streiff int (*port_hwtstamp_set)(struct dsa_switch *ds, int port, 5380336369dSBrandon Streiff struct ifreq *ifr); 53990af1059SBrandon Streiff bool (*port_txtstamp)(struct dsa_switch *ds, int port, 54090af1059SBrandon Streiff struct sk_buff *clone, unsigned int type); 54190af1059SBrandon Streiff bool (*port_rxtstamp)(struct dsa_switch *ds, int port, 54290af1059SBrandon Streiff struct sk_buff *skb, unsigned int type); 54397a69a0dSVladimir Oltean 54497a69a0dSVladimir Oltean /* 54597a69a0dSVladimir Oltean * Deferred frame Tx 54697a69a0dSVladimir Oltean */ 54797a69a0dSVladimir Oltean netdev_tx_t (*port_deferred_xmit)(struct dsa_switch *ds, int port, 54897a69a0dSVladimir Oltean struct sk_buff *skb); 549c8f0b869SBen Hutchings }; 550c8f0b869SBen Hutchings 551ab3d408dSFlorian Fainelli struct dsa_switch_driver { 552ab3d408dSFlorian Fainelli struct list_head list; 553a82f67afSFlorian Fainelli const struct dsa_switch_ops *ops; 554ab3d408dSFlorian Fainelli }; 555ab3d408dSFlorian Fainelli 55614b89f36SFlorian Fainelli struct net_device *dsa_dev_to_net_device(struct device *dev); 557c8f0b869SBen Hutchings 55873a7ece8SVivien Didelot /* Keep inline for faster access in hot path */ 559c6e970a0SAndrew Lunn static inline bool netdev_uses_dsa(struct net_device *dev) 560c6e970a0SAndrew Lunn { 561c6e970a0SAndrew Lunn #if IS_ENABLED(CONFIG_NET_DSA) 562717ffbfbSVivien Didelot return dev->dsa_ptr && dev->dsa_ptr->rcv; 563c6e970a0SAndrew Lunn #endif 564c6e970a0SAndrew Lunn return false; 565c6e970a0SAndrew Lunn } 566c6e970a0SAndrew Lunn 567cc1939e4SVladimir Oltean static inline bool dsa_can_decode(const struct sk_buff *skb, 568cc1939e4SVladimir Oltean struct net_device *dev) 569cc1939e4SVladimir Oltean { 570cc1939e4SVladimir Oltean #if IS_ENABLED(CONFIG_NET_DSA) 571cc1939e4SVladimir Oltean return !dev->dsa_ptr->filter || dev->dsa_ptr->filter(skb, dev); 572cc1939e4SVladimir Oltean #endif 573cc1939e4SVladimir Oltean return false; 574cc1939e4SVladimir Oltean } 575cc1939e4SVladimir Oltean 576a0c02161SVivien Didelot struct dsa_switch *dsa_switch_alloc(struct device *dev, size_t n); 57783c0afaeSAndrew Lunn void dsa_unregister_switch(struct dsa_switch *ds); 57823c9ee49SVivien Didelot int dsa_register_switch(struct dsa_switch *ds); 579ea825e70SFlorian Fainelli #ifdef CONFIG_PM_SLEEP 580ea825e70SFlorian Fainelli int dsa_switch_suspend(struct dsa_switch *ds); 581ea825e70SFlorian Fainelli int dsa_switch_resume(struct dsa_switch *ds); 582ea825e70SFlorian Fainelli #else 583ea825e70SFlorian Fainelli static inline int dsa_switch_suspend(struct dsa_switch *ds) 584ea825e70SFlorian Fainelli { 585ea825e70SFlorian Fainelli return 0; 586ea825e70SFlorian Fainelli } 587ea825e70SFlorian Fainelli static inline int dsa_switch_resume(struct dsa_switch *ds) 588ea825e70SFlorian Fainelli { 589ea825e70SFlorian Fainelli return 0; 590ea825e70SFlorian Fainelli } 591ea825e70SFlorian Fainelli #endif /* CONFIG_PM_SLEEP */ 592ea825e70SFlorian Fainelli 59360724d4bSFlorian Fainelli enum dsa_notifier_type { 59460724d4bSFlorian Fainelli DSA_PORT_REGISTER, 59560724d4bSFlorian Fainelli DSA_PORT_UNREGISTER, 59660724d4bSFlorian Fainelli }; 59760724d4bSFlorian Fainelli 59860724d4bSFlorian Fainelli struct dsa_notifier_info { 59960724d4bSFlorian Fainelli struct net_device *dev; 60060724d4bSFlorian Fainelli }; 60160724d4bSFlorian Fainelli 60260724d4bSFlorian Fainelli struct dsa_notifier_register_info { 60360724d4bSFlorian Fainelli struct dsa_notifier_info info; /* must be first */ 60460724d4bSFlorian Fainelli struct net_device *master; 60560724d4bSFlorian Fainelli unsigned int port_number; 60660724d4bSFlorian Fainelli unsigned int switch_number; 60760724d4bSFlorian Fainelli }; 60860724d4bSFlorian Fainelli 60960724d4bSFlorian Fainelli static inline struct net_device * 61060724d4bSFlorian Fainelli dsa_notifier_info_to_dev(const struct dsa_notifier_info *info) 61160724d4bSFlorian Fainelli { 61260724d4bSFlorian Fainelli return info->dev; 61360724d4bSFlorian Fainelli } 61460724d4bSFlorian Fainelli 61560724d4bSFlorian Fainelli #if IS_ENABLED(CONFIG_NET_DSA) 61660724d4bSFlorian Fainelli int register_dsa_notifier(struct notifier_block *nb); 61760724d4bSFlorian Fainelli int unregister_dsa_notifier(struct notifier_block *nb); 61860724d4bSFlorian Fainelli int call_dsa_notifiers(unsigned long val, struct net_device *dev, 61960724d4bSFlorian Fainelli struct dsa_notifier_info *info); 62060724d4bSFlorian Fainelli #else 62160724d4bSFlorian Fainelli static inline int register_dsa_notifier(struct notifier_block *nb) 62260724d4bSFlorian Fainelli { 62360724d4bSFlorian Fainelli return 0; 62460724d4bSFlorian Fainelli } 62560724d4bSFlorian Fainelli 62660724d4bSFlorian Fainelli static inline int unregister_dsa_notifier(struct notifier_block *nb) 62760724d4bSFlorian Fainelli { 62860724d4bSFlorian Fainelli return 0; 62960724d4bSFlorian Fainelli } 63060724d4bSFlorian Fainelli 63160724d4bSFlorian Fainelli static inline int call_dsa_notifiers(unsigned long val, struct net_device *dev, 63260724d4bSFlorian Fainelli struct dsa_notifier_info *info) 63360724d4bSFlorian Fainelli { 63460724d4bSFlorian Fainelli return NOTIFY_DONE; 63560724d4bSFlorian Fainelli } 63660724d4bSFlorian Fainelli #endif 63760724d4bSFlorian Fainelli 6380a5f14ceSFlorian Fainelli /* Broadcom tag specific helpers to insert and extract queue/port number */ 6390a5f14ceSFlorian Fainelli #define BRCM_TAG_SET_PORT_QUEUE(p, q) ((p) << 8 | q) 6400a5f14ceSFlorian Fainelli #define BRCM_TAG_GET_PORT(v) ((v) >> 8) 6410a5f14ceSFlorian Fainelli #define BRCM_TAG_GET_QUEUE(v) ((v) & 0xff) 6420a5f14ceSFlorian Fainelli 643cf963573SFlorian Fainelli 64497a69a0dSVladimir Oltean netdev_tx_t dsa_enqueue_skb(struct sk_buff *skb, struct net_device *dev); 645cf963573SFlorian Fainelli int dsa_port_get_phy_strings(struct dsa_port *dp, uint8_t *data); 646cf963573SFlorian Fainelli int dsa_port_get_ethtool_phy_stats(struct dsa_port *dp, uint64_t *data); 647cf963573SFlorian Fainelli int dsa_port_get_phy_sset_count(struct dsa_port *dp); 64811d8f3ddSFlorian Fainelli void dsa_port_phylink_mac_change(struct dsa_switch *ds, int port, bool up); 649cf963573SFlorian Fainelli 650d3b8c049SAndrew Lunn struct dsa_tag_driver { 651d3b8c049SAndrew Lunn const struct dsa_device_ops *ops; 652d3b8c049SAndrew Lunn struct list_head list; 653d3b8c049SAndrew Lunn struct module *owner; 654d3b8c049SAndrew Lunn }; 655d3b8c049SAndrew Lunn 656d3b8c049SAndrew Lunn void dsa_tag_drivers_register(struct dsa_tag_driver *dsa_tag_driver_array[], 657d3b8c049SAndrew Lunn unsigned int count, 658d3b8c049SAndrew Lunn struct module *owner); 659d3b8c049SAndrew Lunn void dsa_tag_drivers_unregister(struct dsa_tag_driver *dsa_tag_driver_array[], 660d3b8c049SAndrew Lunn unsigned int count); 661d3b8c049SAndrew Lunn 662d3b8c049SAndrew Lunn #define dsa_tag_driver_module_drivers(__dsa_tag_drivers_array, __count) \ 663d3b8c049SAndrew Lunn static int __init dsa_tag_driver_module_init(void) \ 664d3b8c049SAndrew Lunn { \ 665d3b8c049SAndrew Lunn dsa_tag_drivers_register(__dsa_tag_drivers_array, __count, \ 666d3b8c049SAndrew Lunn THIS_MODULE); \ 667d3b8c049SAndrew Lunn return 0; \ 668d3b8c049SAndrew Lunn } \ 669d3b8c049SAndrew Lunn module_init(dsa_tag_driver_module_init); \ 670d3b8c049SAndrew Lunn \ 671d3b8c049SAndrew Lunn static void __exit dsa_tag_driver_module_exit(void) \ 672d3b8c049SAndrew Lunn { \ 673d3b8c049SAndrew Lunn dsa_tag_drivers_unregister(__dsa_tag_drivers_array, __count); \ 674d3b8c049SAndrew Lunn } \ 675d3b8c049SAndrew Lunn module_exit(dsa_tag_driver_module_exit) 676d3b8c049SAndrew Lunn 677d3b8c049SAndrew Lunn /** 678d3b8c049SAndrew Lunn * module_dsa_tag_drivers() - Helper macro for registering DSA tag 679d3b8c049SAndrew Lunn * drivers 680d3b8c049SAndrew Lunn * @__ops_array: Array of tag driver strucutres 681d3b8c049SAndrew Lunn * 682d3b8c049SAndrew Lunn * Helper macro for DSA tag drivers which do not do anything special 683d3b8c049SAndrew Lunn * in module init/exit. Each module may only use this macro once, and 684d3b8c049SAndrew Lunn * calling it replaces module_init() and module_exit(). 685d3b8c049SAndrew Lunn */ 686d3b8c049SAndrew Lunn #define module_dsa_tag_drivers(__ops_array) \ 687d3b8c049SAndrew Lunn dsa_tag_driver_module_drivers(__ops_array, ARRAY_SIZE(__ops_array)) 688d3b8c049SAndrew Lunn 689d3b8c049SAndrew Lunn #define DSA_TAG_DRIVER_NAME(__ops) dsa_tag_driver ## _ ## __ops 690d3b8c049SAndrew Lunn 691d3b8c049SAndrew Lunn /* Create a static structure we can build a linked list of dsa_tag 692d3b8c049SAndrew Lunn * drivers 693d3b8c049SAndrew Lunn */ 694d3b8c049SAndrew Lunn #define DSA_TAG_DRIVER(__ops) \ 695d3b8c049SAndrew Lunn static struct dsa_tag_driver DSA_TAG_DRIVER_NAME(__ops) = { \ 696d3b8c049SAndrew Lunn .ops = &__ops, \ 697d3b8c049SAndrew Lunn } 698d3b8c049SAndrew Lunn 699d3b8c049SAndrew Lunn /** 700d3b8c049SAndrew Lunn * module_dsa_tag_driver() - Helper macro for registering a single DSA tag 701d3b8c049SAndrew Lunn * driver 702d3b8c049SAndrew Lunn * @__ops: Single tag driver structures 703d3b8c049SAndrew Lunn * 704d3b8c049SAndrew Lunn * Helper macro for DSA tag drivers which do not do anything special 705d3b8c049SAndrew Lunn * in module init/exit. Each module may only use this macro once, and 706d3b8c049SAndrew Lunn * calling it replaces module_init() and module_exit(). 707d3b8c049SAndrew Lunn */ 708d3b8c049SAndrew Lunn #define module_dsa_tag_driver(__ops) \ 709d3b8c049SAndrew Lunn DSA_TAG_DRIVER(__ops); \ 710d3b8c049SAndrew Lunn \ 711d3b8c049SAndrew Lunn static struct dsa_tag_driver *dsa_tag_driver_array[] = { \ 712d3b8c049SAndrew Lunn &DSA_TAG_DRIVER_NAME(__ops) \ 713d3b8c049SAndrew Lunn }; \ 714d3b8c049SAndrew Lunn module_dsa_tag_drivers(dsa_tag_driver_array) 71591da11f8SLennert Buytenhek #endif 716d3b8c049SAndrew Lunn 717