03 Oct, 2020

2 commits

  • Now that we are guaranteed that dsa_untag_bridge_pvid() is called after
    eth_type_trans() we can utilize __vlan_find_dev_deep_rcu() which will
    take care of finding an 802.1Q upper on top of a bridge master.

    A common use case, prior to 12a1526d067 ("net: dsa: untag the bridge
    pvid from rx skbs") was to configure a bridge 802.1Q upper like this:

    ip link add name br0 type bridge vlan_filtering 0
    ip link add link br0 name br0.1 type vlan id 1

    in order to pop the default_pvid VLAN tag.

    With this change we restore that behavior while still allowing the DSA
    receive path to automatically pop the VLAN tag.

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

    Florian Fainelli
     
  • Now that dsa_untag_bridge_pvid() is called after eth_type_trans() we are
    guaranteed that skb->protocol will be set to a correct value, thus
    allowing us to avoid calling vlan_eth_hdr().

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

    Florian Fainelli
     

24 Sep, 2020

1 commit

  • Currently the bridge untags VLANs present in its VLAN groups in
    __allowed_ingress() only when VLAN filtering is enabled.

    But when a skb is seen on the RX path as tagged with the bridge's pvid,
    and that bridge has vlan_filtering=0, and there isn't any 8021q upper
    with that VLAN either, then we have a problem. The bridge will not untag
    it (since it is supposed to remain VLAN-unaware), and pvid-tagged
    communication will be broken.

    There are 2 situations where we can end up like that:

    1. When installing a pvid in egress-tagged mode, like this:

    ip link add dev br0 type bridge vlan_filtering 0
    ip link set swp0 master br0
    bridge vlan del dev swp0 vid 1
    bridge vlan add dev swp0 vid 1 pvid

    This happens because DSA configures the VLAN membership of the CPU port
    using the same flags as swp0 (in this case "pvid and not untagged"), in
    an attempt to copy the frame as-is from ingress to the CPU.

    However, in this case, the packet may arrive untagged on ingress, it
    will be pvid-tagged by the ingress port, and will be sent as
    egress-tagged towards the CPU. Otherwise stated, the CPU will see a VLAN
    tag where there was none to speak of on ingress.

    When vlan_filtering is 1, this is not a problem, as stated in the first
    paragraph, because __allowed_ingress() will pop it. But currently, when
    vlan_filtering is 0 and we have such a VLAN configuration, we need an
    8021q upper (br0.1) to be able to ping over that VLAN, which is not
    symmetrical with the vlan_filtering=1 case, and therefore, confusing for
    users.

    Basically what DSA attempts to do is simply an approximation: try to
    copy the skb with (or without) the same VLAN all the way up to the CPU.
    But DSA drivers treat CPU port VLAN membership in various ways (which is
    a good segue into situation 2). And some of those drivers simply tell
    the CPU port to copy the frame unmodified, which is the golden standard
    when it comes to VLAN processing (therefore, any driver which can
    configure the hardware to do that, should do that, and discard the VLAN
    flags requested by DSA on the CPU port).

    2. Some DSA drivers always configure the CPU port as egress-tagged, in
    an attempt to recover the classified VLAN from the skb. These drivers
    cannot work at all with untagged traffic when bridged in
    vlan_filtering=0 mode. And they can't go for the easy "just keep the
    pvid as egress-untagged towards the CPU" route, because each front port
    can have its own pvid, and that might require conflicting VLAN
    membership settings on the CPU port (swp1 is pvid for VID 1 and
    egress-tagged for VID 2; swp2 is egress-taggeed for VID 1 and pvid for
    VID 2; with this simplistic approach, the CPU port, which is really a
    separate hardware entity and has its own VLAN membership settings, would
    end up being egress-untagged in both VID 1 and VID 2, therefore losing
    the VLAN tags of ingress traffic).

    So the only thing we can do is to create a helper function for resolving
    the problematic case (that is, a function which untags the bridge pvid
    when that is in vlan_filtering=0 mode), which taggers in need should
    call. It isn't called from the generic DSA receive path because there
    are drivers that fall neither in the first nor second category.

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

    Vladimir Oltean
     

12 Sep, 2020

1 commit

  • This reverts commit 314f76d7a68bab0516aa52877944e6aacfa0fc3f.

    Citing that commit message, the call graph was:

    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

    Now that tag_8021q has its own ops structure, it no longer relies on
    dsa_port_vid_add, and therefore on the dsa_switch_ops to install its
    VLANs.

    So dsa_port_vid_add now only has one single caller. So we can simplify
    the call graph to what it was before, aka:

    dsa_slave_vlan_rx_add_vid 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
     

06 Jul, 2020

1 commit

  • net/dsa/slave.c:505:13: warning: incorrect type in initializer (different address spaces)
    net/dsa/slave.c:505:13: expected void const [noderef] *__vpp_verify
    net/dsa/slave.c:505:13: got struct pcpu_sw_netstats *

    Add the needed _percpu property to prevent this warning.

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

    Andrew Lunn
     

13 May, 2020

1 commit

  • DSA assumes that a bridge which has vlan filtering disabled is not
    vlan aware, and ignores all vlan configuration. However, the kernel
    software bridge code allows configuration in this state.

    This causes the kernel's idea of the bridge vlan state and the
    hardware state to disagree, so "bridge vlan show" indicates a correct
    configuration but the hardware lacks all configuration. Even worse,
    enabling vlan filtering on a DSA bridge immediately blocks all traffic
    which, given the output of "bridge vlan show", is very confusing.

    Provide an option that drivers can set to indicate they want to receive
    vlan configuration even when vlan filtering is disabled. At the very
    least, this is safe for Marvell DSA bridges, which do not look up
    ingress traffic in the VTU if the port is in 8021Q disabled state. It is
    also safe for the Ocelot switch family. Whether this change is suitable
    for all DSA bridges is not known.

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

    Russell King
     

11 May, 2020

1 commit

  • One way of utilizing DSA is by cascading switches which do not all have
    compatible taggers. Consider the following real-life topology:

    +---------------------------------------------------------------+
    | LS1028A |
    | +------------------------------+ |
    | | DSA master for Felix | |
    | |(internal ENETC port 2: eno2))| |
    | +------------+------------------------------+-------------+ |
    | | Felix embedded L2 switch | |
    | | | |
    | | +--------------+ +--------------+ +--------------+ | |
    | | |DSA master for| |DSA master for| |DSA master for| | |
    | | | SJA1105 1 | | SJA1105 2 | | SJA1105 3 | | |
    | | |(Felix port 1)| |(Felix port 2)| |(Felix port 3)| | |
    +--+-+--------------+---+--------------+---+--------------+--+--+

    +-----------------------+ +-----------------------+ +-----------------------+
    | SJA1105 switch 1 | | SJA1105 switch 2 | | SJA1105 switch 3 |
    +-----+-----+-----+-----+ +-----+-----+-----+-----+ +-----+-----+-----+-----+
    |sw1p0|sw1p1|sw1p2|sw1p3| |sw2p0|sw2p1|sw2p2|sw2p3| |sw3p0|sw3p1|sw3p2|sw3p3|
    +-----+-----+-----+-----+ +-----+-----+-----+-----+ +-----+-----+-----+-----+

    The above can be described in the device tree as follows (obviously not
    complete):

    mscc_felix {
    dsa,member = ;
    ports {
    port@4 {
    ethernet = ;
    };
    };
    };

    sja1105_switch1 {
    dsa,member = ;
    ports {
    port@4 {
    ethernet = ;
    };
    };
    };

    sja1105_switch2 {
    dsa,member = ;
    ports {
    port@4 {
    ethernet = ;
    };
    };
    };

    sja1105_switch3 {
    dsa,member = ;
    ports {
    port@4 {
    ethernet = ;
    };
    };
    };

    Basically we instantiate one DSA switch tree for every hardware switch
    in the system, but we still give them globally unique switch IDs (will
    come back to that later). Having 3 disjoint switch trees makes the
    tagger drivers "just work", because net devices are registered for the
    3 Felix DSA master ports, and they are also DSA slave ports to the ENETC
    port. So packets received on the ENETC port are stripped of their
    stacked DSA tags one by one.

    Currently, hardware bridging between ports on the same sja1105 chip is
    possible, but switching between sja1105 ports on different chips is
    handled by the software bridge. This is fine, but we can do better.

    In fact, the dsa_8021q tag used by sja1105 is compatible with cascading.
    In other words, a sja1105 switch can correctly parse and route a packet
    containing a dsa_8021q tag. So if we could enable hardware bridging on
    the Felix DSA master ports, cross-chip bridging could be completely
    offloaded.

    Such as system would be used as follows:

    ip link add dev br0 type bridge && ip link set dev br0 up
    for port in sw0p0 sw0p1 sw0p2 sw0p3 \
    sw1p0 sw1p1 sw1p2 sw1p3 \
    sw2p0 sw2p1 sw2p2 sw2p3; do
    ip link set dev $port master br0
    done

    The above makes switching between ports on the same row be performed in
    hardware, and between ports on different rows in software. Now assume
    the Felix switch ports are called swp0, swp1, swp2. By running the
    following extra commands:

    ip link add dev br1 type bridge && ip link set dev br1 up
    for port in swp0 swp1 swp2; do
    ip link set dev $port master br1
    done

    the CPU no longer sees packets which traverse sja1105 switch boundaries
    and can be forwarded directly by Felix. The br1 bridge would not be used
    for any sort of traffic termination.

    For this to work, we need to give drivers an opportunity to listen for
    bridging events on DSA trees other than their own, and pass that other
    tree index as argument. I have made the assumption, for the moment, that
    the other existing DSA notifiers don't need to be broadcast to other
    trees. That assumption might turn out to be incorrect. But in the
    meantime, introduce a dsa_broadcast function, similar in purpose to
    dsa_port_notify, which is used only by the bridging notifiers.

    Signed-off-by: Vladimir Oltean
    Reviewed-by: Florian Fainelli
    Signed-off-by: Jakub Kicinski

    Vladimir Oltean
     

