20 Oct, 2020

1 commit

  • The Marvell 88E6060 uses tag_trailer.c and the KSZ8795, KSZ9477 and
    KSZ9893 switches also use tail tags.

    Fixes: 7a6ffe764be3 ("net: dsa: point out the tail taggers")
    Signed-off-by: Christian Eggers
    Reviewed-by: Florian Fainelli
    Link: https://lore.kernel.org/r/20201016171603.10587-1-ceggers@arri.de
    Signed-off-by: Jakub Kicinski

    Christian Eggers
     

14 Oct, 2020

1 commit


12 Oct, 2020

1 commit


05 Oct, 2020

4 commits

  • A driver may refuse to enable VLAN filtering for any reason beyond what
    the DSA framework cares about, such as:
    - having tc-flower rules that rely on the switch being VLAN-aware
    - the particular switch does not support VLAN, even if the driver does
    (the DSA framework just checks for the presence of the .port_vlan_add
    and .port_vlan_del pointers)
    - simply not supporting this configuration to be toggled at runtime

    Currently, when a driver rejects a configuration it cannot support, it
    does this from the commit phase, which triggers various warnings in
    switchdev.

    So propagate the prepare phase to drivers, to give them the ability to
    refuse invalid configurations cleanly and avoid the warnings.

    Since we need to modify all function prototypes and check for the
    prepare phase from within the drivers, take that opportunity and move
    the existing driver restrictions within the prepare phase where that is
    possible and easy.

    Cc: Florian Fainelli
    Cc: Martin Blumenstingl
    Cc: Hauke Mehrtens
    Cc: Woojung Huh
    Cc: Microchip Linux Driver Support
    Cc: Sean Wang
    Cc: Landen Chao
    Cc: Andrew Lunn
    Cc: Vivien Didelot
    Cc: Jonathan McDowell
    Cc: Linus Walleij
    Cc: Alexandre Belloni
    Cc: Claudiu Manoil
    Signed-off-by: Vladimir Oltean
    Signed-off-by: David S. Miller

    Vladimir Oltean
     
  • Allow DSA drivers to make use of devlink port regions, via simple
    wrappers.

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

    Andrew Lunn
     
  • DSA drivers want to create regions on devlink ports as well as the
    devlink device instance, in order to export registers and other tables
    per port. To keep all this code together in the drivers, have the
    devlink ports registered early, so the setup() method can setup both
    device and port devlink regions.

    v3:
    Remove dp->setup
    Move common code out of switch statement.
    Fix wrong goto

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

    Andrew Lunn
     
  • If a port is unused, still create a devlink port for it, but set the
    flavour to unused. This allows us to attach devlink regions to the
    port, etc.

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

    Andrew Lunn
     

03 Oct, 2020

4 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
     
  • Indicate to the DSA receive path that we need to untage the bridge PVID,
    this allows us to remove the dsa_untag_bridge_pvid() calls from
    net/dsa/tag_brcm.c.

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

    Florian Fainelli
     
  • When a DSA switch driver needs to call dsa_untag_bridge_pvid(), it can
    set dsa_switch::untag_brige_pvid to indicate this is necessary.

    This is a pre-requisite to making sure that we are always calling
    dsa_untag_bridge_pvid() after eth_type_trans() has been called.

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

    Florian Fainelli
     

27 Sep, 2020

