Lines Matching +full:dsa +full:- +full:specific

5 This document describes the **Distributed Switch Architecture (DSA)** subsystem
22 An Ethernet switch typically comprises multiple front-panel ports and one
23 or more CPU or management ports. The DSA subsystem currently relies on the
27 gateways, or even top-of-rack switches. This host Ethernet controller will
28 be later referred to as "master" and "cpu" in DSA terminology and code.
30 The D in DSA stands for Distributed, because the subsystem has been designed
32 using upstream and downstream Ethernet links between switches. These specific
33 ports are referred to as "dsa" ports in DSA terminology and code. A collection
36 For each front-panel port, DSA creates specialized network devices which are
37 used as controlling and data-flowing endpoints for use by the Linux networking
39 interfaces in DSA terminology and code.
41 The ideal case for using DSA is when an Ethernet switch supports a "switch tag"
42 which is a hardware feature making the switch insert a specific tag for each
43 Ethernet frame it receives to/from specific ports to help the management
46 - what port is this frame coming from
47 - what was the reason why this frame got forwarded
48 - how to send CPU originated traffic to specific ports
52 on Port-based VLAN IDs).
54 Note that DSA does not currently create network interfaces for the "cpu" and
55 "dsa" ports because:
57 - the "cpu" port is the Ethernet switch facing side of the management
61 - the "dsa" port(s) are just conduits between two or more switches, and as such
63 downstream, or the top-most upstream interface makes sense with that model
66 ------------------------
68 DSA supports many vendor-specific tagging protocols, one software-defined
69 tagging protocol, and a tag-less mode as well (``DSA_TAG_PROTO_NONE``).
71 The exact format of the tag protocol is vendor specific, but in general, they
74 - identifies which port the Ethernet frame came from/should be sent to
75 - provides a reason why this frame was forwarded to the management interface
77 All tagging protocols are in ``net/dsa/tag_*.c`` files and implement the
82 1. The switch-specific frame header is located before the Ethernet header,
83 shifting to the right (from the perspective of the DSA master's frame
85 2. The switch-specific frame header is located before the EtherType, keeping
86 the MAC DA and MAC SA in place from the DSA master's perspective, but
88 3. The switch-specific frame header is located at the tail of the packet,
90 that the DSA master's frame parser has.
97 with the length in octets of the longest switch frame header/trailer. The DSA
99 accommodate for this extra size in order for DSA user ports to support the
102 on a best-effort basis, the allocation of packets with enough extra space such
106 Even though applications are not expected to parse DSA-specific frame headers,
116 From the perspective of the network stack, all switches within the same DSA
118 fabric with more than one switch, the switch-specific frame header is inserted
130 CPU port can be configured to use either the DSA or the Ethertype DSA (EDSA)
131 format, but the DSA links are configured to use the shorter (without Ethertype)
132 DSA frame header, in order to reduce the autonomous packet forwarding overhead.
133 It still remains the case that, if the DSA switch tree is configured for the
134 EDSA tagging protocol, the operating system sees EDSA-tagged packets from the
135 leaf switches that tagged them with the shorter DSA header. This can be done
137 perform tag translation between DSA and EDSA (which is simply the operation of
140 It is possible to construct cascaded setups of DSA switches even if their
142 no DSA links in this fabric, and each switch constitutes a disjoint DSA switch
143 tree. The DSA links are viewed as simply a pair of a DSA master (the out-facing
144 port of the upstream DSA switch) and a CPU port (the in-facing port of the
145 downstream DSA switch).
147 The tagging protocol of the attached DSA switch tree can be viewed through the
148 ``dsa/tagging`` sysfs attribute of the DSA master::
150 cat /sys/class/net/eth0/dsa/tagging
152 If the hardware and driver are capable, the tagging protocol of the DSA switch
154 protocol name to the same sysfs device attribute as above (the DSA master and
162 for the DSA master.
165 The passed ``struct sk_buff *skb`` has ``skb->data`` pointing at
167 ``struct net_device *dev`` represents the virtual DSA user network interface
174 properly, because DSA ensures there is enough space before calling this method.
177 passed ``struct sk_buff *skb`` has ``skb->data`` pointing at
180 method is to consume the frame header, adjust ``skb->data`` to really point at
181 the first octet after the EtherType, and to change ``skb->dev`` to point to the
182 virtual DSA user network interface corresponding to the physical front-facing
186 hardware) packet dissection on the DSA master, features such as RPS (Receive
187 Packet Steering) on the DSA master would be broken. The DSA framework deals
189 the IP header is to be found in the tagged frame as seen by the DSA master.
196 Checksum offload should work with category 1 and 2 taggers when the DSA master
198 csum_offset. For those cases, DSA will shift the checksum start and offset by
199 the tag size. If the DSA master driver still uses the legacy NETIF_F_IP_CSUM
201 offload hardware already expects that specific tag (perhaps due to matching
202 vendors). DSA slaves inherit those flags from the master port, and it is up to
208 tag is inserted (i.e. inside the tagger). Otherwise, the DSA master would
214 with DSA-unaware masters, mangling what the master perceives as MAC DA), the
215 tagging protocol may require the DSA master to operate in promiscuous mode, to
218 Note that this assumes a DSA-unaware master driver, which is the norm.
221 ----------------------
225 know whether DSA is enabled (e.g.: to enable/disable specific offload features),
226 but the DSA subsystem has been proven to work with industry standard drivers:
233 ----------------------
235 When a master netdev is used with DSA, a small hook is placed in the
236 networking stack is in order to have the DSA subsystem process the Ethernet
237 switch specific tagging protocol. DSA accomplishes this by registering a
238 specific (and fake) Ethernet type (later becoming ``skb->protocol``) with the
246 - receive function is invoked
247 - basic packet processing is done: getting length, status etc.
248 - packet is prepared to be processed by the Ethernet layer by calling
254 if (dev->dsa_ptr != NULL)
255 -> skb->protocol = ETH_P_XDSA
260 -> iterate over registered packet_type
261 -> invoke handler for ETH_P_XDSA, calls dsa_switch_rcv()
263 4. net/dsa/dsa.c::
265 -> dsa_switch_rcv()
266 -> invoke switch tag specific protocol handler in 'net/dsa/tag_*.c'
268 5. net/dsa/tag_*.c:
270 - inspect and strip switch tag protocol to determine originating port
271 - locate per-port network device
272 - invoke ``eth_type_trans()`` with the DSA slave network device
273 - invoked ``netif_receive_skb()``
275 Past this point, the DSA slave network devices get delivered regular Ethernet
279 ---------------------
281 Slave network devices created by DSA are stacked on top of their master network
283 controlling and data-flowing end-point for each front-panel port of the switch.
286 - insert/remove the switch tag protocol (if it exists) when sending traffic
287 to/from specific switch ports
288 - query the switch for ethtool operations: statistics, link state,
289 Wake-on-LAN, register dumps...
290 - manage external/internal PHY: link, auto-negotiation, etc.
293 pointers which allow DSA to introduce a level of layering between the networking
296 Upon frame transmission from these slave network devices, DSA will look up which
298 invoke a specific transmit routine which takes care of adding the relevant
307 device between the DSA slave devices and the physical DSA masters. The LAG
308 device is thus also a DSA master, but the LAG slave devices continue to be DSA
310 recovery in case the LAG DSA master disappears). Thus, the data path of the LAG
311 DSA master is used asymmetrically. On RX, the ``ETH_P_XDSA`` handler, which
312 calls ``dsa_switch_rcv()``, is invoked early (on the physical DSA master;
313 LAG slave). Therefore, the RX data path of the LAG DSA master is not used.
315 ``dsa_enqueue_skb``, which calls ``dev_queue_xmit`` towards the LAG DSA master.
316 The latter calls ``dev_queue_xmit`` towards one physical DSA master or the
321 ------------------------
323 Summarized, this is basically how DSA looks like from a network device
330 +-----------v--|--------------------+
331 |+------+ +------+ +------+ +------+|
333 |+------+-+------+-+------+-+------+|
334 | DSA switch driver |
335 +-----------------------------------+
340 +-----------------------------------+
342 --------+-----------------------------------+------------
344 +-----------------------------------+
349 +-----------------------------------+
351 |+------+ +------+ +------+ +------+|
353 ++------+-+------+-+------+-+------++
356 --------------
358 In order to be able to read to/from a switch PHY built into it, DSA creates a
359 slave MDIO bus which allows a specific switch driver to divert and intercept
360 MDIO reads/writes towards specific PHY addresses. In most MDIO-connected
363 library and/or to return link status, link partner pages, auto-negotiation
372 ---------------
374 DSA data structures are defined in ``include/net/dsa.h`` as well as
375 ``net/dsa/dsa_priv.h``:
377 - ``dsa_chip_data``: platform data configuration for a given switch device,
382 - ``dsa_platform_data``: platform device configuration data which can reference
387 - ``dsa_switch_tree``: structure assigned to the master network device under
394 - ``dsa_switch``: structure describing a switch device in the tree, referencing
398 - ``dsa_switch_ops``: structure referencing function pointers, see below for a
404 Lack of CPU/DSA network devices
405 -------------------------------
407 DSA does not currently create slave network devices for the CPU or DSA ports, as
410 - inability to fetch switch CPU port statistics counters using ethtool, which
413 - inability to configure the CPU port link parameters based on the Ethernet
416 - inability to configure specific VLAN IDs / trunking VLANs between switches
419 Common pitfalls using DSA setups
420 --------------------------------
422 Once a master network device is configured to use DSA (dev->dsa_ptr becomes
423 non-NULL), and the switch behind it expects a tagging protocol, this network
433 DSA currently leverages the following subsystems:
435 - MDIO/PHY library: ``drivers/net/phy/phy.c``, ``mdio_bus.c``
436 - Switchdev:``net/switchdev/*``
437 - Device Tree for various of_* functions
438 - Devlink: ``net/core/devlink.c``
441 ----------------
443 Slave network devices exposed by DSA may or may not be interfacing with PHY
444 devices (``struct phy_device`` as defined in ``include/linux/phy.h)``, but the DSA
447 - internal PHY devices, built into the Ethernet switch hardware
448 - external PHY devices, connected via an internal or external MDIO bus
449 - internal PHY devices, connected via an internal MDIO bus
450 - special, non-autonegotiated or non MDIO-managed PHY devices: SFPs, MoCA; a.k.a
456 - if Device Tree is used, the PHY device is looked up using the standard
457 "phy-handle" property, if found, this PHY device is created and registered
460 - if Device Tree is used and the PHY device is "fixed", that is, conforms to
461 the definition of a non-MDIO managed PHY as defined in
462 ``Documentation/devicetree/bindings/net/fixed-link.txt``, the PHY is registered
465 - finally, if the PHY is built into the switch, as is very common with
467 by DSA
471 ---------
473 DSA directly utilizes SWITCHDEV when interfacing with the bridge layer, and
475 of per-port slave network devices. As of today, the only SWITCHDEV objects
476 supported by DSA are the FDB and VLAN objects.
479 -------
481 DSA registers one devlink device per physical switch in the fabric.
482 For each devlink device, every physical port (i.e. user ports, CPU ports, DSA
485 DSA drivers can make use of the following devlink features:
487 - Regions: debugging feature which allows user space to dump driver-defined
488 areas of hardware information in a low-level, binary format. Both global
489 regions as well as per-port regions are supported. It is possible to export
491 to the standard iproute2 user space programs (ip-link, bridge), like address
493 contain additional hardware-specific details which are not visible through
495 the non-user ports too, which are invisible to iproute2 because no network
497 - Params: a feature which enables user to configure certain low-level tunable
499 devlink params, or may add new device-specific devlink params.
500 - Resources: a monitoring feature which enables users to see the degree of
502 - Shared buffers: a QoS feature for adjusting and partitioning memory and frame
504 directions, such that low-priority bulk traffic does not impede the
505 processing of high-priority critical traffic.
510 -----------
512 DSA features a standardized binding which is documented in
513 ``Documentation/devicetree/bindings/net/dsa/dsa.txt``. PHY/MDIO library helper
515 per-port PHY specific details: interface connection, MDIO bus location, etc.
520 DSA switch drivers need to implement a ``dsa_switch_ops`` structure which will
524 -----------------------------------------
526 DSA switches are regular ``device`` structures on buses (be they platform, SPI,
527 I2C, MDIO or otherwise). The DSA framework is not involved in their probing
535 - ``ds->dev``: will be used to parse the switch's OF node or platform data.
537 - ``ds->num_ports``: will be used to create the port list for this switch, and
540 - ``ds->ops``: a pointer to the ``dsa_switch_ops`` structure holding the DSA
543 - ``ds->priv``: backpointer to a driver-private data structure which can be
544 retrieved in all further DSA method callbacks.
547 be configured to obtain driver-specific behavior from the DSA core. Their
548 behavior when set is documented through comments in ``include/net/dsa.h``.
550 - ``ds->vlan_filtering_is_global``
552 - ``ds->needs_standalone_vlan_filtering``
554 - ``ds->configure_vlan_while_not_filtering``
556 - ``ds->untag_bridge_pvid``
558 - ``ds->assisted_learning_on_cpu_port``
560 - ``ds->mtu_enforcement_ingress``
562 - ``ds->fdb_isolation``
564 Internally, DSA keeps an array of switch trees (group of switches) global to
567 number of the ``dsa,member`` property of the switch's OF node (0 if missing).
574 The first N-1 callers of ``dsa_register_switch()`` only add their ports to the
575 port list of the tree (``dst->ports``), each port having a backpointer to its
576 associated switch (``dp->ds``). Then, these switches exit their
579 DSA links are present in the tree's port list). The tree becomes complete when
581 continuation of initialization (including the call to ``ds->ops->setup()``) for
589 It is mandatory for DSA switch drivers to implement the ``shutdown()`` callback
592 The reason is that DSA keeps a reference on the master net device, and if the
593 driver for the master device decides to unbind on shutdown, DSA's reference
608 --------------------
610 - ``get_tag_protocol``: this is to indicate what kind of tagging protocol is
617 - ``change_tag_protocol``: when the default tagging protocol has compatibility
623 - ``setup``: setup function for the switch, this function is responsible for setting
628 a Port-based VLAN ID for each port and allowing only the CPU port and the
629 specific port to be in the forwarding vector. Ports that are unused by the
637 - ``port_setup`` and ``port_teardown``: methods for initialization and
638 destruction of per-port data structures. It is mandatory for some operations
643 PHY cannot be found. In this case, probing of the DSA switch continues
646 - ``port_change_master``: method through which the affinity (association used
653 the new DSA master ``net_device``. The CPU port associated with the new
655 master->dsa_ptr``. Additionally, the master can also be a LAG device where
656 all the slave devices are physical DSA masters. LAG DSA masters also have a
657 valid ``master->dsa_ptr`` pointer, however this is not unique, but rather a
658 duplicate of the first physical DSA master's (LAG slave) ``dsa_ptr``. In case
659 of a LAG DSA master, a further call to ``port_lag_join`` will be emitted
660 separately for the physical CPU ports associated with the physical DSA
665 -------------------------------
667 - ``get_phy_flags``: Some switches are interfaced to various kinds of Ethernet PHYs,
670 should return a 32-bit bitmask of "flags" that is private between the switch
673 - ``phy_read``: Function invoked by the DSA slave MDIO bus when attempting to read
676 status, auto-negotiation results, link partner pages, etc.
678 - ``phy_write``: Function invoked by the DSA slave MDIO bus when attempting to write
682 - ``adjust_link``: Function invoked by the PHY library when a slave network device
687 - ``fixed_link_update``: Function invoked by the PHY library, and specifically by
689 not be auto-negotiated, or obtained by reading the PHY registers through MDIO.
690 This is particularly useful for specific kinds of hardware such as QSGMII,
691 MoCA or other kinds of non-MDIO managed PHYs where out of band link
695 ------------------
697 - ``get_strings``: ethtool function used to query the driver's strings, will
700 - ``get_ethtool_stats``: ethtool function used to query per-port statistics and
701 return their values. DSA overlays slave network devices general statistics:
702 RX/TX counters from the network device, with switch driver specific statistics
705 - ``get_sset_count``: ethtool function used to query the number of statistics items
707 - ``get_wol``: ethtool function used to obtain Wake-on-LAN settings per-port, this
709 Wake-on-LAN settings if this interface needs to participate in Wake-on-LAN
711 - ``set_wol``: ethtool function used to configure Wake-on-LAN settings per-port,
714 - ``set_eee``: ethtool function which is used to configure a switch port EEE (Green
717 controller and data-processing logic
719 - ``get_eee``: ethtool function which is used to query a switch port EEE settings,
721 and data-processing logic as well as query the PHY for its currently configured
724 - ``get_eeprom_len``: ethtool function returning for a given switch the EEPROM
727 - ``get_eeprom``: ethtool function returning for a given switch the EEPROM contents
729 - ``set_eeprom``: ethtool function writing specified data to a given switch EEPROM
731 - ``get_regs_len``: ethtool function returning the register length for a given
734 - ``get_regs``: ethtool function returning the Ethernet switch internal register
735 contents. This function might require user-land code in ethtool to
736 pretty-print register values and registers
739 ----------------
741 - ``suspend``: function invoked by the DSA platform device when the system goes to
743 participating in Wake-on-LAN active as well as additional wake-up logic if
746 - ``resume``: function invoked by the DSA platform device when the system resumes,
747 should resume all Ethernet switch activities and re-configure the switch to be
750 - ``port_enable``: function invoked by the DSA slave network device ndo_open
752 fully enable a given switch port. DSA takes care of marking the port with
756 - ``port_disable``: function invoked by the DSA slave network device ndo_close
758 fully disable a given switch port. DSA takes care of marking the port with
763 -----------------
772 For example, all ports that belong to a VLAN-unaware bridge (which is
773 *currently* VLAN-unaware) are expected to learn source addresses in the
775 VLAN-unaware bridges). During forwarding and FDB lookup, a packet received on a
776 VLAN-unaware bridge port should be able to find a VLAN-unaware FDB entry having
780 a port which is a member of a different VLAN-unaware bridge (and is therefore
783 Similarly, each VLAN of each offloaded VLAN-aware bridge should have an
788 In this context, a VLAN-unaware database means that all packets are expected to
790 VLAN-aware database means that packets are supposed to match based on the VLAN
793 At the bridge layer, VLAN-unaware FDB entries have the special VID value of 0,
794 whereas VLAN-aware FDB entries have non-zero VID values. Note that a
795 VLAN-unaware bridge may have VLAN-aware (non-zero VID) FDB entries, and a
796 VLAN-aware bridge may have VLAN-unaware FDB entries. As in hardware, the
811 DSA (cascade) and CPU ports are also called "shared" ports because they service
813 to is usually embedded in the DSA tag. This means that the CPU port may
825 DSA is able to perform host address filtering for the following kinds of
828 - Primary unicast MAC addresses of ports (``dev->dev_addr``). These are
833 - Secondary unicast and multicast MAC addresses of ports (addresses added
837 - Local/permanent bridge FDB entries (``BR_FDB_LOCAL``). These are the MAC
842 - Static bridge FDB entries installed towards foreign (non-DSA) interfaces
843 present in the same bridge as some DSA switch ports. These are also
846 - Dynamically learned FDB entries on foreign interfaces present in the same
847 bridge as some DSA switch ports, only if ``ds->assisted_learning_on_cpu_port``
851 For various operations detailed below, DSA provides a ``dsa_db`` structure
854 - ``DSA_DB_PORT``: the FDB (or MDB) entry to be installed or deleted belongs to
855 the port private database of user port ``db->dp``.
856 - ``DSA_DB_BRIDGE``: the entry belongs to one of the address databases of bridge
857 ``db->bridge``. Separation between the VLAN-unaware database and the per-VID
859 - ``DSA_DB_LAG``: the entry belongs to the address database of LAG ``db->lag``.
863 ``port_mdb_add`` etc should declare ``ds->fdb_isolation`` as true.
865 DSA associates each offloaded bridge and each offloaded LAG with a one-based ID
867 refcounting addresses on shared ports. Drivers may piggyback on DSA's numbering
868 scheme (the ID is readable through ``db->bridge.num`` and ``db->lag.id`` or may
874 drivers even if they do not support FDB isolation. However, ``db->bridge.num``
875 and ``db->lag.id`` are always set to 0 in that case (to denote the lack of
882 share the same database, but the reference counting of host-filtered addresses
884 another port) becomes the responsibility of the driver, because DSA is unaware
893 ------------
896 below. They may be absent, return -EOPNOTSUPP, or ``ds->max_num_bridges`` may
897 be non-zero and exceeded, and in this case, joining a bridge port is still
911 ingress switch port. DSA, through ``dsa_port_devlink_setup()``, considers all
922 packets and have ``skb->offload_fwd_mark`` set to true in the tag protocol
932 VLAN-unaware, and in this case the FID must be equal to the FID used by the
933 driver for its VLAN-unaware address database associated with that bridge.
934 Alternatively, the bridge may be VLAN-aware, and in that case, it is guaranteed
935 that the packet is also VLAN-tagged with the VLAN ID that the bridge processed
937 the egress-untagged ports, or keep the tag on the egress-tagged ones.
939 - ``port_bridge_join``: bridge layer function invoked when a given switch port is
946 - ``port_bridge_leave``: bridge layer function invoked when a given switch port is
951 - ``port_stp_state_set``: bridge layer function invoked when a given switch port STP
955 - ``port_bridge_flags``: bridge layer function invoked when a port must
959 types of traffic, then the DSA core notifies of any change to the bridge port
960 flags when the port joins and leaves a bridge. DSA does not currently manage
964 lack of an explicit address filtering mechanism in the DSA core.
966 - ``port_fast_age``: bridge layer function invoked when flushing the
973 ---------------------
975 - ``port_vlan_filtering``: bridge layer function invoked when the bridge gets
976 configured for turning on or off VLAN filtering. If nothing specific needs to
985 - ``port_vlan_add``: bridge layer function invoked when a VLAN is configured
994 - ``port_vlan_del``: bridge layer function invoked when a VLAN is removed from the
997 - ``port_fdb_add``: bridge layer function invoked when the bridge wants to install a
1002 - ``port_fdb_del``: bridge layer function invoked when the bridge wants to remove a
1007 - ``port_fdb_dump``: bridge bypass function invoked by ``ndo_fdb_dump`` on the
1008 physical DSA port interfaces. Since DSA does not attempt to keep in sync its
1014 - ``port_mdb_add``: bridge layer function invoked when the bridge wants to install
1019 - ``port_mdb_del``: bridge layer function invoked when the bridge wants to remove a
1025 ----------------
1029 DSA is capable of offloading a link aggregation group (LAG) to hardware that
1032 ports constitutes a logical port, although DSA has no explicit concept of a
1037 are treated similarly: DSA offloads the same switchdev object / port attribute
1039 supported, since the DSA driver API does not have the concept of a logical port
1042 - ``port_lag_join``: function invoked when a given switch port is added to a
1043 LAG. The driver may return ``-EOPNOTSUPP``, and in this case, DSA will fall
1046 - ``port_lag_leave``: function invoked when a given switch port leaves a LAG
1048 - ``port_lag_change``: function invoked when the link state of any member of
1053 can optionally populate ``ds->num_lag_ids`` from the ``dsa_switch_ops::setup``
1055 retrieved by a DSA switch driver using the ``dsa_lag_id`` function.
1057 IEC 62439-2 (MRP)
1058 -----------------
1072 however in the case of a device with an offloaded data path such as DSA, it is
1073 necessary for the hardware, even if it is not MRP-aware, to be able to extract
1075 implementation. DSA today has no driver which is MRP-aware, therefore it only
1079 - ``port_mrp_add`` and ``port_mrp_del``: notifies driver when an MRP instance
1082 - ``port_mrp_add_ring_role`` and ``port_mrp_del_ring_role``: function invoked
1087 IEC 62439-3 (HSR/PRP)
1088 ---------------------
1093 eliminating the duplicates at the receiver. The High-availability Seamless
1095 the redundant traffic are aware of the fact that it is HSR-tagged (because HSR
1109 ``Documentation/networking/netdev-features.rst``. Additionally, the following
1112 - ``port_hsr_join``: function invoked when a given switch port is added to a
1113 DANP/DANH. The driver may return ``-EOPNOTSUPP`` and in this case, DSA will
1116 - ``port_hsr_leave``: function invoked when a given switch port leaves a
1122 Making SWITCHDEV and DSA converge towards an unified codebase
1123 -------------------------------------------------------------
1127 the other DSA enforces a fairly strict device driver model, and deals with most
1128 of the switch specific. At some point we should envision a merger between these