05 Oct, 2020

1 commit


03 Oct, 2020

1 commit

  • 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
     

19 Sep, 2020

2 commits


08 May, 2020

1 commit

  • As its implementation shows, this is synonimous with calling
    dsa_slave_dev_check followed by dsa_slave_to_port, so it is quite simple
    already and provides functionality which is already there.

    However there is now a need for these functions outside dsa_priv.h, for
    example in drivers that perform mirroring and redirection through
    tc-flower offloads (they are given raw access to the flow_cls_offload
    structure), where they need to call this function on act->dev.

    But simply exporting dsa_slave_to_port would make it non-inline and
    would result in an extra function call in the hotpath, as can be seen
    for example in sja1105:

    Before:

    000006dc :
    {
    6dc: e92d4ff0 push {r4, r5, r6, r7, r8, r9, sl, fp, lr}
    6e0: e1a04000 mov r4, r0
    6e4: e591958c ldr r9, [r1, #1420] ; 0x58c ds, dp->index);
    6f0: e1c901d8 ldrd r0, [r9, #24]
    6f4: ebfffffe bl 0
    6f4: R_ARM_CALL dsa_8021q_tx_vid
    u8 pcp = netdev_txq_to_tc(netdev, queue_mapping);
    6f8: e1d416b0 ldrh r1, [r4, #96] ; 0x60
    u16 tx_vid = dsa_8021q_tx_vid(dp->ds, dp->index);
    6fc: e1a08000 mov r8, r0

    After:

    000006e4 :
    {
    6e4: e92d4ff0 push {r4, r5, r6, r7, r8, r9, sl, fp, lr}
    6e8: e1a04000 mov r4, r0
    6ec: e24dd004 sub sp, sp, #4
    struct dsa_port *dp = dsa_slave_to_port(netdev);
    6f0: e1a00001 mov r0, r1
    {
    6f4: e1a05001 mov r5, r1
    struct dsa_port *dp = dsa_slave_to_port(netdev);
    6f8: ebfffffe bl 0
    6f8: R_ARM_CALL dsa_slave_to_port
    6fc: e1a09000 mov r9, r0
    u16 tx_vid = dsa_8021q_tx_vid(dp->ds, dp->index);
    700: e1c001d8 ldrd r0, [r0, #24]
    704: ebfffffe bl 0
    704: R_ARM_CALL dsa_8021q_tx_vid

    Because we want to avoid possible performance regressions, introduce
    this new function which is designed to be public.

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

    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
     

31 Mar, 2020

1 commit

  • There is no point in preparing the module name in a buffer. The format
    string can be passed diectly to 'request_module()'.

    This axes a few lines of code and cleans a few things:
    - max len for a driver name is MODULE_NAME_LEN wich is ~ 60 chars,
    not 128. It would be down-sized in 'request_module()'
    - we should pass the total size of the buffer to 'snprintf()', not the
    size minus 1

    Signed-off-by: Christophe JAILLET
    Reviewed-by: Andrew Lunn
    Signed-off-by: David S. Miller

    Christophe JAILLET
     

06 Nov, 2019

1 commit


29 Oct, 2019

1 commit

  • Add plumbing to allow DSA drivers to register parameters with devlink.

    To keep with the abstraction, the DSA drivers pass the ds structure to
    these helpers, and the DSA core then translates that to the devlink
    structure associated to the device.

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

    Andrew Lunn
     

23 Oct, 2019

1 commit

  • Do not let the drivers access the ds->ports static array directly
    while there is a dsa_to_port helper for this purpose.

    At the same time, un-const this helper since the SJA1105 driver
    assigns the priv member of the returned dsa_port structure.

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

    Vivien Didelot
     

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
     

08 May, 2019

2 commits

  • Minor conflict with the DSA legacy code removal.

    Signed-off-by: David S. Miller

    David S. Miller
     
  • BUG: unable to handle kernel paging request at ffffffffa01c5430
    PGD 3270067 P4D 3270067 PUD 3271063 PMD 230bc5067 PTE 0
    Oops: 0000 [#1
    CPU: 0 PID: 6159 Comm: modprobe Not tainted 5.1.0+ #33
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.3-0-ge2fc41e-prebuilt.qemu-project.org 04/01/2014
    RIP: 0010:raw_notifier_chain_register+0x16/0x40
    Code: 63 f8 66 90 e9 5d ff ff ff 90 90 90 90 90 90 90 90 90 90 90 55 48 8b 07 48 89 e5 48 85 c0 74 1c 8b 56 10 3b 50 10 7e 07 eb 12 50 10 7c 0d 48 8d 78 08 48 8b 40 08 48 85 c0 75 ee 48 89 46 08
    RSP: 0018:ffffc90001c33c08 EFLAGS: 00010282
    RAX: ffffffffa01c5420 RBX: ffffffffa01db420 RCX: 4fcef45928070a8b
    RDX: 0000000000000000 RSI: ffffffffa01db420 RDI: ffffffffa01b0068
    RBP: ffffc90001c33c08 R08: 000000003e0a33d0 R09: 0000000000000000
    R10: 0000000000000000 R11: 0000000094443661 R12: ffff88822c320700
    R13: ffff88823109be80 R14: 0000000000000000 R15: ffffc90001c33e78
    FS: 00007fab8bd08540(0000) GS:ffff888237a00000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: ffffffffa01c5430 CR3: 00000002297ea000 CR4: 00000000000006f0
    Call Trace:
    register_netdevice_notifier+0x43/0x250
    ? 0xffffffffa01e0000
    dsa_slave_register_notifier+0x13/0x70 [dsa_core
    ? 0xffffffffa01e0000
    dsa_init_module+0x2e/0x1000 [dsa_core
    do_one_initcall+0x6c/0x3cc
    ? do_init_module+0x22/0x1f1
    ? rcu_read_lock_sched_held+0x97/0xb0
    ? kmem_cache_alloc_trace+0x325/0x3b0
    do_init_module+0x5b/0x1f1
    load_module+0x1db1/0x2690
    ? m_show+0x1d0/0x1d0
    __do_sys_finit_module+0xc5/0xd0
    __x64_sys_finit_module+0x15/0x20
    do_syscall_64+0x6b/0x1d0
    entry_SYSCALL_64_after_hwframe+0x49/0xbe

    Cleanup allocated resourses if there are errors,
    otherwise it will trgger memleak.

    Fixes: c9eb3e0f8701 ("net: dsa: Add support for learning FDB through notification")
    Signed-off-by: YueHaibing
    Reviewed-by: Vivien Didelot
    Reviewed-by: Andrew Lunn
    Signed-off-by: David S. Miller

    YueHaibing
     

01 May, 2019

1 commit


29 Apr, 2019

9 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
     
  • Implement the _get and _put functions to make use of the list of tag
    drivers. Also, trigger the loading of the module, based on the alias
    information. The _get function takes a reference on the tag driver, so
    it cannot be unloaded, and the _put function releases the reference.

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

    v2:
    Make tag_driver_register void

    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
     
  • The none tagger is special in that it does not live in a tag_*.c file,
    but is within the core. Register/unregister when DSA is
    loaded/unloaded.

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

    Andrew Lunn
     
  • Let the tag drivers register themselves with the DSA core, keeping
    them in a linked list.

    Signed-off-by: Andrew Lunn

    v2

    Signed-off-by: David S. Miller

    Andrew Lunn
     
  • A DSA tag driver module will need to register the tag protocols it
    implements with the DSA core. Add macros containing this boiler plate.

    The registration/unregistration code is currently just a stub. A Later
    patch will add the real implementation.

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

    v2
    Fix indent of #endif
    Rewrite to move list pointer into a new structure
    v3
    Move kdoc next to macro
    Fix THIS_MODULE indentation

    Signed-off-by: David S. Miller

    Andrew Lunn
     
  • In order that we can match the tagging protocol a switch driver
    request to the tagger, we need to know what protocol the tagger
    supports. Add this information to the ops structure.

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

    v2
    More tag protocol to end of structure to keep hot members at the beginning.

    Signed-off-by: David S. Miller

    Andrew Lunn
     
  • Rather than keep a list to map a tagger ops to a name, place the name
    into the ops structure. This removes the hard coded list, a step
    towards making the taggers more dynamic.

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

    v2:
    Move name to end of structure, keeping the hot entries at the beginning.

    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
     

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
     

17 Sep, 2018

1 commit


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
     

28 Aug, 2018

1 commit

  • Commit 52638f71fcff ("dsa: Move gpio reset into switch driver")
    moved the GPIO handling into the switch drivers but forgot
    to remove the GPIO header includes.

    Signed-off-by: Linus Walleij
    Reviewed-by: Andrew Lunn
    Signed-off-by: David S. Miller

    Linus Walleij
     

15 Feb, 2018

1 commit

  • Forward the rx/tx timestamp machinery from the dsa infrastructure to the
    switch driver.

    On the rx side, defer delivery of skbs until we have an rx timestamp.
    This mimicks the behavior of skb_defer_rx_timestamp.

    On the tx side, identify PTP packets, clone them, and pass them to the
    underlying switch driver before we transmit. This mimicks the behavior
    of skb_tx_timestamp.

    Adjusted txstamp API to keep the allocation and freeing of the clone
    in the same central function by Richard Cochran

    Signed-off-by: Brandon Streiff
    Signed-off-by: Richard Cochran
    Signed-off-by: Andrew Lunn
    Signed-off-by: David S. Miller

    Brandon Streiff
     

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
     

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
     

27 Oct, 2017

1 commit


18 Oct, 2017

1 commit

  • The dsa_port structure has a "netdev" member, which can be used for
    either the master device, or the slave device, depending on its type.

    It is true that today, CPU port are not exposed to userspace, thus the
    port's netdev member can be used to point to its master interface.

    But it is still slightly confusing, so split it into more explicit
    "master" and "slave" members inside an anonymous union.

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

    Vivien Didelot
     

13 Oct, 2017

1 commit

  • In preparation for communicating a given DSA network device's port
    number and switch index, create a specialized DSA notifier and two
    events: DSA_PORT_REGISTER and DSA_PORT_UNREGISTER that communicate: the
    slave network device (slave_dev), port number and switch number in the
    tree.

    This will be later used for network device drivers like bcmsysport which
    needs to cooperate with its DSA network devices to set-up queue mapping
    and scheduling.

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

    Florian Fainelli
     

01 Oct, 2017

1 commit

  • With DSA, a master net device (CPU facing interface) has a dsa_ptr
    pointer to which hangs a dsa_switch_tree. This is not correct because a
    master interface is wired to a dedicated switch port, and because we can
    theoretically have several master interfaces pointing to several CPU
    ports of the same switch fabric.

    Change the master interface's dsa_ptr for the CPU dsa_port pointer.
    This is a step towards supporting multiple CPU ports.

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

    Vivien Didelot
     

20 Sep, 2017

2 commits

  • DSA overrides the master device ethtool ops, so that it can inject stats
    from its dedicated switch CPU port as well.

    The related code is currently split in dsa.c and slave.c, but it only
    scopes the master net device. Move it to a new master.c DSA core file.

    This file will be later extented with master net device specific code.

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

    Vivien Didelot
     
  • There is no need to store a copy of the master ethtool ops, storing the
    original pointer in DSA and the new one in the master netdev itself is
    enough.

    In the meantime, set orig_ethtool_ops to NULL when restoring the master
    ethtool ops and check the presence of the master original ethtool ops as
    well as its needed functions before calling them.

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

    Vivien Didelot
     

22 Aug, 2017

1 commit


08 Aug, 2017

1 commit

  • Add support for learning FDB through notification. The driver defers
    the hardware update via ordered work queue. In case of a successful
    FDB add a notification is sent back to bridge.

    In case of hw FDB del failure the static FDB will be deleted from
    the bridge, thus, the interface is moved to down state in order to
    indicate inconsistent situation.

    Signed-off-by: Arkadi Sharshevsky
    Reviewed-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Arkadi Sharshevsky