1. 23 10月, 2019 6 次提交
  2. 19 10月, 2019 1 次提交
  3. 18 10月, 2019 2 次提交
    • M
      net: dsa: microchip: Add shared regmap mutex · 013572a2
      Marek Vasut 提交于
      The KSZ driver uses one regmap per register width (8/16/32), each with
      it's own lock, but accessing the same set of registers. In theory, it
      is possible to create a race condition between these regmaps, although
      the underlying bus (SPI or I2C) locking should assure nothing bad will
      really happen and the accesses would be correct.
      
      To make the driver do the right thing, add one single shared mutex for
      all the regmaps used by the driver instead. This assures that even if
      some future hardware is on a bus which does not serialize the accesses
      the same way SPI or I2C does, nothing bad will happen.
      
      Note that the status_mutex was unused and only initied, hence it was
      renamed and repurposed as the regmap mutex.
      Signed-off-by: NMarek Vasut <marex@denx.de>
      Cc: Andrew Lunn <andrew@lunn.ch>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: George McCollister <george.mccollister@gmail.com>
      Cc: Tristram Ha <Tristram.Ha@microchip.com>
      Cc: Woojung Huh <woojung.huh@microchip.com>
      Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      013572a2
    • M
      net: dsa: microchip: Do not reinit mutexes on KSZ87xx · 7f238ca9
      Marek Vasut 提交于
      The KSZ87xx driver calls mutex_init() on mutexes already inited in
      ksz_common.c ksz_switch_register(). Do not do it twice, drop the
      reinitialization.
      Signed-off-by: NMarek Vasut <marex@denx.de>
      Cc: Andrew Lunn <andrew@lunn.ch>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: George McCollister <george.mccollister@gmail.com>
      Cc: Tristram Ha <Tristram.Ha@microchip.com>
      Cc: Woojung Huh <woojung.huh@microchip.com>
      Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7f238ca9
  4. 16 10月, 2019 4 次提交
    • N
      net: dsa: sja1105: Use the correct style for SPDX License Identifier · b790b554
      Nishad Kamdar 提交于
      This patch corrects the SPDX License Identifier style
      in header files related to Distributed Switch Architecture
      drivers for NXP SJA1105 series Ethernet switch support.
      It uses an expilict block comment for the SPDX License
      Identifier.
      
      Changes made by using a script provided by Joe Perches here:
      https://lkml.org/lkml/2019/2/7/46.
      Suggested-by: NJoe Perches <joe@perches.com>
      Signed-off-by: NNishad Kamdar <nishadkamdar@gmail.com>
      Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b790b554
    • N
      net: dsa: microchip: Use the correct style for SPDX License Identifier · b31141d3
      Nishad Kamdar 提交于
      This patch corrects the SPDX License Identifier style
      in header files related to Distributed Switch Architecture
      drivers for Microchip KSZ series switch support.
      For C header files Documentation/process/license-rules.rst
      mandates C-like comments (opposed to C source files where
      C++ style should be used)
      
      Changes made by using a script provided by Joe Perches here:
      https://lkml.org/lkml/2019/2/7/46.
      Suggested-by: NJoe Perches <joe@perches.com>
      Signed-off-by: NNishad Kamdar <nishadkamdar@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b31141d3
    • V
      net: dsa: sja1105: Switch to scatter/gather API for SPI · 08839c06
      Vladimir Oltean 提交于
      This reworks the SPI transfer implementation to make use of more of the
      SPI core features. The main benefit is to avoid the memcpy in
      sja1105_xfer_buf().
      
      The memcpy was only needed because the function was transferring a
      single buffer at a time. So it needed to copy the caller-provided buffer
      at buf + 4, to store the SPI message header in the "headroom" area.
      
      But the SPI core supports scatter-gather messages, comprised of multiple
      transfers. We can actually use those to break apart every SPI message
      into 2 transfers: one for the header and one for the actual payload.
      
      To keep the behavior the same regarding the chip select signal, it is
      necessary to tell the SPI core to de-assert the chip select after each
      chunk. This was not needed before, because each spi_message contained
      only 1 single transfer.
      
      The meaning of the per-transfer cs_change=1 is:
      
      - If the transfer is the last one of the message, keep CS asserted
      - Otherwise, deassert CS
      
      We need to deassert CS in the "otherwise" case, which was implicit
      before.
      
      Avoiding the memcpy creates yet another opportunity. The device can't
      process more than 256 bytes of SPI payload at a time, so the
      sja1105_xfer_long_buf() function used to exist, to split the larger
      caller buffer into chunks.
      
      But these chunks couldn't be used as scatter/gather buffers for
      spi_message until now, because of that memcpy (we would have needed more
      memory for each chunk). So we can now remove the sja1105_xfer_long_buf()
      function and have a single implementation for long and short buffers.
      
      Another benefit is lower usage of stack memory. Previously we had to
      store 2 SPI buffers for each chunk. Due to the elimination of the
      memcpy, we can now send pointers to the actual chunks from the
      caller-supplied buffer to the SPI core.
      
      Since the patch merges two functions into a rewritten implementation,
      the function prototype was also changed, mainly for cosmetic consistency
      with the structures used within it.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      08839c06
    • V
      net: dsa: sja1105: Move sja1105_spi_transfer into sja1105_xfer · 8a559400
      Vladimir Oltean 提交于
      This is a cosmetic patch that reduces some boilerplate in the SPI
      interaction of the driver.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      8a559400
  5. 15 10月, 2019 4 次提交
    • V
      net: dsa: sja1105: Change the PTP command access pattern · 66427778
      Vladimir Oltean 提交于
      The PTP command register contains enable bits for:
      - Putting the 64-bit PTPCLKVAL register in add/subtract or write mode
      - Taking timestamps off of the corrected vs free-running clock
      - Starting/stopping the TTEthernet scheduling
      - Starting/stopping PPS output
      - Resetting the switch
      
      When a command needs to be issued (e.g. "change the PTPCLKVAL from write
      mode to add/subtract mode"), one cannot simply write to the command
      register setting the PTPCLKADD bit to 1, because that would zeroize the
      other settings. One also cannot do a read-modify-write (that would be
      too easy for this hardware) because not all bits of the command register
      are readable over SPI.
      
      So this leaves us with the only option of keeping the value of the PTP
      command register in the driver, and operating on that.
      
      Actually there are 2 types of PTP operations now:
      - Operations that modify the cached PTP command. These operate on
        ptp_data->cmd as a pointer.
      - Operations that apply all previously cached PTP settings, but don't
        otherwise cache what they did themselves. The sja1105_ptp_reset
        function is such an example. It copies the ptp_data->cmd on stack
        before modifying and writing it to SPI.
      
      This practically means that struct sja1105_ptp_cmd is no longer an
      implementation detail, since it needs to be stored in full into struct
      sja1105_ptp_data, and hence in struct sja1105_private. So the (*ptp_cmd)
      function prototype can change and take struct sja1105_ptp_cmd as second
      argument now.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      66427778
    • V
      net: dsa: sja1105: Move PTP data to its own private structure · a9d6ed7a
      Vladimir Oltean 提交于
      This is a non-functional change with 2 goals (both for the case when
      CONFIG_NET_DSA_SJA1105_PTP is not enabled):
      
      - Reduce the size of the sja1105_private structure.
      - Make the PTP code more self-contained.
      
      Leaving priv->ptp_data.lock to be initialized in sja1105_main.c is not a
      leftover: it will be used in a future patch "net: dsa: sja1105: Restore
      PTP time after switch reset".
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a9d6ed7a
    • V
      net: dsa: sja1105: Make all public PTP functions take dsa_switch as argument · 61c77126
      Vladimir Oltean 提交于
      The new rule (as already started for sja1105_tas.h) is for functions of
      optional driver components (ones which may be disabled via Kconfig - PTP
      and TAS) to take struct dsa_switch *ds instead of struct sja1105_private
      *priv as first argument.
      
      This is so that forward-declarations of struct sja1105_private can be
      avoided.
      
      So make sja1105_ptp.h the second user of this rule.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      61c77126
    • V
      net: dsa: sja1105: Get rid of global declaration of struct ptp_clock_info · 5b3ae43a
      Vladimir Oltean 提交于
      We need priv->ptp_caps to hold a structure and not just a pointer,
      because we use container_of in the various PTP callbacks.
      
      Therefore, the sja1105_ptp_caps structure declared in the global memory
      of the driver serves no further purpose after copying it into
      priv->ptp_caps.
      
      So just populate priv->ptp_caps with the needed operations and remove
      sja1105_ptp_caps.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      5b3ae43a
  6. 07 10月, 2019 1 次提交
  7. 06 10月, 2019 1 次提交
  8. 05 10月, 2019 2 次提交
  9. 03 10月, 2019 6 次提交
    • V
      net: dsa: sja1105: Rename sja1105_spi_send_packed_buf to sja1105_xfer_buf · 1bd44870
      Vladimir Oltean 提交于
      The most commonly called function in the driver is long due for a
      rename. The "packed" word is redundant (it doesn't make sense to
      transfer an unpacked structure, since that is in CPU endianness yadda
      yadda), and the "spi" word is also redundant since argument 2 of the
      function is SPI_READ or SPI_WRITE.
      
      As for the sja1105_spi_send_long_packed_buf function, it is only being
      used from sja1105_spi.c, so remove its global prototype.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1bd44870
    • V
      net: dsa: sja1105: Replace sja1105_spi_send_int with sja1105_xfer_{u32, u64} · dff79620
      Vladimir Oltean 提交于
      Having a function that takes a variable number of unpacked bytes which
      it generically calls an "int" is confusing and makes auditing patches
      next to impossible.
      
      We only use spi_send_int with the int sizes of 32 and 64 bits. So just
      make the spi_send_int function less generic and replace it with the
      appropriate two explicit functions, which can now type-check the int
      pointer type.
      
      Note that there is still a small weirdness in the u32 function, which
      has to convert it to a u64 temporary. This is because of how the packing
      API works at the moment, but the weirdness is at least hidden from
      callers of sja1105_xfer_u32 now.
      Suggested-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      dff79620
    • V
      net: dsa: sja1105: Don't use "inline" function declarations in C files · 09c1b412
      Vladimir Oltean 提交于
      Let the compiler decide.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      09c1b412
    • V
      net: dsa: sja1105: Fix sleeping while atomic in .port_hwtstamp_set · 3e8db7e5
      Vladimir Oltean 提交于
      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] [<c0313d7c>] (unwind_backtrace) from [<c030e13c>] (show_stack+0x10/0x14)
      [   41.607584] [<c030e13c>] (show_stack) from [<c1212d50>] (dump_stack+0xd4/0x100)
      [   41.614863] [<c1212d50>] (dump_stack) from [<c037dfc8>] (___might_sleep+0x1c8/0x2b4)
      [   41.622574] [<c037dfc8>] (___might_sleep) from [<c122ea90>] (__mutex_lock+0x48/0xab8)
      [   41.630368] [<c122ea90>] (__mutex_lock) from [<c122f51c>] (mutex_lock_nested+0x1c/0x24)
      [   41.638340] [<c122f51c>] (mutex_lock_nested) from [<c0c6fe08>] (sja1105_static_config_reload+0x30/0x27c)
      [   41.647779] [<c0c6fe08>] (sja1105_static_config_reload) from [<c0c7015c>] (sja1105_hwtstamp_set+0x108/0x1cc)
      [   41.657562] [<c0c7015c>] (sja1105_hwtstamp_set) from [<c0feb650>] (dev_ifsioc+0x18c/0x330)
      [   41.665788] [<c0feb650>] (dev_ifsioc) from [<c0febbd8>] (dev_ioctl+0x320/0x6e8)
      [   41.673064] [<c0febbd8>] (dev_ioctl) from [<c0f8b1f4>] (sock_ioctl+0x334/0x5e8)
      [   41.680340] [<c0f8b1f4>] (sock_ioctl) from [<c05404a8>] (do_vfs_ioctl+0xb0/0xa10)
      [   41.687789] [<c05404a8>] (do_vfs_ioctl) from [<c0540e3c>] (ksys_ioctl+0x34/0x58)
      [   41.695151] [<c0540e3c>] (ksys_ioctl) from [<c0301000>] (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: a602afd2 ("net: dsa: sja1105: Expose PTP timestamping ioctls to userspace")
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3e8db7e5
    • V
      net: dsa: sja1105: Initialize the meta_lock · d6530e5a
      Vladimir Oltean 提交于
      Otherwise, with CONFIG_DEBUG_SPINLOCK=y, this stack trace gets printed
      when enabling RX timestamping and receiving a PTP frame:
      
      [  318.537078] INFO: trying to register non-static key.
      [  318.542040] the code is fine but needs lockdep annotation.
      [  318.547500] turning off the locking correctness validator.
      [  318.552972] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.3.0-13257-g0825b0669811-dirty #1962
      [  318.561283] Hardware name: Freescale LS1021A
      [  318.565566] [<c03144bc>] (unwind_backtrace) from [<c030e164>] (show_stack+0x10/0x14)
      [  318.573289] [<c030e164>] (show_stack) from [<c11b9f50>] (dump_stack+0xd4/0x100)
      [  318.580579] [<c11b9f50>] (dump_stack) from [<c03b9b40>] (register_lock_class+0x728/0x734)
      [  318.588731] [<c03b9b40>] (register_lock_class) from [<c03b60c4>] (__lock_acquire+0x78/0x25cc)
      [  318.597227] [<c03b60c4>] (__lock_acquire) from [<c03b8ef8>] (lock_acquire+0xd8/0x234)
      [  318.605033] [<c03b8ef8>] (lock_acquire) from [<c11db934>] (_raw_spin_lock+0x44/0x54)
      [  318.612755] [<c11db934>] (_raw_spin_lock) from [<c1164370>] (sja1105_rcv+0x1f8/0x4e8)
      [  318.620561] [<c1164370>] (sja1105_rcv) from [<c115d7cc>] (dsa_switch_rcv+0x80/0x204)
      [  318.628283] [<c115d7cc>] (dsa_switch_rcv) from [<c0f58c80>] (__netif_receive_skb_one_core+0x50/0x6c)
      [  318.637386] [<c0f58c80>] (__netif_receive_skb_one_core) from [<c0f58f04>] (netif_receive_skb_internal+0xac/0x264)
      [  318.647611] [<c0f58f04>] (netif_receive_skb_internal) from [<c0f59e98>] (napi_gro_receive+0x1d8/0x338)
      [  318.656887] [<c0f59e98>] (napi_gro_receive) from [<c0c298a4>] (gfar_clean_rx_ring+0x328/0x724)
      [  318.665472] [<c0c298a4>] (gfar_clean_rx_ring) from [<c0c29e60>] (gfar_poll_rx_sq+0x34/0x94)
      [  318.673795] [<c0c29e60>] (gfar_poll_rx_sq) from [<c0f5b40c>] (net_rx_action+0x128/0x4f8)
      [  318.681860] [<c0f5b40c>] (net_rx_action) from [<c03022f0>] (__do_softirq+0x148/0x5ac)
      [  318.689666] [<c03022f0>] (__do_softirq) from [<c0355af4>] (irq_exit+0x160/0x170)
      [  318.697040] [<c0355af4>] (irq_exit) from [<c03c6818>] (__handle_domain_irq+0x60/0xb4)
      [  318.704847] [<c03c6818>] (__handle_domain_irq) from [<c07e9440>] (gic_handle_irq+0x58/0x9c)
      [  318.713172] [<c07e9440>] (gic_handle_irq) from [<c0301a70>] (__irq_svc+0x70/0x98)
      [  318.720622] Exception stack(0xc2001f18 to 0xc2001f60)
      [  318.725656] 1f00:                                                       00000001 00000006
      [  318.733805] 1f20: 00000000 c20165c0 ffffe000 c2010cac c2010cf4 00000001 00000000 c2010c88
      [  318.741955] 1f40: c1f7a5a8 00000000 00000000 c2001f68 c03ba140 c030a288 200e0013 ffffffff
      [  318.750110] [<c0301a70>] (__irq_svc) from [<c030a288>] (arch_cpu_idle+0x24/0x3c)
      [  318.757486] [<c030a288>] (arch_cpu_idle) from [<c038a480>] (do_idle+0x1b8/0x2a4)
      [  318.764859] [<c038a480>] (do_idle) from [<c038a94c>] (cpu_startup_entry+0x18/0x1c)
      [  318.772407] [<c038a94c>] (cpu_startup_entry) from [<c1e00f10>] (start_kernel+0x4cc/0x4fc)
      
      Fixes: 844d7edc ("net: dsa: sja1105: Add a global sja1105_tagger_data structure")
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d6530e5a
    • L
      net: dsa: rtl8366: Check VLAN ID and not ports · e8521e53
      Linus Walleij 提交于
      There has been some confusion between the port number and
      the VLAN ID in this driver. What we need to check for
      validity is the VLAN ID, nothing else.
      
      The current confusion came from assigning a few default
      VLANs for default routing and we need to rewrite that
      properly.
      
      Instead of checking if the port number is a valid VLAN
      ID, check the actual VLAN IDs passed in to the callback
      one by one as expected.
      
      Fixes: d8652956 ("net: dsa: realtek-smi: Add Realtek SMI driver")
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e8521e53
  10. 02 10月, 2019 1 次提交
  11. 01 10月, 2019 3 次提交
    • N
      net: dsa: sja1105: Prevent leaking memory · 68501df9
      Navid Emamdoost 提交于
      In sja1105_static_config_upload, in two cases memory is leaked: when
      static_config_buf_prepare_for_upload fails and when sja1105_inhibit_tx
      fails. In both cases config_buf should be released.
      
      Fixes: 8aa9ebcc ("net: dsa: Introduce driver for NXP SJA1105 5-port L2 switch")
      Fixes: 1a4c6940 ("net: dsa: sja1105: Prevent PHY jabbering during switch reset")
      Signed-off-by: NNavid Emamdoost <navid.emamdoost@gmail.com>
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      68501df9
    • V
      net: dsa: sja1105: Ensure PTP time for rxtstamp reconstruction is not in the past · b6f2494d
      Vladimir Oltean 提交于
      Sometimes the PTP synchronization on the switch 'jumps':
      
        ptp4l[11241.155]: rms    8 max   16 freq -21732 +/-  11 delay   742 +/-   0
        ptp4l[11243.157]: rms    7 max   17 freq -21731 +/-  10 delay   744 +/-   0
        ptp4l[11245.160]: rms 33592410 max 134217731 freq +192422 +/- 8530253 delay   743 +/-   0
        ptp4l[11247.163]: rms 811631 max 964131 freq +10326 +/- 557785 delay   743 +/-   0
        ptp4l[11249.166]: rms 261936 max 533876 freq -304323 +/- 126371 delay   744 +/-   0
        ptp4l[11251.169]: rms 48700 max 57740 freq -20218 +/- 30532 delay   744 +/-   0
        ptp4l[11253.171]: rms 14570 max 30163 freq  -5568 +/- 7563 delay   742 +/-   0
        ptp4l[11255.174]: rms 2914 max 3440 freq -22001 +/- 1667 delay   744 +/-   1
        ptp4l[11257.177]: rms  811 max 1710 freq -22653 +/- 451 delay   744 +/-   1
        ptp4l[11259.180]: rms  177 max  218 freq -21695 +/-  89 delay   741 +/-   0
        ptp4l[11261.182]: rms   45 max   92 freq -21677 +/-  32 delay   742 +/-   0
        ptp4l[11263.186]: rms   14 max   32 freq -21733 +/-  11 delay   742 +/-   0
        ptp4l[11265.188]: rms    9 max   14 freq -21725 +/-  12 delay   742 +/-   0
        ptp4l[11267.191]: rms    9 max   16 freq -21727 +/-  13 delay   742 +/-   0
        ptp4l[11269.194]: rms    6 max   15 freq -21726 +/-   9 delay   743 +/-   0
        ptp4l[11271.197]: rms    8 max   15 freq -21728 +/-  11 delay   743 +/-   0
        ptp4l[11273.200]: rms    6 max   12 freq -21727 +/-   8 delay   743 +/-   0
        ptp4l[11275.202]: rms    9 max   17 freq -21720 +/-  11 delay   742 +/-   0
        ptp4l[11277.205]: rms    9 max   18 freq -21725 +/-  12 delay   742 +/-   0
      
      Background: the switch only offers partial RX timestamps (24 bits) and
      it is up to the driver to read the PTP clock to fill those timestamps up
      to 64 bits. But the PTP clock readout needs to happen quickly enough (in
      0.135 seconds, in fact), otherwise the PTP clock will wrap around 24
      bits, condition which cannot be detected.
      
      Looking at the 'max 134217731' value on output line 3, one can see that
      in hex it is 0x8000003. Because the PTP clock resolution is 8 ns,
      that means 0x1000000 in ticks, which is exactly 2^24. So indeed this is
      a PTP clock wraparound, but the reason might be surprising.
      
      What is going on is that sja1105_tstamp_reconstruct(priv, now, ts)
      expects a "now" time that is later than the "ts" was snapshotted at.
      This, of course, is obvious: we read the PTP time _after_ the partial RX
      timestamp was received. However, the workqueue is processing frames from
      a skb queue and reuses the same PTP time, read once at the beginning.
      Normally the skb queue only contains one frame and all goes well. But
      when the skb queue contains two frames, the second frame that gets
      dequeued might have been partially timestamped by the RX MAC _after_ we
      had read our PTP time initially.
      
      The code was originally like that due to concerns that SPI access for
      PTP time readout is a slow process, and we are time-constrained anyway
      (aka: premature optimization). But some timing analysis reveals that the
      time spent until the RX timestamp is completely reconstructed is 1 order
      of magnitude lower than the 0.135 s deadline even under worst-case
      conditions. So we can afford to read the PTP time for each frame in the
      RX timestamping queue, which of course ensures that the full PTP time is
      in the partial timestamp's future.
      
      Fixes: f3097be2 ("net: dsa: sja1105: Add a state machine for RX timestamping")
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b6f2494d
    • M
      net: dsa: qca8k: Use up to 7 ports for all operations · 7ae6d93c
      Michal Vokáč 提交于
      The QCA8K family supports up to 7 ports. So use the existing
      QCA8K_NUM_PORTS define to allocate the switch structure and limit all
      operations with the switch ports.
      
      This was not an issue until commit 0394a63a ("net: dsa: enable and
      disable all ports") disabled all unused ports. Since the unused ports 7-11
      are outside of the correct register range on this switch some registers
      were rewritten with invalid content.
      
      Fixes: 6b93fb46 ("net-next: dsa: add new driver for qca8xxx family")
      Fixes: a0c02161 ("net: dsa: variable number of ports")
      Fixes: 0394a63a ("net: dsa: enable and disable all ports")
      Signed-off-by: NMichal Vokáč <michal.vokac@ysoft.com>
      Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7ae6d93c
  12. 28 9月, 2019 1 次提交
    • M
      net: dsa: microchip: Always set regmap stride to 1 · a3aa6e65
      Marek Vasut 提交于
      The regmap stride is set to 1 for regmap describing 8bit registers already.
      However, for 16/32/64bit registers, the stride is 2/4/8 respectively. This
      is not correct, as the switch protocol supports unaligned register reads
      and writes and the KSZ87xx even uses such unaligned register accesses to
      read e.g. MIB counter.
      
      This patch fixes MIB counter access on KSZ87xx.
      Signed-off-by: NMarek Vasut <marex@denx.de>
      Cc: Andrew Lunn <andrew@lunn.ch>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: George McCollister <george.mccollister@gmail.com>
      Cc: Tristram Ha <Tristram.Ha@microchip.com>
      Cc: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
      Cc: Woojung Huh <woojung.huh@microchip.com>
      Fixes: 46558d60 ("net: dsa: microchip: Initial SPI regmap support")
      Fixes: 255b59ad ("net: dsa: microchip: Factor out regmap config generation into common header")
      Reviewed-by: NGeorge McCollister <george.mccollister@gmail.com>
      Tested-by: NGeorge McCollister <george.mccollister@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a3aa6e65
  13. 27 9月, 2019 1 次提交
  14. 23 9月, 2019 2 次提交
  15. 22 9月, 2019 1 次提交
    • M
      net: dsa: sja1105: Add dependency for NET_DSA_SJA1105_TAS · a8d570de
      Mao Wenan 提交于
      If CONFIG_NET_DSA_SJA1105_TAS=y and CONFIG_NET_SCH_TAPRIO=n,
      below error can be found:
      drivers/net/dsa/sja1105/sja1105_tas.o: In function `sja1105_setup_tc_taprio':
      sja1105_tas.c:(.text+0x318): undefined reference to `taprio_offload_free'
      sja1105_tas.c:(.text+0x590): undefined reference to `taprio_offload_get'
      drivers/net/dsa/sja1105/sja1105_tas.o: In function `sja1105_tas_teardown':
      sja1105_tas.c:(.text+0x610): undefined reference to `taprio_offload_free'
      make: *** [vmlinux] Error 1
      
      sja1105_tas needs tc-taprio, so this patch add the dependency for it.
      
      Fixes: 317ab5b8 ("net: dsa: sja1105: Configure the Time-Aware Scheduler via tc-taprio offload")
      Signed-off-by: NMao Wenan <maowenan@huawei.com>
      Reviewed-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NJakub Kicinski <jakub.kicinski@netronome.com>
      a8d570de
  16. 17 9月, 2019 3 次提交
    • V
      net: dsa: sja1105: Configure the Time-Aware Scheduler via tc-taprio offload · 317ab5b8
      Vladimir Oltean 提交于
      This qdisc offload is the closest thing to what the SJA1105 supports in
      hardware for time-based egress shaping. The switch core really is built
      around SAE AS6802/TTEthernet (a TTTech standard) but can be made to
      operate similarly to IEEE 802.1Qbv with some constraints:
      
      - The gate control list is a global list for all ports. There are 8
        execution threads that iterate through this global list in parallel.
        I don't know why 8, there are only 4 front-panel ports.
      
      - Care must be taken by the user to make sure that two execution threads
        never get to execute a GCL entry simultaneously. I created a O(n^4)
        checker for this hardware limitation, prior to accepting a taprio
        offload configuration as valid.
      
      - The spec says that if a GCL entry's interval is shorter than the frame
        length, you shouldn't send it (and end up in head-of-line blocking).
        Well, this switch does anyway.
      
      - The switch has no concept of ADMIN and OPER configurations. Because
        it's so simple, the TAS settings are loaded through the static config
        tables interface, so there isn't even place for any discussion about
        'graceful switchover between ADMIN and OPER'. You just reset the
        switch and upload a new OPER config.
      
      - The switch accepts multiple time sources for the gate events. Right
        now I am using the standalone clock source as opposed to PTP. So the
        base time parameter doesn't really do much. Support for the PTP clock
        source will be added in a future series.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      317ab5b8
    • V
      net: dsa: sja1105: Advertise the 8 TX queues · 5f06c63b
      Vladimir Oltean 提交于
      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: NVladimir Oltean <olteanv@gmail.com>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      5f06c63b
    • V
      net: dsa: sja1105: Add static config tables for scheduling · 7f1e4ba8
      Vladimir Oltean 提交于
      In order to support tc-taprio offload, the TTEthernet egress scheduling
      core registers must be made visible through the static interface.
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7f1e4ba8
  17. 16 9月, 2019 1 次提交