24 Apr, 2020

1 commit

  • gro_cells lib is used by different encapsulating netdevices, such as
    geneve, macsec, vxlan etc. to speed up decapsulated traffic processing.
    CPU tag is a sort of "encapsulation", and we can use the same mechs to
    greatly improve overall DSA performance.
    skbs are passed to the GRO layer after removing CPU tags, so we don't
    need any new packet offload types as it was firstly proposed by me in
    the first GRO-over-DSA variant [1].

    The size of struct gro_cells is sizeof(void *), so hot struct
    dsa_slave_priv becomes only 4/8 bytes bigger, and all critical fields
    remain in one 32-byte cacheline.
    The other positive side effect is that drivers for network devices
    that can be shipped as CPU ports of DSA-driven switches can now use
    napi_gro_frags() to pass skbs to kernel. Packets built that way are
    completely non-linear and are likely being dropped without GRO.

    This was tested on to-be-mainlined-soon Ethernet driver that uses
    napi_gro_frags(), and the overall performance was on par with the
    variant from [1], sometimes even better due to minimal overhead.
    net.core.gro_normal_batch tuning may help to push it to the limit
    on particular setups and platforms.

    iperf3 IPoE VLAN NAT TCP forwarding (port1.218 -> port0) setup
    on 1.2 GHz MIPS board:

    5.7-rc2 baseline:

    [ID] Interval Transfer Bitrate Retr
    [ 5] 0.00-120.01 sec 9.00 GBytes 644 Mbits/sec 413 sender
    [ 5] 0.00-120.00 sec 8.99 GBytes 644 Mbits/sec receiver

    Iface RX packets TX packets
    eth0 7097731 7097702
    port0 426050 6671829
    port1 6671681 425862
    port1.218 6671677 425851

    With this patch:

    [ID] Interval Transfer Bitrate Retr
    [ 5] 0.00-120.01 sec 12.2 GBytes 870 Mbits/sec 122 sender
    [ 5] 0.00-120.00 sec 12.2 GBytes 870 Mbits/sec receiver

    Iface RX packets TX packets
    eth0 9474792 9474777
    port0 455200 353288
    port1 9019592 455035
    port1.218 353144 455024

    v2:
    - Add some performance examples in the commit message;
    - No functional changes.

    [1] https://lore.kernel.org/netdev/20191230143028.27313-1-alobakin@dlink.ru/

    Signed-off-by: Alexander Lobakin
    Signed-off-by: David S. Miller

    Alexander Lobakin
     

