18 Feb, 2017

1 commit

  • [ Upstream commit 382e1eea2d983cd2343482c6a638f497bb44a636 ]

    dsa_slave_create() can fail, and dsa_user_port_unapply() will properly check
    for the network device not being NULL before attempting to destroy it. We were
    not setting the slave network device as NULL if dsa_slave_create() failed, so
    we would later on be calling dsa_slave_destroy() on a now free'd and
    unitialized network device, causing crashes in dsa_slave_destroy().

    Fixes: 83c0afaec7b7 ("net: dsa: Add new binding implementation")
    Signed-off-by: Florian Fainelli
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Florian Fainelli
     

04 Feb, 2017

1 commit

  • [ Upstream commit f154be241d22298d2b63c9b613f619fa1086ea75 ]

    Commit 448b4482c671 ("net: dsa: Add lockdep class to tx queues to avoid
    lockdep splat") removed the netif_device_detach() call done in
    dsa_slave_suspend() which is necessary, and paired with a corresponding
    netif_device_attach(), bring it back.

    Fixes: 448b4482c671 ("net: dsa: Add lockdep class to tx queues to avoid lockdep splat")
    Signed-off-by: Florian Fainelli
    Reviewed-by: Andrew Lunn
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Florian Fainelli
     

15 Jan, 2017

1 commit

  • [ Upstream commit faf3a932fbeb77860226a8323eacb835edc98648 ]

    It is perfectly possible to have non zero indexed switches being present
    in a DSA switch tree, in such a case, we will be deferencing a NULL
    pointer while dsa_cpu_port_ethtool_{setup,restore}. Be more defensive
    and ensure that dst->ds[0] is valid before doing anything with it.

    Fixes: 0c73c523cf73 ("net: dsa: Initialize CPU port ethtool ops per tree")
    Signed-off-by: Florian Fainelli
    Reviewed-by: Vivien Didelot
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Florian Fainelli
     

30 Nov, 2016

3 commits

  • Make sure to deregister and free any fixed-link PHY registered using
    of_phy_register_fixed_link() on slave-setup errors and on slave destroy.

    Fixes: 0d8bcdd383b8 ("net: dsa: allow for more complex PHY setups")
    Signed-off-by: Johan Hovold
    Signed-off-by: David S. Miller

    Johan Hovold
     
  • Add helper to deregister fixed-link PHYs registered using
    of_phy_register_fixed_link().

    Convert the two drivers that care to deregister their fixed-link PHYs to
    use the new helper, but note that most drivers currently fail to do so.

    Signed-off-by: Johan Hovold
    Signed-off-by: David S. Miller

    Johan Hovold
     
  • Make sure to drop the reference taken by of_parse_phandle() before
    returning from dsa_slave_phy_setup().

    Note that this also modifies the PHY priority so that any fixed-link
    node is only parsed when no phy-handle is given, which is in accordance
    with the common scheme for this.

    Fixes: 0d8bcdd383b8 ("net: dsa: allow for more complex PHY setups")
    Signed-off-by: Johan Hovold
    Signed-off-by: David S. Miller

    Johan Hovold
     

29 Nov, 2016

1 commit

  • _dsa_register_switch() gets a dsa_switch_tree object either via
    dsa_get_dst() or via dsa_add_dst(). Former path does not increase kref
    in returned object (resulting into caller not owning a reference),
    while later path does create a new object (resulting into caller owning
    a reference).

    The rest of _dsa_register_switch() assumes that it owns a reference, and
    calls dsa_put_dst().

    This causes a memory breakage if first switch in the tree initialized
    successfully, but second failed to initialize. In particular, freed
    dsa_swith_tree object is left referenced by switch that was initialized,
    and later access to sysfs attributes of that switch cause OOPS.

    To fix, need to add kref_get() call to dsa_get_dst().

    Fixes: 83c0afaec7b7 ("net: dsa: Add new binding implementation")
    Signed-off-by: Nikita Yushchenko
    Reviewed-by: Andrew Lunn
    Signed-off-by: David S. Miller

    Nikita Yushchenko
     

28 Nov, 2016

1 commit

  • Make sure to drop the reference taken by of_phy_find_device() when
    registering and deregistering the fixed-link PHY-device.

    Fixes: 39b0c705195e ("net: dsa: Allow configuration of CPU & DSA port
    speeds/duplex")
    Signed-off-by: Johan Hovold
    Signed-off-by: David S. Miller

    Johan Hovold
     

23 Sep, 2016

2 commits

  • Today the DSA drivers are in charge of flushing the MAC addresses
    associated to a port when its STP state changes from Learning or
    Forwarding, to Disabled or Blocking or Listening.

    This makes the drivers more complex and hides the generic switch logic.
    Introduce a new optional port_fast_age operation to dsa_switch_ops, to
    move this logic to the DSA layer and keep drivers simple.

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

    Vivien Didelot
     
  • Add a void helper to set the STP state of a port, checking first if the
    required routine is provided by the driver.

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

    Vivien Didelot
     

20 Sep, 2016

2 commits


16 Sep, 2016

1 commit

  • Add support for the 2-bytes Qualcomm tag that gigabit switches such as
    the QCA8337/N might insert when receiving packets, or that we need
    to insert while targeting specific switch ports. The tag is inserted
    directly behind the ethernet header.

    Reviewed-by: Andrew Lunn
    Reviewed-by: Florian Fainelli
    Signed-off-by: John Crispin
    Signed-off-by: David S. Miller

    John Crispin
     

01 Sep, 2016

1 commit


25 Aug, 2016

1 commit

  • Now that the dsa_switch_driver structure contains only function pointers
    as it is supposed to, rename it to the more appropriate dsa_switch_ops,
    uniformly to any other operations structure in the kernel.

    No functional changes here, basically just the result of something like:
    s/dsa_switch_driver *drv/dsa_switch_ops *ops/g

    However keep the {un,}register_switch_driver functions and their
    dsa_switch_drivers list as is, since they represent the -- likely to be
    deprecated soon -- legacy DSA registration framework.

    In the meantime, also fix the following checks from checkpatch.pl to
    make it happy with this patch:

    CHECK: Comparison to NULL could be written "!ops"
    #403: FILE: net/dsa/dsa.c:470:
    + if (ops == NULL) {

    CHECK: Comparison to NULL could be written "ds->ops->get_strings"
    #773: FILE: net/dsa/slave.c:697:
    + if (ds->ops->get_strings != NULL)

    CHECK: Comparison to NULL could be written "ds->ops->get_ethtool_stats"
    #824: FILE: net/dsa/slave.c:785:
    + if (ds->ops->get_ethtool_stats != NULL)

    CHECK: Comparison to NULL could be written "ds->ops->get_sset_count"
    #835: FILE: net/dsa/slave.c:798:
    + if (ds->ops->get_sset_count != NULL)

    total: 0 errors, 0 warnings, 4 checks, 784 lines checked

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

    Vivien Didelot
     

23 Aug, 2016

1 commit


20 Aug, 2016

2 commits

  • The Broadcom Starfighter 2 switch driver should be a proper platform
    driver, now that the DSA code has been updated to allow that, register a
    switch device, feed it with the proper configuration data coming from
    Device Tree and register our switch device with DSA.

    The bulk of the changes consist in moving what bcm_sf2_sw_setup() did
    into the platform driver probe function.

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

    Florian Fainelli
     
  • In preparation for allowing switch drivers to implement system-wide
    suspend/resume functions, export dsa_switch_suspend and
    dsa_switch_resume() such that these are callable from the appropriate
    driver specific suspend/resume functions.

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

    Florian Fainelli
     

20 Jul, 2016

1 commit

  • Add a new function for DSA drivers to handle the switchdev
    SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME attribute.

    The ageing time is passed as milliseconds.

    Also because we can have multiple logical bridges on top of a physical
    switch and ageing time are switch-wide, call the driver function with
    the fastest ageing time in use on the chip instead of the requested one.

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

    Vivien Didelot
     

13 Jul, 2016

1 commit


09 Jul, 2016

1 commit

  • The routing table of every switch in a tree is currently initialized to
    all zeros. This is an issue since 0 is a valid port number.

    Add a DSA_RTABLE_NONE=-1 constant to initialize the signed values of the
    routing table pointing to other switches.

    This fixes the device mapping of the mv88e6xxx driver where the port
    pointing to the switch itself and to non-existent switches was wrongly
    configured to be 0. It is now set to the expected 0xf value.

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

    Vivien Didelot
     

09 Jun, 2016

5 commits

  • Now that we can properly support multiple distinct trees in the system,
    using a global variable: dsa_cpu_port_ethtool_ops is getting clobbered
    as soon as the second switch tree gets probed, and we don't want that.

    We need to move this to be dynamically allocated, and since we can't
    really be comparing addresses anymore to determine first time
    initialization versus any other times, just move this to dsa.c and
    dsa2.c where the remainder of the dst/ds initialization happens.

    The operations teardown restores the master netdev's ethtool_ops to its
    original ethtool_ops pointer (typically within the Ethernet driver)

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

    Florian Fainelli
     
  • Add a helper function: dsa_cpu_port_ethtool_init() which initializes a
    custom ethtool_ops structure with custom DSA ethtool operations for CPU
    ports. This is a preliminary change to move the initialization outside
    of net/dsa/slave.c.

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

    Florian Fainelli
     
  • Mimic what net/dsa/dsa.c does and provide a slave MII bus by default
    which will be created if the driver implements a phy_read method.

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

    Florian Fainelli
     
  • Some drivers rely on these two bitmasks to contain the correct values
    for them to successfully probe and initialize at drv->setup() time,
    calculate correct values to put in both masks as early as possible in
    dsa_get_ports_dn().

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

    Florian Fainelli
     
  • In case we have multiples trees and switches with the same index, we
    need to add another discriminating id: the switch tree.

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

    Florian Fainelli
     

05 Jun, 2016

11 commits

  • The existing DSA binding has a number of limitations and problems. The
    main problem is that it cannot represent a switch as a linux device,
    hanging off some bus. It is limited to one CPU port. The DSA platform
    device is artificial, and does not really represent hardware.

    Implement a new binding which can be embedded into any type of node on
    a bus to represent one switch device, and its links to other switches.

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

    Andrew Lunn
     
  • The switch may want to instantiate its own MDIO bus. Only do it
    centrally if the switch has not already created one, and the read op
    is implemented.

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

    Andrew Lunn
     
  • Replace the two switch statements with an array lookup, and store the
    result in the dsa tree structure. The drivers no longer need to know
    the selected tag protocol, so remove it from the dsa switch structure.

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

    Andrew Lunn
     
  • Refactor the code to setup a single DSA/CPU port into a function of
    its own, and export it, so it can be used by the new binding.

    Similarly, refactor the destroy code into a function. When destroying
    the ports, don't put the of node. They should be released at the end
    along with the normal ports.

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

    Andrew Lunn
     
  • The new binding will not have a chip data structure, it will place the
    routing directly into the switch structure. To enable backwards
    compatibility, copy the routing from the chip data into the switch
    structure.

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

    Andrew Lunn
     
  • With a maximum of four switches, the size of the routing table is the
    same as the pointer to it. Removing it makes the code simpler.

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

    Andrew Lunn
     
  • Move the port device node structure into the port structure, from the
    chip data. This information is needed in the next step of implementing
    the new binding.

    The chip data structure is used while parsing the whole old binding,
    before the individual switch structures exist. With the new bindings,
    this is reversed, the switches exist first, and the interconnections
    between the switches is derived from the individual switch
    bindings. Thus this chip data structure becomes unneeded.

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

    Andrew Lunn
     
  • There are going to be more per-port members added to the switch
    structure. So add a port structure and move the netdev into it.

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

    Andrew Lunn
     
  • The platform data nr_chips is used when validating a received packet,
    to ensure it comes from a know switch chip. The number of possible
    switches is limited to DSA_MAX_SWITCHES, so use this as the first
    validation step. The new binding allows holes in the dst->ds[] array,
    so also ensure ensure there is a valid dsa_switch for this packet.

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

    Andrew Lunn
     
  • The DSA layer should no longer assume the switch is connected to an
    MDIO bus. As a result, we cannot use the address on the MDIO bus when
    forming the name of the switches internal MDIO bus for its builtin and
    possibly external PHYs. The switch index is sufficient to make the
    name unique, so drop the MDIO address.

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

    Andrew Lunn
     
  • The new binding does not make use of dsa_chip_data, a.k.a cd. When
    retrieving the size of the EEPROM attached to a switch, don't assume
    there is a cd attached to the switch structure.

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

    Andrew Lunn
     

12 May, 2016

3 commits

  • The dsa_switch structure contains a dsa_chip_data member called pd.
    However in the rest of the code, pd is used for dsa_platform_data.
    This is confusing. Rename it cd, which is already often used in dsa.c
    and slave.c for this data type.

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

    Andrew Lunn
     
  • The switch drivers only use the master_dev member for dev_info()
    messages. Now that the device is passed to the old style probe, and
    new style drivers are probed as true linux drivers, this is no longer
    needed.

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

    Andrew Lunn
     
  • Resetting the switch is something the driver does, not the framework.
    So move the parsing of this property into the driver.

    There are no in kernel users of this property, so moving it does not
    break anything. There is however a board which will make use of this
    property making its way into the kernel.

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

    Andrew Lunn