12 commits

  • Remove the .flow_dissect procedure, so the flow dissector will call the
    generic variant which works for this tagging protocol.

    Cc: Linus Walleij
    Cc: DENG Qingfang
    Cc: Mauri Sandberg
    Signed-off-by: Vladimir Oltean
    Signed-off-by: David S. Miller

    Vladimir Oltean
     
  • The sja1105 is a bit of a special snowflake, in that not all frames are
    transmitted/received in the same way. L2 link-local frames are received
    with the source port/switch ID information put in the destination MAC
    address. For the rest, a tag_8021q header is used. So only the latter
    frames displace the rest of the headers and need to use the generic flow
    dissector procedure.

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

    Vladimir Oltean
     
  • Remove the .flow_dissect procedure, so the flow dissector will call the
    generic variant which works for this tagging protocol.

    Cc: John Crispin
    Cc: Alexander Lobakin
    Signed-off-by: Vladimir Oltean
    Signed-off-by: David S. Miller

    Vladimir Oltean
     
  • Remove the .flow_dissect procedure, so the flow dissector will call the
    generic variant which works for this tagging protocol.

    Cc: DENG Qingfang
    Cc: Sean Wang
    Cc: John Crispin
    Signed-off-by: Vladimir Oltean
    Signed-off-by: David S. Miller

    Vladimir Oltean
     
  • Remove the .flow_dissect procedure, so the flow dissector will call the
    generic variant which works for this tagging protocol.

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

    Vladimir Oltean
     
  • Remove the .flow_dissect procedure, so the flow dissector will call the
    generic variant which works for this tagging protocol.

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

    Vladimir Oltean
     
  • There are 2 Broadcom tags in use, one places the DSA tag before the
    Ethernet destination MAC address, and the other before the EtherType.
    Nonetheless, both displace the rest of the headers, so this tagger can
    use the generic flow dissector procedure which accounts for that.

    The ASCII art drawing is a good reference though, so keep it but move it
    somewhere else.

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

    Vladimir Oltean
     
  • The Marvell 88E6060 uses tag_trailer.c and the KSZ8795, KSZ9477 and
    KSZ9893 switches also use tail tags.

    Tell that to the DSA core, since this makes a difference for the flow
    dissector. Most switches break the parsing of frame headers, but these
    ones don't, so no flow dissector adjustment needs to be done for them.

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

    Vladimir Oltean
     
  • There is no tagger that returns anything other than zero, so just change
    the return type appropriately.

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

    Vladimir Oltean
     
  • There are 2 goals that we follow:

    - Reduce the header size
    - Make the header size equal between RX and TX

    The issue that required long prefix on RX was the fact that the ocelot
    DSA tag, being put before Ethernet as it is, would overlap with the area
    that a DSA master uses for RX filtering (destination MAC address
    mainly).

    Now that we can ask DSA to put the master in promiscuous mode, in theory
    we could remove the prefix altogether and call it a day, but it looks
    like we can't. Using no prefix on ingress, some packets (such as ICMP)
    would be received, while others (such as PTP) would not be received.
    This is because the DSA master we use (enetc) triggers parse errors
    ("MAC rx frame errors") presumably because it sees Ethernet frames with
    a bad length. And indeed, when using no prefix, the EtherType (bytes
    12-13 of the frame, bits 96-111) falls over the REW_VAL field from the
    extraction header, aka the PTP timestamp.

    When turning the short (32-bit) prefix on, the EtherType overlaps with
    bits 64-79 of the extraction header, which are a reserved area
    transmitted as zero by the switch. The packets are not dropped by the
    DSA master with a short prefix. Actually, the frames look like this in
    tcpdump (below is a PTP frame, with an extra dsa_8021q tag - dadb 0482 -
    added by a downstream sja1105).

    89:0c:a9:f2:01:00 > 88:80:00:0a:00:1d, 802.3, length 0: LLC, \
    dsap Unknown (0x10) Individual, ssap ProWay NM (0x0e) Response, \
    ctrl 0x0004: Information, send seq 2, rcv seq 0, \
    Flags [Response], length 78

    0x0000: 8880 000a 001d 890c a9f2 0100 0000 100f ................
    0x0010: 0400 0000 0180 c200 000e 001f 7b63 0248 ............{c.H
    0x0020: dadb 0482 88f7 1202 0036 0000 0000 0000 .........6......
    0x0030: 0000 0000 0000 0000 0000 001f 7bff fe63 ............{..c
    0x0040: 0248 0001 1f81 0500 0000 0000 0000 0000 .H..............
    0x0050: 0000 0000 0000 0000 0000 0000 ............

    So the short prefix is our new default: we've shortened our RX frames by
    12 octets, increased TX by 4, and headers are now equal between RX and
    TX. Note that we still need promiscuous mode for the DSA master to not
    drop it.

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

    Vladimir Oltean
     
  • Currently PTP is broken when ports are in standalone mode (the tagger
    keeps printing this message):

    sja1105 spi0.1: Expected meta frame, is 01-80-c2-00-00-0e in the DSA master multicast filter?

    Sure, one might say "simply add 01-80-c2-00-00-0e to the master's RX
    filter" but things become more complicated because:

    - Actually all frames in the 01-80-c2-xx-xx-xx and 01-1b-19-xx-xx-xx
    range are trapped to the CPU automatically
    - The switch mangles bytes 3 and 4 of the MAC address via the incl_srcpt
    ("include source port [in the DMAC]") option, which is how source port
    and switch id identification is done for link-local traffic on RX. But
    this means that an address installed to the RX filter would, at the
    end of the day, not correspond to the final address seen by the DSA
    master.

    Assume RX filtering lists on DSA masters are typically too small to
    include all necessary addresses for PTP to work properly on sja1105, and
    just request promiscuous mode unconditionally.

    Just an example:
    Assuming the following addresses are trapped to the CPU:
    01-80-c2-00-00-00 to 01-80-c2-00-00-ff
    01-1b-19-00-00-00 to 01-1b-19-00-00-ff

    These are 512 addresses.
    Now let's say this is a board with 3 switches, and 4 ports per switch.
    The 512 addresses become 6144 addresses that must be managed by the DSA
    master's RX filtering lists.

    This may be refined in the future, but for now, it is simply not worth
    it to add the additional addresses to the master's RX filter, so simply
    request it to become promiscuous as soon as the driver probes.

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

    Vladimir Oltean
     
  • Currently DSA assumes that taggers don't mess with the destination MAC
    address of the frames on RX. That is not always the case. Some DSA
    headers are placed before the Ethernet header (ocelot), and others
    simply mangle random bytes from the destination MAC address (sja1105
    with its incl_srcpt option).

    Currently the DSA master goes to promiscuous mode automatically when the
    slave devices go too (such as when enslaved to a bridge), but in
    standalone mode this is a problem that needs to be dealt with.

    So give drivers the possibility to signal that their tagging protocol
    will get randomly dropped otherwise, and let DSA deal with fixing that.

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

    Vladimir Oltean
     

25 Sep, 2020

1 commit

  • Currently, ocelot switchdev passes the skb directly to the function that
    enqueues it to the list of skb's awaiting a TX timestamp. Whereas the
    felix DSA driver first clones the skb, then passes the clone to this
    queue.

    This matters because in the case of felix, the common IRQ handler, which
    is ocelot_get_txtstamp(), currently clones the clone, and frees the
    original clone. This is useless and can be simplified by using
    skb_complete_tx_timestamp() instead of skb_tstamp_tx().

    Signed-off-by: Vladimir Oltean
    Acked-by: Richard Cochran
    Signed-off-by: David S. Miller

    Vladimir Oltean
     

24 Sep, 2020

2 commits

  • Update the B53 driver to support VLANs while not filtering. This
    requires us to enable VLAN globally within the switch upon driver
    initial configuration (dev->vlan_enabled).

    We also need to remove the code that dealt with PVID re-configuration in
    b53_vlan_filtering() since that function worked under the assumption
    that it would only be called to make a bridge VLAN filtering, or not
    filtering, and we would attempt to move the port's PVID accordingly.

    Now that VLANs are programmed all the time, even in the case of a
    non-VLAN filtering bridge, we would be programming a default_pvid for
    the bridged switch ports.

    We need the DSA receive path to pop the VLAN tag if it is the bridge's
    default_pvid because the CPU port is always programmed tagged in the
    programmed VLANs. In order to do so we utilize the
    dsa_untag_bridge_pvid() helper introduced in the commit before within
    net/dsa/tag_brcm.c.

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

    Florian Fainelli
     
  • 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
     

23 Sep, 2020

1 commit

  • Two minor conflicts:

    1) net/ipv4/route.c, adding a new local variable while
    moving another local variable and removing it's
    initial assignment.

    2) drivers/net/dsa/microchip/ksz9477.c, overlapping changes.
    One pretty prints the port mode differently, whilst another
    changes the driver to try and obtain the port mode from
    the port node rather than the switch node.

    Signed-off-by: David S. Miller

    David S. Miller
     