28 Mar, 2020

2 commits

  • Many switches don't have an explicit knob for configuring the MTU
    (maximum transmission unit per interface). Instead, they do the
    length-based packet admission checks on the ingress interface, for
    reasons that are easy to understand (why would you accept a packet in
    the queuing subsystem if you know you're going to drop it anyway).

    So it is actually the MRU that these switches permit configuring.

    In Linux there only exists the IFLA_MTU netlink attribute and the
    associated dev_set_mtu function. The comments like to play blind and say
    that it's changing the "maximum transfer unit", which is to say that
    there isn't any directionality in the meaning of the MTU word. So that
    is the interpretation that this patch is giving to things: MTU == MRU.

    When 2 interfaces having different MTUs are bridged, the bridge driver
    MTU auto-adjustment logic kicks in: what br_mtu_auto_adjust() does is it
    adjusts the MTU of the bridge net device itself (and not that of the
    slave net devices) to the minimum value of all slave interfaces, in
    order for forwarded packets to not exceed the MTU regardless of the
    interface they are received and send on.

    The idea behind this behavior, and why the slave MTUs are not adjusted,
    is that normal termination from Linux over the L2 forwarding domain
    should happen over the bridge net device, which _is_ properly limited by
    the minimum MTU. And termination over individual slave devices is
    possible even if those are bridged. But that is not "forwarding", so
    there's no reason to do normalization there, since only a single
    interface sees that packet.

    The problem with those switches that can only control the MRU is with
    the offloaded data path, where a packet received on an interface with
    MRU 9000 would still be forwarded to an interface with MRU 1500. And the
    br_mtu_auto_adjust() function does not really help, since the MTU
    configured on the bridge net device is ignored.

    In order to enforce the de-facto MTU == MRU rule for these switches, we
    need to do MTU normalization, which means: in order for no packet larger
    than the MTU configured on this port to be sent, then we need to limit
    the MRU on all ports that this packet could possibly come from. AKA
    since we are configuring the MRU via MTU, it means that all ports within
    a bridge forwarding domain should have the same MTU.

    And that is exactly what this patch is trying to do.

    >From an implementation perspective, we try to follow the intent of the
    user, otherwise there is a risk that we might livelock them (they try to
    change the MTU on an already-bridged interface, but we just keep
    changing it back in an attempt to keep the MTU normalized). So the MTU
    that the bridge is normalized to is either:

    - The most recently changed one:

    ip link set dev swp0 master br0
    ip link set dev swp1 master br0
    ip link set dev swp0 mtu 1400

    This sequence will make swp1 inherit MTU 1400 from swp0.

    - The one of the most recently added interface to the bridge:

    ip link set dev swp0 master br0
    ip link set dev swp1 mtu 1400
    ip link set dev swp1 master br0

    The above sequence will make swp0 inherit MTU 1400 as well.

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

    Vladimir Oltean
     
  • It is useful be able to configure port policers on a switch to accept
    frames of various sizes:

    - Increase the MTU for better throughput from the default of 1500 if it
    is known that there is no 10/100 Mbps device in the network.
    - Decrease the MTU to limit the latency of high-priority frames under
    congestion, or work around various network segments that add extra
    headers to packets which can't be fragmented.

    For DSA slave ports, this is mostly a pass-through callback, called
    through the regular ndo ops and at probe time (to ensure consistency
    across all supported switches).

    The CPU port is called with an MTU equal to the largest configured MTU
    of the slave ports. The assumption is that the user might want to
    sustain a bidirectional conversation with a partner over any switch
    port.

    The DSA master is configured the same as the CPU port, plus the tagger
    overhead. Since the MTU is by definition L2 payload (sans Ethernet
    header), it is up to each individual driver to figure out if it needs to
    do anything special for its frame tags on the CPU port (it shouldn't
    except in special cases). So the MTU does not contain the tagger
    overhead on the CPU port.
    However the MTU of the DSA master, minus the tagger overhead, is used as
    a proxy for the MTU of the CPU port, which does not have a net device.
    This is to avoid uselessly calling the .change_mtu function on the CPU
    port when nothing should change.

    So it is safe to assume that the DSA master and the CPU port MTUs are
    apart by exactly the tagger's overhead in bytes.

    Some changes were made around dsa_master_set_mtu(), function which was
    now removed, for 2 reasons:
    - dev_set_mtu() already calls dev_validate_mtu(), so it's redundant to
    do the same thing in DSA
    - __dev_set_mtu() returns 0 if ops->ndo_change_mtu is an absent method
    That is to say, there's no need for this function in DSA, we can safely
    call dev_set_mtu() directly, take the rtnl lock when necessary, and just
    propagate whatever errors get reported (since the user probably wants to
    be informed).

    Some inspiration (mainly in the MTU DSA notifier) was taken from a
    vaguely similar patch from Murali and Florian, who are credited as
    co-developers down below.

    Co-developed-by: Murali Krishna Policharla
    Signed-off-by: Murali Krishna Policharla
    Co-developed-by: Florian Fainelli
    Signed-off-by: Florian Fainelli
    Signed-off-by: Vladimir Oltean
    Signed-off-by: David S. Miller

    Vladimir Oltean
     

04 Mar, 2020

1 commit

  • Place phylink_start()/phylink_stop() inside dsa_port_enable() and
    dsa_port_disable(), which ensures that we call phylink_stop() before
    tearing down phylink - which is a documented requirement. Failure
    to do so can cause use-after-free bugs.

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

    Russell King
     

09 Jan, 2020

1 commit

  • It is possible to stack multiple DSA switches in a way that they are not
    part of the tree (disjoint) but the DSA master of a switch is a DSA
    slave of another. When that happens switch drivers may have to know this
    is the case so as to determine whether their tagging protocol has a
    remove chance of working.

    This is useful for specific switch drivers such as b53 where devices
    have been known to be stacked in the wild without the Broadcom tag
    protocol supporting that feature. This allows b53 to continue supporting
    those devices by forcing the disabling of Broadcom tags on the outermost
    switches if necessary.

    The get_tag_protocol() function is therefore updated to gain an
    additional enum dsa_tag_protocol argument which denotes the current
    tagging protocol used by the DSA master we are attached to, else
    DSA_TAG_PROTO_NONE for the top of the dsa_switch_tree.

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

    Florian Fainelli
     

06 Jan, 2020

1 commit

  • There are 3 things that are wrong with the DSA deferred xmit mechanism:

    1. Its introduction has made the DSA hotpath ever so slightly more
    inefficient for everybody, since DSA_SKB_CB(skb)->deferred_xmit needs
    to be initialized to false for every transmitted frame, in order to
    figure out whether the driver requested deferral or not (a very rare
    occasion, rare even for the only driver that does use this mechanism:
    sja1105). That was necessary to avoid kfree_skb from freeing the skb.

    2. Because L2 PTP is a link-local protocol like STP, it requires
    management routes and deferred xmit with this switch. But as opposed
    to STP, the deferred work mechanism needs to schedule the packet
    rather quickly for the TX timstamp to be collected in time and sent
    to user space. But there is no provision for controlling the
    scheduling priority of this deferred xmit workqueue. Too bad this is
    a rather specific requirement for a feature that nobody else uses
    (more below).

    3. Perhaps most importantly, it makes the DSA core adhere a bit too
    much to the NXP company-wide policy "Innovate Where It Doesn't
    Matter". The sja1105 is probably the only DSA switch that requires
    some frames sent from the CPU to be routed to the slave port via an
    out-of-band configuration (register write) rather than in-band (DSA
    tag). And there are indeed very good reasons to not want to do that:
    if that out-of-band register is at the other end of a slow bus such
    as SPI, then you limit that Ethernet flow's throughput to effectively
    the throughput of the SPI bus. So hardware vendors should definitely
    not be encouraged to design this way. We do _not_ want more
    widespread use of this mechanism.

    Luckily we have a solution for each of the 3 issues:

    For 1, we can just remove that variable in the skb->cb and counteract
    the effect of kfree_skb with skb_get, much to the same effect. The
    advantage, of course, being that anybody who doesn't use deferred xmit
    doesn't need to do any extra operation in the hotpath.

    For 2, we can create a kernel thread for each port's deferred xmit work.
    If the user switch ports are named swp0, swp1, swp2, the kernel threads
    will be named swp0_xmit, swp1_xmit, swp2_xmit (there appears to be a 15
    character length limit on kernel thread names). With this, the user can
    change the scheduling priority with chrt $(pidof swp2_xmit).

    For 3, we can actually move the entire implementation to the sja1105
    driver.

    So this patch deletes the generic implementation from the DSA core and
    adds a new one, more adequate to the requirements of PTP TX
    timestamping, in sja1105_main.c.

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

    Vladimir Oltean
     

18 Dec, 2019

1 commit

  • Commit 77373d49de22 ("net: dsa: Move the phylink driver calls into
    port.c") moved and exported a bunch of symbols, but they are not used
    outside of net/dsa/port.c at the moment, so no reason to export them.

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

    Florian Fainelli
     

24 Nov, 2019

1 commit

  • Rename the mac_link_state() method to mac_pcs_get_state() to make it
    clear that it should be returning the MACs PCS current state, which
    is used for inband negotiation rather than just reading back what the
    MAC has been configured for. Update the documentation to explicitly
    mention that this is for inband.

    We drop the return value as well; most of phylink doesn't check the
    return value and it is not clear what it should do on error - instead
    arrange for state->link to be false.

    Signed-off-by: Russell King
    Signed-off-by: Jakub Kicinski

    Russell King
     

23 Oct, 2019

1 commit

  • Use the new ports list instead of iterating over switches and their
    ports when looking for a slave device from a given master interface.

    Signed-off-by: Vivien Didelot
    Reviewed-by: Florian Fainelli
    Reviewed-by: Andrew Lunn
    Signed-off-by: Jakub Kicinski

    Vivien Didelot
     

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
     

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

1 commit

  • 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

  • Some hardware needs to take work to get convinced to receive frames on
    the CPU port (such as the sja1105 which takes temporary L2 forwarding
    rules over SPI that last for a single frame). Such work needs a
    sleepable context, and because the regular .ndo_start_xmit is atomic,
    this cannot be done in the tagger. So introduce a generic DSA mechanism
    that sets up a transmit skb queue and a workqueue for deferred
    transmission.

    The new driver callback (.port_deferred_xmit) is in dsa_switch and not
    in the tagger because the operations that require sleeping typically
    also involve interacting with the hardware, and not simply skb
    manipulations. Therefore having it there simplifies the structure a bit
    and makes it unnecessary to export functions from the driver to the
    tagger.

    The driver is responsible of calling dsa_enqueue_skb which transfers it
    to the master netdevice. This is so that it has a chance of performing
    some more work afterwards, such as cleanup or TX timestamping.

    To tell DSA that skb xmit deferral is required, I have thought about
    changing the return type of the tagger .xmit from struct sk_buff * into
    a enum dsa_tx_t that could potentially encode a DSA_XMIT_DEFER value.

    But the trailer tagger is reallocating every skb on xmit and therefore
    making a valid use of the pointer return value. So instead of reworking
    the API in complicated ways, right now a boolean property in the newly
    introduced DSA_SKB_CB is set.

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

    Vladimir Oltean
     

01 May, 2019

2 commits

  • Now that all drivers can be probed using more traditional methods,
    remove the legacy probe code.

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

    Andrew Lunn
     
  • 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
     

29 Apr, 2019

3 commits

  • Now that tag drivers dynamically register, we don't need the static
    table. Remove it. This also means the tag driver structures can be
    made static.

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

    Andrew Lunn
     
  • When a DSA switch driver is unloaded, the lock on the tag driver
    should be released so the module can be unloaded. Add the needed calls,
    but leave the actual release code as a stub.

    Signed-off-by: Andrew Lunn
    Reviewed-by: Florian Fainelli

    v2

    Signed-off-by: David S. Miller

    Andrew Lunn
     
  • dsa_resolve_tag_protocol() is used to find the tagging driver needed
    by a switch driver. When the tagging drivers become modules, it will
    be necassary to take a reference on the module to prevent it being
    unloaded. So rename this function to _get() to indicate it has some
    locking properties.

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

    Andrew Lunn
     

04 Mar, 2019

1 commit

  • KSZ9893 switch is similar to KSZ9477 switch except the ingress tail tag
    has 1 byte instead of 2 bytes. The size of the portmap is smaller and
    so the override and lookup bits are also moved.

    Signed-off-by: Tristram Ha
    Reviewed-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Tristram Ha
     

25 Feb, 2019

1 commit


22 Feb, 2019

2 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
     
  • 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
     

18 Jan, 2019

1 commit

  • Drivers may not be able to support certain FDB entries, and an error
    code is insufficient to give clear hints as to the reasons of rejection.

    In order to make it possible to communicate the rejection reason, extend
    ndo_fdb_add() with an extack argument. Adapt the existing
    implementations of ndo_fdb_add() to take the parameter (and ignore it).
    Pass the extack parameter when invoking ndo_fdb_add() from rtnl_fdb_add().

    Signed-off-by: Petr Machata
    Signed-off-by: David S. Miller

    Petr Machata
     

17 Dec, 2018

1 commit

  • Rename the tag Kconfig option and related macros in preparation for
    addition of new KSZ family switches with different tag formats.

    Signed-off-by: Tristram Ha
    Signed-off-by: Marek Vasut
    Cc: Vivien Didelot
    Cc: Woojung Huh
    Cc: David S. Miller
    Reviewed-by: Andrew Lunn
    Reviewed-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Tristram Ha
     

13 Sep, 2018

1 commit

  • This handles the tag added by the PMAC on the VRX200 SoC line.

    The GSWIP uses internally a GSWIP special tag which is located after the
    Ethernet header. The PMAC which connects the GSWIP to the CPU converts
    this special tag used by the GSWIP into the PMAC special tag which is
    added in front of the Ethernet header.

    This was tested with GSWIP 2.1 found in the VRX200 SoCs, other GSWIP
    versions use slightly different PMAC special tags.

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

    Hauke Mehrtens
     

08 Sep, 2018

1 commit

  • There is no way for user-space to know what a given DSA network device's
    tagging protocol is. Expose this information through a dsa/tagging
    attribute which reflects the tagging protocol currently in use.

    This is helpful for configuration (e.g: none behaves dramatically
    different wrt. bridges) as well as for packet capture tools when there
    is not a proper Ethernet type available.

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

    Florian Fainelli
     

12 May, 2018

1 commit

  • Add support for PHYLINK within the DSA subsystem in order to support more
    complex devices such as pluggable (SFP) and non-pluggable (SFF) modules, 10G
    PHYs, and traditional PHYs. Using PHYLINK allows us to drop some amount of
    complexity we had while probing fixed and non-fixed PHYs using Device Tree.

    Because PHYLINK separates the Ethernet MAC/port configuration into different
    stages, we let switch drivers implement those, and for now, we maintain
    functionality by calling dsa_slave_adjust_link() during
    phylink_mac_link_{up,down} which provides semantically equivalent steps.

    Drivers willing to take advantage of PHYLINK should implement the phylink_mac_*
    operations that DSA wraps.

    We cannot quite remove the adjust_link() callback just yet, because a number of
    drivers rely on that for configuring their "CPU" and "DSA" ports, this is done
    dsa_port_setup_phy_of() and dsa_port_fixed_link_register_of() still.

    Drivers that utilize fixed links for user-facing ports (e.g: bcm_sf2) will need
    to implement phylink_mac_ops from now on to preserve functionality, since PHYLINK
    *does not* create a phy_device instance for fixed links.

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

    Florian Fainelli
     

08 Apr, 2018

1 commit

  • The Marvell switches under some conditions will pass a frame to the
    host with the port being the CPU port. Such frames are invalid, and
    should be dropped. Not dropping them can result in a crash when
    incrementing the receive statistics for an invalid port.

    Reported-by: Chris Healy
    Fixes: 91da11f870f0 ("net: Distributed Switch Architecture protocol support")
    Signed-off-by: Andrew Lunn
    Reviewed-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Andrew Lunn
     

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
     

03 Jan, 2018

1 commit

  • We need to make the dsa_legacy_register() stub return 0 in order for
    dsa_init_module() to successfully register and continue registering the
    ETH_P_XDSA packet handler.

    Fixes: 2a93c1a3651f ("net: dsa: Allow compiling out legacy support")
    Reported-by: Egil Hjelmeland
    Signed-off-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Florian Fainelli
     

08 Dec, 2017

1 commit

  • Introduce a configuration option: CONFIG_NET_DSA_LEGACY allowing to compile out
    support for the old platform device and Device Tree binding registration.
    Support for these configurations is scheduled to be removed in 4.17.

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

    Florian Fainelli
     

13 Nov, 2017

1 commit

  • Add a new type: DSA_TAG_PROTO_PREPEND which allows us to support for the
    4-bytes Broadcom tag that we already support, but in a format where it
    is pre-pended to the packet instead of located between the MAC SA and
    the Ethertyper (DSA_TAG_PROTO_BRCM).

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

    Florian Fainelli