08 Mar, 2020

1 commit

  • Merge Linux stable release v5.4.24 into imx_5.4.y

    * tag 'v5.4.24': (3306 commits)
    Linux 5.4.24
    blktrace: Protect q->blk_trace with RCU
    kvm: nVMX: VMWRITE checks unsupported field before read-only field
    ...

    Signed-off-by: Jason Liu

    Conflicts:
    arch/arm/boot/dts/imx6sll-evk.dts
    arch/arm/boot/dts/imx7ulp.dtsi
    arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi
    drivers/clk/imx/clk-composite-8m.c
    drivers/gpio/gpio-mxc.c
    drivers/irqchip/Kconfig
    drivers/mmc/host/sdhci-of-esdhc.c
    drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
    drivers/net/can/flexcan.c
    drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
    drivers/net/ethernet/mscc/ocelot.c
    drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
    drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
    drivers/net/phy/realtek.c
    drivers/pci/controller/mobiveil/pcie-mobiveil-host.c
    drivers/perf/fsl_imx8_ddr_perf.c
    drivers/tee/optee/shm_pool.c
    drivers/usb/cdns3/gadget.c
    kernel/sched/cpufreq.c
    net/core/xdp.c
    sound/soc/fsl/fsl_esai.c
    sound/soc/fsl/fsl_sai.c
    sound/soc/sof/core.c
    sound/soc/sof/imx/Kconfig
    sound/soc/sof/loader.c

    Jason Liu
     

26 Feb, 2020

1 commit

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

    Signed-off-by: Vladimir Oltean

    Conflicts:
    include/net/dsa.h

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

    (cherry picked from commit 222d888331f409755fc25b1933e5dee1a976b9c1)

    Vladimir Oltean
     

24 Feb, 2020

1 commit

  • [ Upstream commit 04fb91243a853dbde216d829c79d9632e52aa8d9 ]

    Passing tag size to skb_cow_head will make sure
    there is enough headroom for the tag data.
    This change does not introduce any overhead in case there
    is already available headroom for tag.

    Signed-off-by: Per Forlin
    Reviewed-by: Florian Fainelli
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Per Forlin
     

23 Jan, 2020

2 commits

  • [ Upstream commit ad32205470919c8e04cdd33e0613bdba50c2376d ]

    The correct name is GSWIP (Gigabit Switch IP). Typo was introduced in
    875138f81d71a ("dsa: Move tagger name into its ops structure") while
    moving tagger names to their structures.

    Fixes: 875138f81d71a ("dsa: Move tagger name into its ops structure")
    Reviewed-by: Andrew Lunn
    Signed-off-by: Alexander Lobakin
    Reviewed-by: Florian Fainelli
    Acked-by: Hauke Mehrtens
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Alexander Lobakin
     
  • [ Upstream commit bd5874da57edd001b35cf28ae737779498c16a56 ]

    DSA subsystem takes care of netdev statistics since commit 4ed70ce9f01c
    ("net: dsa: Refactor transmit path to eliminate duplication"), so
    any accounting inside tagger callbacks is redundant and can lead to
    messing up the stats.
    This bug is present in Qualcomm tagger since day 0.

    Fixes: cafdc45c949b ("net-next: dsa: add Qualcomm tag RX/TX handler")
    Reviewed-by: Andrew Lunn
    Signed-off-by: Alexander Lobakin
    Reviewed-by: Florian Fainelli
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Alexander Lobakin
     

02 Dec, 2019

3 commits

  • Support tsn capabilities in DSA felix switch driver. This felix tsn
    driver is using tsn configuration of ocelot, and registered on each
    switch port through DSA port setup.

    Signed-off-by: Xiaoliang Yang

    Xiaoliang Yang
     
  • This patch is to reuse ocelot functions as possible to enable PTP
    clock and to support hardware timestamping on Felix.
    On TX path, timestamping works on packet which requires timestamp.
    The injection header will be configured accordingly, and skb clone
    requires timestamp will be added into a list. The TX timestamp
    is final handled in threaded interrupt handler when PTP timestamp
    FIFO is ready.
    On RX path, timestamping is always working. The RX timestamp could
    be got from extraction header.

    Signed-off-by: Yangbo Lu
    Signed-off-by: David S. Miller

    Yangbo Lu
     
  • While it is entirely possible that this tagger format is in fact more
    generic than just these 2 switch families, I don't have that knowledge.
    The Seville switch in NXP T1040 has a similar frame format, but there
    are enough differences (e.g. DEST field starts at bit 57 instead of 56)
    that calling this file tag_vitesse.c is a bit of a stretch at the
    moment. The frame format has been listed in a comment so that people who
    add support for further Vitesse switches can rework this tagger while
    keeping compatibility with Felix.

    The "ocelot" name was chosen instead of "felix" because even the Ocelot
    switch can act as a DSA device when it is used in NPI mode, and the Felix
    tagger format is almost identical. Currently it is only used for the
    Felix switch embedded in the NXP LS1028A chip.

    The ABI for this tagger should be considered "not stable" at the moment.
    The DSA tag is always placed before the Ethernet header and therefore,
    we are using the long prefix for RX tags to avoid putting the DSA master
    port in promiscuous mode. Once there will be an API in DSA for drivers
    to request DSA masters to be in promiscuous mode unconditionally, we
    will switch to the "no prefix" extraction frame header, which will save
    16 padding bytes for each RX frame.

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

    Vladimir Oltean
     

