26 Feb, 2020

1 commit

  • The DSA drivers that implement .phylink_mac_link_state should normally
    register an interrupt for the PCS, from which they should call
    phylink_mac_change(). However not all switches implement this, and those
    who don't should set this flag in dsa_switch in the .setup callback, so
    that PHYLINK will poll for a few ms until the in-band AN link timer
    expires and the PCS state settles.

    Signed-off-by: Vladimir Oltean

    Conflicts:
    include/net/dsa.h

    trivially with upstream commit 05f294a85235 ("net: dsa: allocate ports
    on touch") which was merged in v5.4-rc3.

    (cherry picked from commit 222d888331f409755fc25b1933e5dee1a976b9c1)

    Vladimir Oltean
     

28 Aug, 2019

2 commits

  • The bridge VLANs are not offloaded by dsa_port_vlan_* if the port is
    not bridged or if its bridge is not VLAN aware.

    This is a good thing but other corners of DSA, such as the tag_8021q
    driver, may need to program VLANs regardless the bridge state.

    And also because bridge_dev is specific to user ports anyway, move
    these checks were it belongs, one layer up in the slave code.

    Signed-off-by: Vivien Didelot
    Suggested-by: Vladimir Oltean
    Signed-off-by: David S. Miller

    Vivien Didelot
     
  • Currently dsa_port_vid_add returns 0 if the switch returns -EOPNOTSUPP.

    This function is used in the tag_8021q.c code to offload the PVID of
    ports, which would simply not work if .port_vlan_add is not supported
    by the underlying switch.

    Do not skip -EOPNOTSUPP in dsa_port_vid_add but only when necessary,
    that is to say in dsa_slave_vlan_rx_add_vid.

    Signed-off-by: Vivien Didelot
    Signed-off-by: David S. Miller

    Vivien Didelot
     

18 Aug, 2019

1 commit


10 Jul, 2019

1 commit

  • This patch adds support for enabling or disabling the flooding of
    unknown multicast traffic on the CPU ports, depending on the value
    of the switchdev SWITCHDEV_ATTR_ID_BRIDGE_MROUTER attribute.

    The current behavior is kept unchanged but a user can now prevent
    the CPU conduit to be flooded with a lot of unregistered traffic that
    the network stack needs to filter in software with e.g.:

    echo 0 > /sys/class/net/br0/multicast_router

    Signed-off-by: Vivien Didelot
    Signed-off-by: David S. Miller

    Vivien Didelot
     

15 Jun, 2019

1 commit

  • The current DSA code handling switchdev objects does not recurse into
    the lower devices thus is never called with an orig_dev member being
    a bridge device, hence remove this useless check.

    At the same time, remove the comments about the callers, which is
    unlikely to be updated if the code changes and thus will be confusing.

    Signed-off-by: Vivien Didelot
    Reviewed-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Vivien Didelot
     

13 Jun, 2019

1 commit

  • We need to specifically deal with phylink_of_phy_connect() returning
    -ENODEV, because this can happen when a CPU/DSA port does connect
    neither to a PHY, nor has a fixed-link property. This is a valid use
    case that is permitted by the binding and indicates to the switch:
    auto-configure port with maximum capabilities.

    Fixes: 0e27921816ad ("net: dsa: Use PHYLINK for the CPU/DSA ports")
    Signed-off-by: Florian Fainelli
    Reviewed-by: Andrew Lunn
    Signed-off-by: David S. Miller

    Florian Fainelli
     

08 Jun, 2019

1 commit


31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 3029 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

30 May, 2019

2 commits

  • For DSA switches that do not have an .adjust_link callback, aka those
    who transitioned totally to the PHYLINK-compliant API, use PHYLINK to
    drive the CPU/DSA ports.

    The PHYLIB usage and .adjust_link are kept but deprecated, and users are
    asked to transition from it. The reason why we can't do anything for
    them is because PHYLINK does not wrap the fixed-link state behind a
    phydev object, so we cannot wrap .phylink_mac_config into .adjust_link
    unless we fabricate a phy_device structure.

    For these ports, the newly introduced PHYLINK_DEV operation type is
    used and the dsa_switch device structure is passed to PHYLINK for
    printing purposes. The handling of the PHYLINK_NETDEV and PHYLINK_DEV
    PHYLINK instances is common from the perspective of the driver.

    Signed-off-by: Ioana Ciornei
    Signed-off-by: Vladimir Oltean
    Reviewed-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Ioana Ciornei
     
  • In order to have a common handling of PHYLINK for the slave and non-user
    ports, the DSA core glue logic (between PHYLINK and the driver) must use
    an API that does not rely on a struct net_device.

    These will also be called by the CPU-port-handling code in a further
    patch.

    Signed-off-by: Ioana Ciornei
    Suggested-by: Vladimir Oltean
    Reviewed-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Ioana Ciornei
     

06 May, 2019

1 commit


01 May, 2019

5 commits

  • This hides the need to perform a two-phase transaction and construct a
    switchdev_obj_port_vlan struct.

    Call graph (including a function that will be introduced in a follow-up
    patch) looks like this now (same for the *_vlan_del function):

    dsa_slave_vlan_rx_add_vid dsa_port_setup_8021q_tagging
    | |
    | |
    | +-------------+
    | |
    v v
    dsa_port_vid_add dsa_slave_port_obj_add
    | |
    +-------+ +-------+
    | |
    v v
    dsa_port_vlan_add

    Signed-off-by: Vladimir Oltean
    Reviewed-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Vladimir Oltean
     
  • Even if VLAN filtering is global, DSA will call this callback once per
    each port. Drivers should not have to compare the global state with the
    requested change. So let DSA do it.

    Signed-off-by: Vladimir Oltean
    Reviewed-by: Andrew Lunn
    Signed-off-by: David S. Miller

    Vladimir Oltean
     
  • The current behavior is not as obvious as one would assume (which is
    that, if the driver set vlan_filtering_is_global = 1, then checking any
    dp->vlan_filtering would yield the same result). Only the ports which
    are actively enslaved into a bridge would have vlan_filtering set.

    This makes it tricky for drivers to check what the global state is.
    So fix this and make the struct dsa_switch hold this global setting.

    Signed-off-by: Vladimir Oltean
    Signed-off-by: David S. Miller

    Vladimir Oltean
     
  • On some switches, the action of whether to parse VLAN frame headers and use
    that information for ingress admission is configurable, but not per
    port. Such is the case for the Broadcom BCM53xx and the NXP SJA1105
    families, for example. In that case, DSA can prevent the bridge core
    from trying to apply different VLAN filtering settings on net devices
    that belong to the same switch.

    Signed-off-by: Vladimir Oltean
    Suggested-by: Florian Fainelli
    Reviewed-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Vladimir Oltean
     
  • This allows drivers to query the VLAN setting imposed by the bridge
    driver directly from DSA, instead of keeping their own state based on
    the .port_vlan_filtering callback.

    Signed-off-by: Vladimir Oltean
    Reviewed-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Vladimir Oltean
     

03 Mar, 2019

1 commit


26 Feb, 2019

1 commit

  • The call to of_parse_phandle returns a node pointer with refcount
    incremented thus it must be explicitly decremented after the last
    usage.

    Detected by coccinelle with the following warnings:
    ./net/dsa/port.c:294:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 284, but without a corresponding object release within this function.
    ./net/dsa/dsa2.c:627:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 618, but without a corresponding object release within this function.
    ./net/dsa/dsa2.c:630:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 618, but without a corresponding object release within this function.
    ./net/dsa/dsa2.c:636:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 618, but without a corresponding object release within this function.
    ./net/dsa/dsa2.c:639:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 618, but without a corresponding object release within this function.

    Signed-off-by: Wen Yang
    Reviewed-by: Vivien Didelot
    Cc: Andrew Lunn
    Cc: Vivien Didelot
    Cc: Florian Fainelli
    Cc: "David S. Miller"
    Cc: Vivien Didelot
    Cc: netdev@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: David S. Miller

    Wen Yang
     

25 Feb, 2019

2 commits


23 Feb, 2019

1 commit

  • In order to properly support VLAN filtering being enabled/disabled on a
    bridge, while having other ports being non bridge port members, we need
    to support the ndo_vlan_rx_{add,kill}_vid callbacks in order to make
    sure the non-bridge ports can continue receiving VLAN tags, even when
    the switch is globally configured to do ingress/egress VID checking.

    Since we can call dsa_port_vlan_{add,del} with a bridge_dev pointer
    NULL, we now need to check that in these two functions.

    We specifically deal with two possibly problematic cases:

    - creating a bridge VLAN entry while there is an existing VLAN device
    claiming that same VID

    - creating a VLAN device while there is an existing bridge VLAN entry
    with that VID

    Those are both resolved with returning -EBUSY back to user-space.

    Signed-off-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Florian Fainelli
     

22 Feb, 2019

3 commits

  • In preparation for removing SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT,
    add support for a function that processes the
    SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS and
    SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS attributes and returns not
    supported for any flag set, since DSA does not currently support
    toggling those bridge port attributes (yet).

    Signed-off-by: Florian Fainelli
    Acked-by: Jiri Pirko
    Signed-off-by: David S. Miller

    Florian Fainelli
     
  • Switches work by learning the MAC address for each attached station by
    monitoring traffic from each station. When a station sends a packet,
    the switch records which port the MAC address is connected to.

    With IPv4 networking, before communication commences with a neighbour,
    an ARP packet is broadcasted to all stations asking for the MAC address
    corresponding with the IPv4. The desired station responds with an ARP
    reply, and the ARP reply causes the switch to learn which port the
    station is connected to.

    With IPv6 networking, the situation is rather different. Rather than
    broadcasting ARP packets, a "neighbour solicitation" is multicasted
    rather than broadcasted. This multicast needs to reach the intended
    station in order for the neighbour to be discovered.

    Once a neighbour has been discovered, and entered into the sending
    stations neighbour cache, communication can restart at a point later
    without sending a new neighbour solicitation, even if the entry in
    the neighbour cache is marked as stale. This can be after the MAC
    address has expired from the forwarding cache of the DSA switch -
    when that occurs, there is a long pause in communication.

    Our DSA implementation for mv88e6xxx switches disables flooding of
    multicast and unicast frames for bridged ports. As per the above
    description, this is fine for IPv4 networking, since the broadcasted
    ARP queries will be sent to and received by all stations on the same
    network. However, this breaks IPv6 very badly - blocking neighbour
    solicitations and later causing connections to stall.

    The defaults that the Linux bridge code expect from bridges are for
    unknown unicast and unknown multicast frames to be flooded to all ports
    on the bridge, which is at odds to the defaults adopted by our DSA
    implementation for mv88e6xxx switches.

    This commit enables by default flooding of both unknown unicast and
    unknown multicast frames whenever a port is added to a bridge, and
    disables the flooding when a port leaves the bridge. This means that
    mv88e6xxx DSA switches now behave as per the bridge(8) man page, and
    IPv6 works flawlessly through such a switch.

    Reviewed-by: Florian Fainelli
    Reviewed-by: Vivien Didelot
    Signed-off-by: Russell King
    Signed-off-by: David S. Miller

    Russell King
     
  • The Linux bridge implementation allows various properties of the bridge
    to be controlled, such as flooding unknown unicast and multicast frames.
    This patch adds the necessary DSA infrastructure to allow the Linux
    bridge support to control these properties for DSA switches.

    Reviewed-by: Vivien Didelot
    Signed-off-by: Russell King
    [florian: Add missing dp and ds variables declaration to fix build]
    Signed-off-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Russell King
     

21 Feb, 2019

1 commit

  • When a DSA port is added to a bridge and brought up, the resulting STP
    state programmed into the hardware depends on the order that these
    operations are performed. However, the Linux bridge code believes that
    the port is in disabled mode.

    If the DSA port is first added to a bridge and then brought up, it will
    be in blocking mode. If it is brought up and then added to the bridge,
    it will be in disabled mode.

    This difference is caused by DSA always setting the STP mode in
    dsa_port_enable() whether or not this port is part of a bridge. Since
    bridge always sets the STP state when the port is added, brought up or
    taken down, it is unnecessary for us to manipulate the STP state.

    Apparently, this code was copied from Rocker, and the very next day a
    similar fix for Rocker was merged but was not propagated to DSA. See
    e47172ab7e41 ("rocker: put port in FORWADING state after leaving bridge")

    Fixes: b73adef67765 ("net: dsa: integrate with SWITCHDEV for HW bridging")
    Signed-off-by: Russell King
    Reviewed-by: Vivien Didelot
    Reviewed-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Russell King
     

24 Nov, 2018

1 commit


01 Jun, 2018

1 commit

  • A follow-up patch enables emitting VLAN notifications for the bridge CPU
    port in addition to the existing slave port notifications. These
    notifications have orig_dev set to the bridge in question.

    Because there's no specific support for these VLANs, just ignore the
    notifications to maintain the current behavior.

    Signed-off-by: Petr Machata
    Reviewed-by: Vivien Didelot
    Reviewed-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Petr Machata
     

27 Apr, 2018

2 commits


24 Jan, 2018

1 commit

  • This adds support for enabling the internal PHY for a 'cpu' port.
    It has been tested on GE B850v3, B650v3 and B450v3, which have a
    built-in MV88E6240 switch hardwired to a PCIe based network card.
    On these machines the internal PHY of the i210 network card and
    the Marvell switch are connected to each other and must be enabled
    for properly using the switch. While the i210 PHY will be enabled
    when the network interface is enabled, the switch's port is not
    exposed as network interface. Additionally the mv88e6xxx driver
    resets the chip during probe, so the PHY is disabled without this
    patch.

    Signed-off-by: Sebastian Reichel
    Reviewed-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Sebastian Reichel
     

10 Nov, 2017

2 commits

  • The software bridge can be build with vlan filtering support
    included. However, by default it is turned off. In its turned off
    state, it still passes VLANs via switchev, even though they are not to
    be used. Don't pass these VLANs to the hardware. Only do so when vlan
    filtering is enabled.

    This fixes at least one corner case. There are still issues in other
    corners, such as when vlan_filtering is later enabled.

    Signed-off-by: Andrew Lunn
    Signed-off-by: David S. Miller

    Andrew Lunn
     
  • The notify mechanism does not need to modify the port it is notifying.
    So make the parameter const.

    Signed-off-by: Andrew Lunn
    Reviewed-by: Vivien Didelot
    Signed-off-by: David S. Miller

    Andrew Lunn
     

28 Oct, 2017

1 commit

  • The new bindings (dsa2.c) and the old bindings (legacy.c) share two
    helpers dsa_cpu_dsa_setup and dsa_cpu_dsa_destroy, used to register or
    deregister a fixed PHY if a given port has a corresponding device node.

    Unclutter the code by moving them into two new port.c helpers,
    dsa_port_fixed_link_register_of and dsa_port_fixed_link_(un)register_of.

    Signed-off-by: Vivien Didelot
    Signed-off-by: David S. Miller

    Vivien Didelot
     

26 Sep, 2017

1 commit

  • Provide dsa_port_enable and dsa_port_disable helpers to respectively
    enable and disable a switch port. This makes the dsa_port_set_state_now
    helper static.

    Signed-off-by: Vivien Didelot
    Reviewed-by: Florian Fainelli
    Reviewed-by: Andrew Lunn
    Signed-off-by: David S. Miller

    Vivien Didelot
     

22 Sep, 2017

1 commit

  • Dumping a DSA port's FDB entries is not specific to a DSA slave, so add
    a dsa_port_fdb_dump function, similarly to dsa_port_fdb_add and
    dsa_port_fdb_del.

    Signed-off-by: Vivien Didelot
    Reviewed-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Vivien Didelot
     

08 Aug, 2017

4 commits