21 Sep, 2020

9 commits

  • Check whether there is any hwaccel VLAN tag on RX, and if there is,
    treat it as the tag_8021q header.

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

    Vladimir Oltean
     
  • The whole purpose of tag_8021q is to send VLAN-tagged traffic to the
    CPU, from which the driver can decode the source port and switch id.

    Currently this only works if the VLAN filtering on the master is
    disabled. Change that by explicitly adding code to tag_8021q.c to add
    the VLANs corresponding to the tags to the filter of the master
    interface.

    Because we now need to call vlan_vid_add, then we also need to hold the
    RTNL mutex. Propagate that requirement to the callers of dsa_8021q_setup
    and modify the existing call sites as appropriate. Note that one call
    path, sja1105_best_effort_vlan_filtering_set -> sja1105_vlan_filtering
    -> sja1105_setup_8021q_tagging, was already holding this lock.

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

    Vladimir Oltean
     
  • Most DSA switch tags shift the EtherType to the right, causing the
    master to not parse the VLAN as VLAN.
    However, not all switches do that (example: tail tags, tag_8021q etc),
    and if the DSA master has "rx-vlan-filter: on" in ethtool -k, then we
    have a problem.

    Therefore, we could populate the VLAN table of the master, just in case
    (for some switches it will not make a difference), so that network I/O
    can work even with a VLAN filtering master.

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

    Vladimir Oltean
     
  • When the bridge has VLAN awareness disabled there isn't any duplication
    of functionality, since the bridge does not process VLAN. Don't deny
    adding 8021q uppers to DSA switch ports in that case. The switch is
    supposed to simply pass traffic leaving the VLAN tag as-is, and the
    stack will happily strip the VLAN tag for all 8021q uppers that exist.

    We need to ensure that there are no 8021q uppers when the user attempts
    to enable bridge vlan_filtering.

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

    Vladimir Oltean
     
  • The current logic beats me a little bit. The comment that "bridge skips
    -EOPNOTSUPP, so skip the prepare phase" was introduced in commit
    fb2dabad69f0 ("net: dsa: support VLAN filtering switchdev attr").

    I'm not sure:
    (a) ok, the bridge skips -EOPNOTSUPP, but, so what, where are we
    returning -EOPNOTSUPP?
    (b) even if we are, and I'm just not seeing it, what is the causality
    relationship between the bridge skipping -EOPNOTSUPP and DSA
    skipping the prepare phase, and just returning zero?

    One thing is certain beyond doubt though, and that is that DSA currently
    refuses VLAN filtering from the "commit" phase instead of "prepare", and
    that this is not a good thing:

    ip link add br0 type bridge
    ip link add br1 type bridge vlan_filtering 1
    ip link set swp2 master br0
    ip link set swp3 master br1
    [ 3790.379389] 001: sja1105 spi0.1: VLAN filtering is a global setting
    [ 3790.379399] 001: ------------[ cut here ]------------
    [ 3790.379403] 001: WARNING: CPU: 1 PID: 515 at net/switchdev/switchdev.c:157 switchdev_port_attr_set_now+0x9c/0xa4
    [ 3790.379420] 001: swp3: Commit of attribute (id=6) failed.
    [ 3790.379533] 001: [] (switchdev_port_attr_set_now) from [] (nbp_vlan_init+0x84/0x148)
    [ 3790.379544] 001: [] (nbp_vlan_init) from [] (br_add_if+0x514/0x670)
    [ 3790.379554] 001: [] (br_add_if) from [] (do_setlink+0x38c/0xab0)
    [ 3790.379565] 001: [] (do_setlink) from [] (__rtnl_newlink+0x44c/0x748)
    [ 3790.379573] 001: [] (__rtnl_newlink) from [] (rtnl_newlink+0x44/0x60)
    [ 3790.379580] 001: [] (rtnl_newlink) from [] (rtnetlink_rcv_msg+0x124/0x2f8)
    [ 3790.379590] 001: [] (rtnetlink_rcv_msg) from [] (netlink_rcv_skb+0xb8/0x110)
    [ 3790.379806] 001: ---[ end trace 0000000000000002 ]---
    [ 3790.379819] 001: sja1105 spi0.1 swp3: failed to initialize vlan filtering on this port

    So move the current logic that may fail (except ds->ops->port_vlan_filtering,
    that is way harder) into the prepare stage of the switchdev transaction.

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

    Vladimir Oltean
     
  • This is checking for the following order of operations, and makes sure
    to deny that configuration:

    ip link add link swp2 name swp2.100 type vlan id 100
    ip link add br0 type bridge vlan_filtering 1
    ip link set swp2 master br0
    bridge vlan add dev swp2 vid 100

    Instead of using vlan_for_each(), which looks at the VLAN filters
    installed with vlan_vid_add(), just track the 8021q uppers. This has the
    advantage of freeing up the vlan_vid_add() call for actual VLAN
    filtering.

    There is another change in this patch. The check is moved in slave.c,
    from switch.c. I don't think it makes sense to have this 8021q upper
    check for each switch port that gets notified of that VLAN addition
    (these include DSA links and CPU ports, we know those can't have 8021q
    uppers because they don't have a net_device registered for them), so
    just do it in slave.c, for that one slave interface.

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

    Vladimir Oltean
     
  • DSA tries to prevent having a VLAN added by a bridge and by an 802.1Q
    upper at the same time. It does that by checking the VID in
    .ndo_vlan_rx_add_vid(), since that's something that the 8021q module
    calls, via vlan_vid_add(). When a VLAN matches in both subsystems, this
    check returns -EBUSY.

    However the vlan_vid_add() function isn't specific to the 8021q module
    in any way at all. It is simply the kernel's way to tell an interface to
    add a VLAN to its RX filter and not drop that VLAN. So there's no reason
    to return -EBUSY when somebody tries to call vlan_vid_add() for a VLAN
    that was installed by the bridge. The proper behavior is to accept that
    configuration.

    So what's wrong is how DSA checks that it has an 8021q upper. It should
    look at the actual uppers for that, not just assume that the 8021q
    module was somewhere in the call stack of .ndo_vlan_rx_add_vid().

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

    Vladimir Oltean
     
  • We'll be adding a new check in the PRECHANGEUPPER notifier, where we'll
    need to check some VLAN uppers. It is hard to do that when there is
    already a function named dsa_slave_upper_vlan_check. So rename this one.

    Not to mention that this function probably shouldn't have started with
    "dsa_slave_" in the first place, since the struct net_device argument
    isn't a DSA slave, but an 8021q upper of one.

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

    Vladimir Oltean
     
  • There doesn't seem to be any strong technical reason for doing it this
    way, but we'll be adding more checks for invalid upper device
    configurations, and it will be easier to have them all grouped under
    PRECHANGEUPPER.

    Tested that it still works:
    ip link set br0 type bridge vlan_filtering 1
    ip link add link swp2 name swp2.100 type vlan id 100
    ip link set swp2.100 master br0
    [ 20.321312] br0: port 5(swp2.100) entered blocking state
    [ 20.326711] br0: port 5(swp2.100) entered disabled state
    Error: dsa_core: Cannot enslave VLAN device into VLAN aware bridge.
    [ 20.346549] br0: port 5(swp2.100) entered blocking state
    [ 20.351957] br0: port 5(swp2.100) entered disabled state

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

    Vladimir Oltean
     

19 Sep, 2020

4 commits

  • Allow the DSA drivers to implement the devlink call to get info info,
    e.g. driver name, firmware version, ASIC ID, etc.

    v2:
    Combine declaration and the assignment on a single line.

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

    Andrew Lunn
     
  • Allow DSA drivers to make use of devlink regions, via simple wrappers.

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

    Andrew Lunn
     
  • Given a devlink instance, return the dsa switch it is associated to.

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

    Andrew Lunn
     
  • The ocelot_port->ts_id is used to:
    (a) populate skb->cb[0] for matching the TX timestamp in the PTP IRQ
    with an skb.
    (b) populate the REW_OP from the injection header of the ongoing skb.
    Only then is ocelot_port->ts_id incremented.

    This is a problem because, at least theoretically, another timestampable
    skb might use the same ocelot_port->ts_id before that is incremented.
    Normally all transmit calls are serialized by the netdev transmit
    spinlock, but in this case, ocelot_port_add_txtstamp_skb() is also
    called by DSA, which has started declaring the NETIF_F_LLTX feature
    since commit 2b86cb829976 ("net: dsa: declare lockless TX feature for
    slave ports"). So the logic of using and incrementing the timestamp id
    should be atomic per port.

    The solution is to use the global ocelot_port->ts_id only while
    protected by the associated ocelot_port->ts_id_lock. That's where we
    populate skb->cb[0]. Note that for ocelot, ocelot_port_add_txtstamp_skb
    is called for the actual skb, but for felix, it is called for the skb's
    clone. That is something which will also be changed in the future.

    Signed-off-by: Vladimir Oltean
    Reviewed-by: Horatiu Vultur
    Reviewed-by: Florian Fainelli
    Tested-by: Alexandre Belloni
    Reviewed-by: Alexandre Belloni
    Signed-off-by: David S. Miller

    Vladimir Oltean