17 Nov, 2019

1 commit

  • This sequence of operations:
    ip link set dev br0 type bridge vlan_filtering 1
    bridge vlan del dev swp2 vid 1
    ip link set dev br0 type bridge vlan_filtering 1
    ip link set dev br0 type bridge vlan_filtering 0

    apparently fails with the message:

    [ 31.305716] sja1105 spi0.1: Reset switch and programmed static config. Reason: VLAN filtering
    [ 31.322161] sja1105 spi0.1: Couldn't determine PVID attributes (pvid 0)
    [ 31.328939] sja1105 spi0.1: Failed to setup VLAN tagging for port 1: -2
    [ 31.335599] ------------[ cut here ]------------
    [ 31.340215] WARNING: CPU: 1 PID: 194 at net/switchdev/switchdev.c:157 switchdev_port_attr_set_now+0x9c/0xa4
    [ 31.349981] br0: Commit of attribute (id=6) failed.
    [ 31.354890] Modules linked in:
    [ 31.357942] CPU: 1 PID: 194 Comm: ip Not tainted 5.4.0-rc6-01792-gf4f632e07665-dirty #2062
    [ 31.366167] Hardware name: Freescale LS1021A
    [ 31.370437] [] (unwind_backtrace) from [] (show_stack+0x10/0x14)
    [ 31.378153] [] (show_stack) from [] (dump_stack+0xe0/0x10c)
    [ 31.385437] [] (dump_stack) from [] (__warn+0xf4/0x10c)
    [ 31.392373] [] (__warn) from [] (warn_slowpath_fmt+0x74/0xb8)
    [ 31.399827] [] (warn_slowpath_fmt) from [] (switchdev_port_attr_set_now+0x9c/0xa4)
    [ 31.409097] [] (switchdev_port_attr_set_now) from [] (__br_vlan_filter_toggle+0x6c/0x118)
    [ 31.418971] [] (__br_vlan_filter_toggle) from [] (br_changelink+0xf8/0x518)
    [ 31.427637] [] (br_changelink) from [] (__rtnl_newlink+0x3f4/0x76c)
    [ 31.435613] [] (__rtnl_newlink) from [] (rtnl_newlink+0x44/0x60)
    [ 31.443329] [] (rtnl_newlink) from [] (rtnetlink_rcv_msg+0x2cc/0x51c)
    [ 31.451477] [] (rtnetlink_rcv_msg) from [] (netlink_rcv_skb+0xb8/0x110)
    [ 31.459796] [] (netlink_rcv_skb) from [] (netlink_unicast+0x17c/0x1f8)
    [ 31.468026] [] (netlink_unicast) from [] (netlink_sendmsg+0x2bc/0x3b4)
    [ 31.476261] [] (netlink_sendmsg) from [] (___sys_sendmsg+0x230/0x250)
    [ 31.484408] [] (___sys_sendmsg) from [] (__sys_sendmsg+0x50/0x8c)
    [ 31.492209] [] (__sys_sendmsg) from [] (ret_fast_syscall+0x0/0x28)
    [ 31.500090] Exception stack(0xedf47fa8 to 0xedf47ff0)
    [ 31.505122] 7fa0: 00000002 b6f2e060 00000003 beabd6a4 00000000 00000000
    [ 31.513265] 7fc0: 00000002 b6f2e060 5d6e3213 00000128 00000000 00000001 00000006 000619c4
    [ 31.521405] 7fe0: 00086078 beabd658 0005edbc b6e7ce68

    The reason is the implementation of br_get_pvid:

    static inline u16 br_get_pvid(const struct net_bridge_vlan_group *vg)
    {
    if (!vg)
    return 0;

    smp_rmb();
    return vg->pvid;
    }

    Since VID 0 is an invalid pvid from the bridge's point of view, let's
    add this check in dsa_8021q_restore_pvid to avoid restoring a pvid that
    doesn't really exist.

    Fixes: 5f33183b7fdf ("net: dsa: tag_8021q: Restore bridge VLANs when enabling vlan_filtering")
    Signed-off-by: Vladimir Oltean
    Reviewed-by: Andrew Lunn
    Signed-off-by: David S. Miller

    Vladimir Oltean
     

25 Oct, 2019

1 commit

  • Some interface types could be nested.
    (VLAN, BONDING, TEAM, MACSEC, MACVLAN, IPVLAN, VIRT_WIFI, VXLAN, etc..)
    These interface types should set lockdep class because, without lockdep
    class key, lockdep always warn about unexisting circular locking.

    In the current code, these interfaces have their own lockdep class keys and
    these manage itself. So that there are so many duplicate code around the
    /driver/net and /net/.
    This patch adds new generic lockdep keys and some helper functions for it.

    This patch does below changes.
    a) Add lockdep class keys in struct net_device
    - qdisc_running, xmit, addr_list, qdisc_busylock
    - these keys are used as dynamic lockdep key.
    b) When net_device is being allocated, lockdep keys are registered.
    - alloc_netdev_mqs()
    c) When net_device is being free'd llockdep keys are unregistered.
    - free_netdev()
    d) Add generic lockdep key helper function
    - netdev_register_lockdep_key()
    - netdev_unregister_lockdep_key()
    - netdev_update_lockdep_key()
    e) Remove unnecessary generic lockdep macro and functions
    f) Remove unnecessary lockdep code of each interfaces.

    After this patch, each interface modules don't need to maintain
    their lockdep keys.

    Signed-off-by: Taehee Yoo
    Signed-off-by: David S. Miller

    Taehee Yoo
     

20 Oct, 2019

1 commit

  • If there are multiple switch trees on the device, only the last one
    will be listed, because the arguments of list_add_tail are swapped.

    Fixes: 83c0afaec7b7 ("net: dsa: Add new binding implementation")
    Signed-off-by: Vivien Didelot
    Reviewed-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Vivien Didelot
     

03 Oct, 2019

1 commit

  • Currently this stack trace can be seen with CONFIG_DEBUG_ATOMIC_SLEEP=y:

    [ 41.568348] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:909
    [ 41.576757] in_atomic(): 1, irqs_disabled(): 0, pid: 208, name: ptp4l
    [ 41.583212] INFO: lockdep is turned off.
    [ 41.587123] CPU: 1 PID: 208 Comm: ptp4l Not tainted 5.3.0-rc6-01445-ge950f2d4bc7f-dirty #1827
    [ 41.599873] [] (unwind_backtrace) from [] (show_stack+0x10/0x14)
    [ 41.607584] [] (show_stack) from [] (dump_stack+0xd4/0x100)
    [ 41.614863] [] (dump_stack) from [] (___might_sleep+0x1c8/0x2b4)
    [ 41.622574] [] (___might_sleep) from [] (__mutex_lock+0x48/0xab8)
    [ 41.630368] [] (__mutex_lock) from [] (mutex_lock_nested+0x1c/0x24)
    [ 41.638340] [] (mutex_lock_nested) from [] (sja1105_static_config_reload+0x30/0x27c)
    [ 41.647779] [] (sja1105_static_config_reload) from [] (sja1105_hwtstamp_set+0x108/0x1cc)
    [ 41.657562] [] (sja1105_hwtstamp_set) from [] (dev_ifsioc+0x18c/0x330)
    [ 41.665788] [] (dev_ifsioc) from [] (dev_ioctl+0x320/0x6e8)
    [ 41.673064] [] (dev_ioctl) from [] (sock_ioctl+0x334/0x5e8)
    [ 41.680340] [] (sock_ioctl) from [] (do_vfs_ioctl+0xb0/0xa10)
    [ 41.687789] [] (do_vfs_ioctl) from [] (ksys_ioctl+0x34/0x58)
    [ 41.695151] [] (ksys_ioctl) from [] (ret_fast_syscall+0x0/0x28)
    [ 41.702768] Exception stack(0xe8495fa8 to 0xe8495ff0)
    [ 41.707796] 5fa0: beff4a8c 00000001 00000011 000089b0 beff4a8c beff4a80
    [ 41.715933] 5fc0: beff4a8c 00000001 0000000c 00000036 b6fa98c8 004e19c1 00000001 00000000
    [ 41.724069] 5fe0: 004dcedc beff4a6c 004c0738 b6e7af4c
    [ 41.729860] BUG: scheduling while atomic: ptp4l/208/0x00000002
    [ 41.735682] INFO: lockdep is turned off.

    Enabling RX timestamping will logically disturb the fastpath (processing
    of meta frames). Replace bool hwts_rx_en with a bit that is checked
    atomically from the fastpath and temporarily unset from the sleepable
    context during a change of the RX timestamping process (a destructive
    operation anyways, requires switch reset).
    If found unset, the fastpath (net/dsa/tag_sja1105.c) will just drop any
    received meta frame and not take the meta_lock at all.

    Fixes: a602afd200f5 ("net: dsa: sja1105: Expose PTP timestamping ioctls to userspace")
    Signed-off-by: Vladimir Oltean
    Signed-off-by: David S. Miller

    Vladimir Oltean
     

18 Sep, 2019

1 commit


17 Sep, 2019

2 commits

  • This is a preparation patch for the tc-taprio offload (and potentially
    for other future offloads such as tc-mqprio).

    Instead of looking directly at skb->priority during xmit, let's get the
    netdev queue and the queue-to-traffic-class mapping, and put the
    resulting traffic class into the dsa_8021q PCP field. The switch is
    configured with a 1-to-1 PCP-to-ingress-queue-to-egress-queue mapping
    (see vlan_pmap in sja1105_main.c), so the effect is that we can inject
    into a front-panel's egress traffic class through VLAN tagging from
    Linux, completely transparently.

    Unfortunately the switch doesn't look at the VLAN PCP in the case of
    management traffic to/from the CPU (link-local frames at
    01-80-C2-xx-xx-xx or 01-1B-19-xx-xx-xx) so we can't alter the
    transmission queue of this type of traffic on a frame-by-frame basis. It
    is only selected through the "hostprio" setting which ATM is harcoded in
    the driver to 7.

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

    Vladimir Oltean
     
  • DSA currently handles shared block filters (for the classifier-action
    qdisc) in the core due to what I believe are simply pragmatic reasons -
    hiding the complexity from drivers and offerring a simple API for port
    mirroring.

    Extend the dsa_slave_setup_tc function by passing all other qdisc
    offloads to the driver layer, where the driver may choose what it
    implements and how. DSA is simply a pass-through in this case.

    Signed-off-by: Vladimir Oltean
    Acked-by: Kurt Kanzenbach
    Reviewed-by: Florian Fainelli
    Acked-by: Ilias Apalodimas
    Signed-off-by: David S. Miller

    Vladimir Oltean
     

16 Sep, 2019

1 commit

  • The DSA core, DSA taggers and DSA drivers all make use of
    module_init(). Hence they get initialised at device_initcall() time.
    The ordering is non-deterministic. It can be a DSA driver is bound to
    a device before the needed tag driver has been initialised, resulting
    in the message:

    No tagger for this switch

    Rather than have this be fatal, return -EPROBE_DEFER so that it is
    tried again later once all the needed drivers have been loaded.

    Fixes: d3b8c04988ca ("dsa: Add boilerplate helper to register DSA tag driver modules")
    Signed-off-by: Andrew Lunn
    Signed-off-by: David S. Miller

    Andrew Lunn
     

12 Sep, 2019

1 commit

  • Remove the superfluous NET_DSA_TAG_KSZ_COMMON and just use the existing
    NET_DSA_TAG_KSZ. Update the description to mention the three switch
    families it supports. No functional change.

    Signed-off-by: George McCollister
    Reviewed-by: Marek Vasut
    Reviewed-by: Florian Fainelli
    Reviewed-by: Andrew Lunn
    Signed-off-by: David S. Miller

    George McCollister
     

03 Sep, 2019

2 commits

  • When a function such as dsa_slave_create fails, currently the following
    stack trace can be seen:

    [ 2.038342] sja1105 spi0.1: Probed switch chip: SJA1105T
    [ 2.054556] sja1105 spi0.1: Reset switch and programmed static config
    [ 2.063837] sja1105 spi0.1: Enabled switch tagging
    [ 2.068706] fsl-gianfar soc:ethernet@2d90000 eth2: error -19 setting up slave phy
    [ 2.076371] ------------[ cut here ]------------
    [ 2.080973] WARNING: CPU: 1 PID: 21 at net/core/devlink.c:6184 devlink_free+0x1b4/0x1c0
    [ 2.088954] Modules linked in:
    [ 2.092005] CPU: 1 PID: 21 Comm: kworker/1:1 Not tainted 5.3.0-rc6-01360-g41b52e38d2b6-dirty #1746
    [ 2.100912] Hardware name: Freescale LS1021A
    [ 2.105162] Workqueue: events deferred_probe_work_func
    [ 2.110287] [] (unwind_backtrace) from [] (show_stack+0x10/0x14)
    [ 2.117992] [] (show_stack) from [] (dump_stack+0xb4/0xc8)
    [ 2.125180] [] (dump_stack) from [] (__warn+0xe0/0xf8)
    [ 2.132018] [] (__warn) from [] (warn_slowpath_null+0x40/0x48)
    [ 2.139549] [] (warn_slowpath_null) from [] (devlink_free+0x1b4/0x1c0)
    [ 2.147772] [] (devlink_free) from [] (dsa_switch_teardown+0x60/0x6c)
    [ 2.155907] [] (dsa_switch_teardown) from [] (dsa_register_switch+0x8e4/0xaa8)
    [ 2.164821] [] (dsa_register_switch) from [] (sja1105_probe+0x21c/0x2ec)
    [ 2.173216] [] (sja1105_probe) from [] (spi_drv_probe+0x80/0xa4)
    [ 2.180920] [] (spi_drv_probe) from [] (really_probe+0x108/0x400)
    [ 2.188711] [] (really_probe) from [] (driver_probe_device+0x78/0x1bc)
    [ 2.196933] [] (driver_probe_device) from [] (bus_for_each_drv+0x58/0xb8)
    [ 2.205414] [] (bus_for_each_drv) from [] (__device_attach+0xd0/0x168)
    [ 2.213637] [] (__device_attach) from [] (bus_probe_device+0x84/0x8c)
    [ 2.221772] [] (bus_probe_device) from [] (deferred_probe_work_func+0x84/0xc4)
    [ 2.230686] [] (deferred_probe_work_func) from [] (process_one_work+0x218/0x510)
    [ 2.239772] [] (process_one_work) from [] (worker_thread+0x2a8/0x5c0)
    [ 2.247908] [] (worker_thread) from [] (kthread+0x148/0x150)
    [ 2.255265] [] (kthread) from [] (ret_from_fork+0x14/0x2c)
    [ 2.262444] Exception stack(0xea965fb0 to 0xea965ff8)
    [ 2.267466] 5fa0: 00000000 00000000 00000000 00000000
    [ 2.275598] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
    [ 2.283729] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000
    [ 2.290333] ---[ end trace ca5d506728a0581a ]---

    devlink_free is complaining right here:

    WARN_ON(!list_empty(&devlink->port_list));

    This happens because devlink_port_unregister is no longer done right
    away in dsa_port_setup when a DSA_PORT_TYPE_USER has failed.
    Vivien said about this change that:

    Also no need to call devlink_port_unregister from within dsa_port_setup
    as this step is inconditionally handled by dsa_port_teardown on error.

    which is not really true. The devlink_port_unregister function _is_
    being called unconditionally from within dsa_port_setup, but not for
    this port that just failed, just for the previous ones which were set
    up.

    ports_teardown:
    for (i = 0; i < port; i++)
    dsa_port_teardown(&ds->ports[i]);

    Initially I was tempted to fix this by extending the "for" loop to also
    cover the port that failed during setup. But this could have potentially
    unforeseen consequences unrelated to devlink_port or even other types of
    ports than user ports, which I can't really test for. For example, if
    for some reason devlink_port_register itself would fail, then
    unconditionally unregistering it in dsa_port_teardown would not be a
    smart idea. The list might go on.

    So just make dsa_port_setup undo the setup it had done upon failure, and
    let the for loop undo the work of setting up the previous ports, which
    are guaranteed to be brought up to a consistent state.

    Fixes: 955222ca5281 ("net: dsa: use a single switch statement for port setup")
    Signed-off-by: Vladimir Oltean
    Reviewed-by: Vivien Didelot
    Signed-off-by: David S. Miller

    Vladimir Oltean
     
  • r8152 conflicts are the NAPI fixes in 'net' overlapping with
    some tasklet stuff in net-next

    Signed-off-by: David S. Miller

    David S. Miller
     

01 Sep, 2019

1 commit

  • The bridge core assumes that enabling/disabling vlan_filtering will
    translate into the simple toggling of a flag for switchdev drivers.

    That is clearly not the case for sja1105, which alters the VLAN table
    and the pvids in order to obtain port separation in standalone mode.

    There are 2 parts to the issue.

    First, tag_8021q changes the pvid to a unique per-port rx_vid for frame
    identification. But we need to disable tag_8021q when vlan_filtering
    kicks in, and at that point, the VLAN configured as pvid will have to be
    removed from the filtering table of the ports. With an invalid pvid, the
    ports will drop all traffic. Since the bridge will not call any vlan
    operation through switchdev after enabling vlan_filtering, we need to
    ensure we're in a functional state ourselves. Hence read the pvid that
    the bridge is aware of, and program that into our ports.

    Secondly, tag_8021q uses the 1024-3071 range privately in
    vlan_filtering=0 mode. Had the user installed one of these VLANs during
    a previous vlan_filtering=1 session, then upon the next tag_8021q
    cleanup for vlan_filtering to kick in again, VLANs in that range will
    get deleted unconditionally, hence breaking user expectation. So when
    deleting the VLANs, check if the bridge had knowledge about them, and if
    it did, re-apply the settings. Wrap this logic inside a
    dsa_8021q_vid_apply helper function to reduce code duplication.

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

    Vladimir Oltean
     

28 Aug, 2019

8 commits

  • When adding a VLAN sub-interface on a DSA slave port, the 8021q core
    checks NETIF_F_HW_VLAN_CTAG_FILTER and, if the netdev is capable of
    filtering, calls .ndo_vlan_rx_add_vid or .ndo_vlan_rx_kill_vid to
    configure the VLAN offloading.

    DSA sets this up counter-intuitively: it always advertises this netdev
    feature, but the underlying driver may not actually support VLAN table
    manipulation. In that case, the DSA core is forced to ignore the error,
    because not being able to offload the VLAN is still fine - and should
    result in the creation of a non-accelerated VLAN sub-interface.

    Change this so that the netdev feature is only advertised for switch
    drivers that support VLAN manipulation, instead of checking for
    -EOPNOTSUPP at runtime.

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

    Vladimir Oltean
     
  • After witnessing the discussion in https://lkml.org/lkml/2019/8/14/151
    w.r.t. ioctl extensibility, it became clear that such an issue might
    prevent that the 3 RSV bits inside the DSA 802.1Q tag might also suffer
    the same fate and be useless for further extension.

    So clearly specify that the reserved bits should currently be
    transmitted as zero and ignored on receive. The DSA tagger already does
    this (and has always did), and is the only known user so far (no
    Wireshark dissection plugin, etc). So there should be no incompatibility
    to speak of.

    Fixes: 0471dd429cea ("net: dsa: tag_8021q: Create a stable binary format")
    Signed-off-by: Vladimir Oltean
    Reviewed-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Vladimir Oltean
     
  • When the bridge offloads a VLAN on a slave port, we also need to
    program its dedicated CPU port as a member of the VLAN.

    Drivers may handle the CPU port's membership as they want. For example,
    Marvell as a special "Unmodified" mode to pass frames as is through
    such ports.

    Even though DSA expects the drivers to handle the CPU port membership,
    it does not make sense to program user VLANs as PVID on the CPU port.
    This patch clears this flag before programming the CPU port.

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

    Vivien Didelot
     
  • DSA currently programs a VLAN on the CPU port implicitly after the
    related notifier is received by a switch.

    While we still need to do this transparent programmation of the DSA
    links in the fabric, programming the CPU port this way may cause
    problems in some corners such as the tag_8021q driver.

    Because the dedicated CPU port is specific to a slave, make their
    programmation explicit a few layers up, in the slave code.

    Note that technically, DSA links have a dedicated CPU port as well,
    but since they are only used as conduit between interconnected switches
    of a fabric, programming them transparently this way is what we want.

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

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

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

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

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

    Vivien Didelot
     
  • Add dsa_slave_vlan_add and dsa_slave_vlan_del helpers to handle
    SWITCHDEV_OBJ_ID_PORT_VLAN switchdev objects. Also copy the
    switchdev_obj_port_vlan structure on add since we will modify it in
    future patches.

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

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

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

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

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

    Vivien Didelot
     
  • The bitmap operations were introduced to simplify the switch drivers
    in the future, since most of them could implement the common VLAN and
    MDB operations (add, del, dump) with simple functions taking all target
    ports at once, and thus limiting the number of hardware accesses.

    Programming an MDB or VLAN this way in a single operation would clearly
    simplify the drivers a lot but would require a new get-set interface
    in DSA. The usage of such bitmap from the stack also raised concerned
    in the past, leading to the dynamic allocation of a new ds->_bitmap
    member in the dsa_switch structure. So let's get rid of them for now.

    This commit nicely wraps the ds->ops->port_{mdb,vlan}_{prepare,add}
    switch operations into new dsa_switch_{mdb,vlan}_{prepare,add}
    variants not using any bitmap argument anymore.

    New dsa_switch_{mdb,vlan}_match helpers have been introduced to make
    clear which local port of a switch must be programmed with the target
    object. While the targeted user port is an obvious candidate, the
    DSA links must also be programmed, as well as the CPU port for VLANs.

    While at it, also remove local variables that are only used once.

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

    Vivien Didelot
     

21 Aug, 2019

2 commits

  • Call the .port_enable and .port_disable functions for all ports,
    not only the user ports, so that drivers may optimize the power
    consumption of all ports after a successful setup.

    Unused ports are now disabled on setup. CPU and DSA ports are now
    enabled on setup and disabled on teardown. User ports were already
    enabled at slave creation and disabled at slave destruction.

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

    Vivien Didelot
     
  • It is currently difficult to read the different steps involved in the
    setup and teardown of ports in the DSA code. Keep it simple with a
    single switch statement for each port type: UNUSED, CPU, DSA, or USER.

    Also no need to call devlink_port_unregister from within dsa_port_setup
    as this step is inconditionally handled by dsa_port_teardown on error.

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

    Vivien Didelot
     

20 Aug, 2019

1 commit


18 Aug, 2019

1 commit


12 Aug, 2019

1 commit

  • The dsa framework has optional .port_mdb_{prepare,add,del} callback fields
    for drivers to handle multicast database entries. When adding an entry, the
    framework goes through a prepare phase, then a commit phase. Drivers not
    providing these callbacks should be detected in the prepare phase.

    DSA core may still bypass the bridge layer and call the dsa_port_mdb_add
    function directly with no prepare phase or no switchdev trans object,
    and the framework ends up calling an undefined .port_mdb_add callback.
    This results in a NULL pointer dereference, as shown in the log below.

    The other functions seem to be properly guarded. Do the same for
    .port_mdb_add in dsa_switch_mdb_add_bitmap() as well.

    8] lr : [] psr: 80070013
    sp : ee871db8 ip : 00000000 fp : ee98d0a4
    r10: 0000000c r9 : 00000008 r8 : ee89f710
    r7 : ee98d040 r6 : ee98d088 r5 : c0f04c48 r4 : ee98d04c
    r3 : 00000000 r2 : ee89f710 r1 : 00000008 r0 : ee98d040
    Flags: Nzcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none
    Control: 10c5387d Table: 6deb406a DAC: 00000051
    Process kworker/1:2 (pid: 134, stack limit = 0x(ptrval))
    Stack: (0xee871db8 to 0xee872000)
    1da0: ee871e14 103ace2d
    1dc0: 00000000 ffffffff 00000000 ee871e14 00000005 00000000 c08524a0 00000000
    1de0: ffffe000 c014bdfc c0f04c48 ee871e98 c0f04c48 ee9e5000 c0851120 c014bef0
    1e00: 00000000 b643aea2 ee9b4068 c08509a8 ee2bf940 ee89f710 ee871ecb 00000000
    1e20: 00000008 103ace2d 00000000 c087e248 ee29c868 103ace2d 00000001 ffffffff
    1e40: 00000000 ee871e98 00000006 00000000 c0fb2a50 c087e2d0 ffffffff c08523c4
    1e60: ffffffff c014bdfc 00000006 c0fad2d0 ee871e98 ee89f710 00000000 c014c500
    1e80: 00000000 ee89f3c0 c0f04c48 00000000 ee9e5000 c087dfb4 ee9e5000 00000000
    1ea0: ee89f710 ee871ecb 00000001 103ace2d 00000000 c0f04c48 00000000 c087e0a8
    1ec0: 00000000 efd9a3e0 0089f3c0 103ace2d ee89f700 ee89f710 ee9e5000 00000122
    1ee0: 00000100 c087e130 ee89f700 c0fad2c8 c1003ef0 c087de4c 2e928000 c0fad2ec
    1f00: c0fad2ec ee839580 ef7a62c0 ef7a9400 00000000 c087def8 c0fad2ec c01447dc
    1f20: ef315640 ef7a62c0 00000008 ee839580 ee839594 ef7a62c0 00000008 c0f03d00
    1f40: ef7a62d8 ef7a62c0 ffffe000 c0145b84 ffffe000 c0fb2420 c0bfaa8c 00000000
    1f60: ffffe000 ee84b600 ee84b5c0 00000000 ee870000 ee839580 c0145b40 ef0e5ea4
    1f80: ee84b61c c014a6f8 00000001 ee84b5c0 c014a5b0 00000000 00000000 00000000
    1fa0: 00000000 00000000 00000000 c01010e8 00000000 00000000 00000000 00000000
    1fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
    1fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000
    [] (dsa_switch_event) from [] (notifier_call_chain+0x48/0x84)
    [] (notifier_call_chain) from [] (raw_notifier_call_chain+0x18/0x20)
    [] (raw_notifier_call_chain) from [] (dsa_port_mdb_add+0x48/0x74)
    [] (dsa_port_mdb_add) from [] (__switchdev_handle_port_obj_add+0x54/0xd4)
    [] (__switchdev_handle_port_obj_add) from [] (switchdev_handle_port_obj_add+0x8/0x14)
    [] (switchdev_handle_port_obj_add) from [] (dsa_slave_switchdev_blocking_event+0x94/0xa4)
    [] (dsa_slave_switchdev_blocking_event) from [] (notifier_call_chain+0x48/0x84)
    [] (notifier_call_chain) from [] (blocking_notifier_call_chain+0x50/0x68)
    [] (blocking_notifier_call_chain) from [] (switchdev_port_obj_notify+0x44/0xa8)
    [] (switchdev_port_obj_notify) from [] (switchdev_port_obj_add_now+0x90/0x104)
    [] (switchdev_port_obj_add_now) from [] (switchdev_port_obj_add_deferred+0x14/0x5c)
    [] (switchdev_port_obj_add_deferred) from [] (switchdev_deferred_process+0x64/0x104)
    [] (switchdev_deferred_process) from [] (switchdev_deferred_process_work+0xc/0x14)
    [] (switchdev_deferred_process_work) from [] (process_one_work+0x218/0x50c)
    [] (process_one_work) from [] (worker_thread+0x44/0x5bc)
    [] (worker_thread) from [] (kthread+0x148/0x150)
    [] (kthread) from [] (ret_from_fork+0x14/0x2c)
    Exception stack(0xee871fb0 to 0xee871ff8)
    1fa0: 00000000 00000000 00000000 00000000
    1fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
    1fe0: 00000000 00000000 00000000 00000000 00000013 00000000
    Code: bad PC value
    ---[ end trace 1292c61abd17b130 ]---

    [] (dsa_switch_event) from [] (notifier_call_chain+0x48/0x84)
    corresponds to

    $ arm-linux-gnueabihf-addr2line -C -i -e vmlinux c08533ec

    linux/net/dsa/switch.c:156
    linux/net/dsa/switch.c:178
    linux/net/dsa/switch.c:328

    Fixes: e6db98db8a95 ("net: dsa: add switch mdb bitmap functions")
    Signed-off-by: Chen-Yu Tsai
    Reviewed-by: Vivien Didelot
    Signed-off-by: David S. Miller

    Chen-Yu Tsai
     

07 Aug, 2019

5 commits

  • Just minor overlapping changes in the conflicts here.

    Signed-off-by: David S. Miller

    David S. Miller
     
  • When RX timestamping is enabled and two link-local (non-meta) frames are
    received in a row, this constitutes an error.

    The tagger is always caching the last link-local frame, in an attempt to
    merge it with the meta follow-up frame when that arrives. To recover
    from the above error condition, the initial cached link-local frame is
    dropped and the second frame in a row is cached (in expectance of the
    second meta frame).

    However, when dropping the initial link-local frame, its backing memory
    was being leaked.

    Fixes: f3097be21bf1 ("net: dsa: sja1105: Add a state machine for RX timestamping")
    Signed-off-by: Vladimir Oltean
    Signed-off-by: David S. Miller

    Vladimir Oltean
     
  • After a meta frame is received, it is associated with the cached
    sp->data->stampable_skb from the DSA tagger private structure.

    Cached means its refcount is incremented with skb_get() in order for
    dsa_switch_rcv() to not free it when the tagger .rcv returns NULL.

    The mistake is that skb_unref() is not the correct function to use. It
    will correctly decrement the refcount (which will go back to zero) but
    the skb memory will not be freed. That is the job of kfree_skb(), which
    also calls skb_unref().

    But it turns out that freeing the cached stampable_skb is in fact not
    necessary. It is still a perfectly valid skb, and now it is even
    annotated with the partial RX timestamp. So remove the skb_copy()
    altogether and simply pass the stampable_skb with a refcount of 1
    (incremented by us, decremented by dsa_switch_rcv) up the stack.

    Fixes: f3097be21bf1 ("net: dsa: sja1105: Add a state machine for RX timestamping")
    Signed-off-by: Vladimir Oltean
    Signed-off-by: David S. Miller

    Vladimir Oltean
     
  • Merge the CPU port registers dump into the master interface registers
    dump through ethtool, by nesting the ethtool_drvinfo and ethtool_regs
    structures of the CPU port into the dump.

    drvinfo->regdump_len will contain the full data length, while regs->len
    will contain only the master interface registers dump length.

    This allows for example to dump the CPU port registers on a ZII Dev
    C board like this:

    # ethtool -d eth1
    0x004: 0x00000000
    0x008: 0x0a8000aa
    0x010: 0x01000000
    0x014: 0x00000000
    0x024: 0xf0000102
    0x040: 0x6d82c800
    0x044: 0x00000020
    0x064: 0x40000000
    0x084: RCR (Receive Control Register) 0x47c00104
    MAX_FL (Maximum frame length) 1984
    FCE (Flow control enable) 0
    BC_REJ (Broadcast frame reject) 0
    PROM (Promiscuous mode) 0
    DRT (Disable receive on transmit) 0
    LOOP (Internal loopback) 0
    0x0c4: TCR (Transmit Control Register) 0x00000004
    RFC_PAUSE (Receive frame control pause) 0
    TFC_PAUSE (Transmit frame control pause) 0
    FDEN (Full duplex enable) 1
    HBC (Heartbeat control) 0
    GTS (Graceful transmit stop) 0
    0x0e4: 0x76735d6d
    0x0e8: 0x7e9e8808
    0x0ec: 0x00010000
    .
    .
    .
    88E6352 Switch Port Registers
    ------------------------------
    00: Port Status 0x4d04
    Pause Enabled 0
    My Pause 1
    802.3 PHY Detected 0
    Link Status Up
    Duplex Full
    Speed 100 or 200 Mbps
    EEE Enabled 0
    Transmitter Paused 0
    Flow Control 0
    Config Mode 0x4
    01: Physical Control 0x003d
    RGMII Receive Timing Control Default
    RGMII Transmit Timing Control Default
    200 BASE Mode 100
    Flow Control's Forced value 0
    Force Flow Control 0
    Link's Forced value Up
    Force Link 1
    Duplex's Forced value Full
    Force Duplex 1
    Force Speed 100 or 200 Mbps
    .
    .
    .

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

    Vivien Didelot
     
  • This Kconfig option is unused, drop it.

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

    Marek Vasut
     

31 Jul, 2019

1 commit

  • Add DSA tag code for Microchip KSZ8795 switch. The switch is simpler
    and the tag is only 1 byte, instead of 2 as is the case with KSZ9477.

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

    Tristram Ha
     

20 Jul, 2019

1 commit

  • This object stores the flow block callbacks that are attached to this
    block. Update flow_block_cb_lookup() to take this new object.

    This patch restores the block sharing feature.

    Fixes: da3eeb904ff4 ("net: flow_offload: add list handling functions")
    Signed-off-by: Pablo Neira Ayuso
    Acked-by: Jiri Pirko
    Signed-off-by: David S. Miller

    Pablo Neira Ayuso