1. 09 9月, 2022 7 次提交
    • V
      net: mscc: ocelot: minimize definitions for stats · b69cf1c6
      Vladimir Oltean 提交于
      The current definition of struct ocelot_stat_layout is long-winded (4
      lines per entry, and we have hundreds of entries), so we could make an
      effort to use the C preprocessor and reduce the line count.
      
      Create an implicit correspondence between enum ocelot_reg, which tells
      us the register address (SYS_COUNT_RX_OCTETS etc) and enum ocelot_stat
      which allows us to index the ocelot->stats array (OCELOT_STAT_RX_OCTETS
      etc), and don't require us to specify both when we define what stats
      each switch family has.
      
      Create an OCELOT_STAT() macro that pairs only an enum ocelot_stat to an
      enum ocelot_reg, and an OCELOT_STAT_ETHTOOL() macro which also contains
      a name exported to the unstructured ethtool -S stringset API. For now,
      we define all counters as having the OCELOT_STAT_ETHTOOL() kind, but we
      will add more counters in the future which are not exported to the
      unstructured ethtool -S.
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b69cf1c6
    • V
      net: mscc: ocelot: harmonize names of SYS_COUNT_TX_AGING and OCELOT_STAT_TX_AGED · be5c13f2
      Vladimir Oltean 提交于
      The hardware counter is called C_TX_AGED, so rename SYS_COUNT_TX_AGING
      to SYS_COUNT_TX_AGED. This will become important since we want to
      minimize the way in which we declare struct ocelot_stat_layout elements,
      using the C preprocessor.
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      be5c13f2
    • V
      net: mscc: ocelot: add support for all sorts of standardized counters present in DSA · e32036e1
      Vladimir Oltean 提交于
      DSA is integrated with the new standardized ethtool -S --groups option,
      but the felix driver only exports unstructured statistics.
      
      Reuse the array of 64-bit statistics collected by ocelot_check_stats_work(),
      but just export select values from it.
      
      Since ocelot_check_stats_work() runs periodically to avoid 32-bit
      overflow, and the ethtool calling context is sleepable, we update the
      64-bit stats one more time, to provide up-to-date values. The locking
      scheme with a mutex followed by a spinlock is a bit hard to digest, so
      we create and use a ocelot_port_stats_run() helper with a callback that
      populates the ethool stats group the caller is interested in.
      
      The exported stats are:
      ethtool -S swp0 --groups eth-phy
      ethtool -S swp0 --groups eth-mac
      ethtool -S swp0 --groups eth-ctrl
      ethtool -S swp0 --groups rmon
      ethtool --include-statistics --show-pause swp0
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e32036e1
    • V
      net: dsa: felix: use ocelot's ndo_get_stats64 method · 776b71e5
      Vladimir Oltean 提交于
      Move the logic from the ocelot switchdev driver's ocelot_get_stats64()
      method to the common switch lib and reuse it for the DSA driver.
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      776b71e5
    • V
      net: dsa: felix: check the 32-bit PSFP stats against overflow · 25027c84
      Vladimir Oltean 提交于
      The Felix PSFP counters suffer from the same problem as the ocelot
      ndo_get_stats64 ones - they are 32-bit, so they can easily overflow and
      this can easily go undetected.
      
      Add a custom hook in ocelot_check_stats_work() through which driver
      specific actions can be taken, and update the stats for the existing
      PSFP filters from that hook.
      
      Previously, vsc9959_psfp_filter_add() and vsc9959_psfp_filter_del() were
      serialized with respect to each other via rtnl_lock(). However, with the
      new entry point into &psfp->sfi_list coming from the periodic worker, we
      now need an explicit mutex to serialize access to these lists.
      
      We used to keep a struct felix_stream_filter_counters on stack, through
      which vsc9959_psfp_stats_get() - a FLOW_CLS_STATS callback - would
      retrieve data from vsc9959_psfp_counters_get(). We need to become
      smarter about that in 3 ways:
      
      - we need to keep a persistent set of counters for each stream instead
        of keeping them on stack
      
      - we need to promote those counters from u32 to u64, and create a
        procedure that properly keeps 64-bit counters. Since we clear the
        hardware counters anyway, and we poll every 2 seconds, a simple
        increment of a u64 counter with a u32 value will perfectly do the job.
      
      - FLOW_CLS_STATS also expect incremental counters, so we also need to
        zeroize our u64 counters every time sch_flower calls us
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      25027c84
    • V
      net: mscc: ocelot: make access to STAT_VIEW sleepable again · 96980ff7
      Vladimir Oltean 提交于
      To support SPI-controlled switches in the future, access to
      SYS_STAT_CFG_STAT_VIEW needs to be done outside of any spinlock
      protected region, but it still needs to be serialized (by a mutex).
      
      Split the ocelot->stats_lock spinlock into a mutex that serializes
      indirect access to hardware registers (ocelot->stat_view_lock) and a
      spinlock that serializes access to the u64 ocelot->stats array.
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      96980ff7
    • V
      net: dsa: felix: add definitions for the stream filter counters · 0a2360c5
      Vladimir Oltean 提交于
      TSN stream (802.1Qci, 802.1CB) filters are also accessed through
      STAT_VIEW, just like the port registers, but these counters are per
      stream, rather than per port. So we don't keep them in
      ocelot_port_update_stats().
      
      What we can do, however, is we can create register definitions for them
      just like we have for the port counters, and delete the last remaining
      user of the SYS_CNT register + a group index (read_gix).
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0a2360c5
  2. 07 9月, 2022 9 次提交
    • V
      net: dsa: felix: access QSYS_TAG_CONFIG under tas_lock in vsc9959_sched_speed_set · a4bb481a
      Vladimir Oltean 提交于
      The read-modify-write of QSYS_TAG_CONFIG from vsc9959_sched_speed_set()
      runs unlocked with respect to the other functions that access it, which
      are vsc9959_tas_guard_bands_update(), vsc9959_qos_port_tas_set() and
      vsc9959_tas_clock_adjust(). All the others are under ocelot->tas_lock,
      so move the vsc9959_sched_speed_set() access under that lock as well, to
      resolve the concurrency.
      
      Fixes: 55a515b1 ("net: dsa: felix: drop oversized frames with tc-taprio instead of hanging the port")
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a4bb481a
    • V
      net: dsa: felix: disable cut-through forwarding for frames oversized for tc-taprio · 843794bb
      Vladimir Oltean 提交于
      Experimentally, it looks like when QSYS_QMAXSDU_CFG_7 is set to 605,
      frames even way larger than 601 octets are transmitted even though these
      should be considered as oversized, according to the documentation, and
      dropped.
      
      Since oversized frame dropping depends on frame size, which is only
      known at the EOF stage, and therefore not at SOF when cut-through
      forwarding begins, it means that the switch cannot take QSYS_QMAXSDU_CFG_*
      into consideration for traffic classes that are cut-through.
      
      Since cut-through forwarding has no UAPI to control it, and the driver
      enables it based on the mantra "if we can, then why not", the strategy
      is to alter vsc9959_cut_through_fwd() to take into consideration which
      tc's have oversize frame dropping enabled, and disable cut-through for
      them. Then, from vsc9959_tas_guard_bands_update(), we re-trigger the
      cut-through determination process.
      
      There are 2 strategies for vsc9959_cut_through_fwd() to determine
      whether a tc has oversized dropping enabled or not. One is to keep a bit
      mask of traffic classes per port, and the other is to read back from the
      hardware registers (a non-zero value of QSYS_QMAXSDU_CFG_* means the
      feature is enabled). We choose reading back from registers, because
      struct ocelot_port is shared with drivers (ocelot, seville) that don't
      support either cut-through nor tc-taprio, and we don't have a felix
      specific extension of struct ocelot_port. Furthermore, reading registers
      from the Felix hardware is quite cheap, since they are memory-mapped.
      
      Fixes: 55a515b1 ("net: dsa: felix: drop oversized frames with tc-taprio instead of hanging the port")
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      843794bb
    • V
      net: dsa: felix: tc-taprio intervals smaller than MTU should send at least one packet · 11afdc65
      Vladimir Oltean 提交于
      The blamed commit broke tc-taprio schedules such as this one:
      
      tc qdisc replace dev $swp1 root taprio \
              num_tc 8 \
              map 0 1 2 3 4 5 6 7 \
              queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 \
              base-time 0 \
              sched-entry S 0x7f 990000 \
              sched-entry S 0x80  10000 \
              flags 0x2
      
      because the gate entry for TC 7 (S 0x80 10000 ns) now has a static guard
      band added earlier than its 'gate close' event, such that packet
      overruns won't occur in the worst case of the largest packet possible.
      
      Since guard bands are statically determined based on the per-tc
      QSYS_QMAXSDU_CFG_* with a fallback on the port-based QSYS_PORT_MAX_SDU,
      we need to discuss what happens with TC 7 depending on kernel version,
      since the driver, prior to commit 55a515b1 ("net: dsa: felix: drop
      oversized frames with tc-taprio instead of hanging the port"), did not
      touch QSYS_QMAXSDU_CFG_*, and therefore relied on QSYS_PORT_MAX_SDU.
      
      1 (before vsc9959_tas_guard_bands_update): QSYS_PORT_MAX_SDU defaults to
        1518, and at gigabit this introduces a static guard band (independent
        of packet sizes) of 12144 ns, plus QSYS::HSCH_MISC_CFG.FRM_ADJ (bit
        time of 20 octets => 160 ns). But this is larger than the time window
        itself, of 10000 ns. So, the queue system never considers a frame with
        TC 7 as eligible for transmission, since the gate practically never
        opens, and these frames are forever stuck in the TX queues and hang
        the port.
      
      2 (after vsc9959_tas_guard_bands_update): Under the sole goal of
        enabling oversized frame dropping, we make an effort to set
        QSYS_QMAXSDU_CFG_7 to 1230 bytes. But QSYS_QMAXSDU_CFG_7 plays
        one more role, which we did not take into account: per-tc static guard
        band, expressed in L2 byte time (auto-adjusted for FCS and L1 overhead).
        There is a discrepancy between what the driver thinks (that there is
        no guard band, and 100% of min_gate_len[tc] is available for egress
        scheduling) and what the hardware actually does (crops the equivalent
        of QSYS_QMAXSDU_CFG_7 ns out of min_gate_len[tc]). In practice, this
        means that the hardware thinks it has exactly 0 ns for scheduling tc 7.
      
      In both cases, even minimum sized Ethernet frames are stuck on egress
      rather than being considered for scheduling on TC 7, even if they would
      fit given a proper configuration. Considering the current situation,
      with vsc9959_tas_guard_bands_update(), frames between 60 octets and 1230
      octets in size are not eligible for oversized dropping (because they are
      smaller than QSYS_QMAXSDU_CFG_7), but won't be considered as eligible
      for scheduling either, because the min_gate_len[7] (10000 ns) minus the
      guard band determined by QSYS_QMAXSDU_CFG_7 (1230 octets * 8 ns per
      octet == 9840 ns) minus the guard band auto-added for L1 overhead by
      QSYS::HSCH_MISC_CFG.FRM_ADJ (20 octets * 8 ns per octet == 160 octets)
      leaves 0 ns for scheduling in the queue system proper.
      
      Investigating the hardware behavior, it becomes apparent that the queue
      system needs precisely 33 ns of 'gate open' time in order to consider a
      frame as eligible for scheduling to a tc. So the solution to this
      problem is to amend vsc9959_tas_guard_bands_update(), by giving the
      per-tc guard bands less space by exactly 33 ns, just enough for one
      frame to be scheduled in that interval. This allows the queue system to
      make forward progress for that port-tc, and prevents it from hanging.
      
      Fixes: 297c4de6 ("net: dsa: felix: re-enable TAS guard band mode")
      Reported-by: NXiaoliang Yang <xiaoliang.yang_1@nxp.com>
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      11afdc65
    • J
      net: dsa: LAN9303: Add basic support for LAN9354 · 13248b97
      Jerry Ray 提交于
      Adding support for the LAN9354 device by allowing it to use
      the LAN9303 DSA driver.  These devices have the same underlying
      access and control methods and from a feature set point of view
      the LAN9354 is a superset of the LAN9303.
      
      The MDIO access method has been tested on a SAMA5D3-EDS board
      with a LAN9354 RMII daughter card.
      
      While the SPI access method should also be the same, it has not
      been tested and as such is not included at this time.
      Signed-off-by: NJerry Ray <jerry.ray@microchip.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      13248b97
    • J
      net: dsa: LAN9303: Add early read to sync · 732f374e
      Jerry Ray 提交于
      Add initial BYTE_ORDER read to sync the 32-bit accesses over the 16-bit
      mdio bus to improve driver robustness.
      
      The lan9303 expects two mdio read transactions back-to-back to read a
      32-bit register. The first read transaction causes the other half of the
      32-bit register to get latched.  The subsequent read returns the latched
      second half of the 32-bit read. The BYTE_ORDER register is an exception to
      this rule. As it is a constant value, there is no need to latch the second
      half. We read this register first in case there were reads during the boot
      loader process that might have occurred prior to this driver taking over
      ownership of accessing this device.
      
      This patch has been tested on the SAMA5D3-EDS with a LAN9303 RMII daughter
      card.
      Signed-off-by: NJerry Ray <jerry.ray@microchip.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      732f374e
    • R
      net: dsa: microchip: add regmap_range for KSZ9896 chip · 6674e7fd
      Romain Naour 提交于
      Add register validation for KSZ9896.
      Signed-off-by: NRomain Naour <romain.naour@skf.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      6674e7fd
    • R
      net: dsa: microchip: ksz9477: remove 0x033C and 0x033D addresses from regmap_access_tables · 3a8b8ea6
      Romain Naour 提交于
      According to the KSZ9477S datasheet, there is no global register
      at 0x033C and 0x033D addresses.
      Signed-off-by: NRomain Naour <romain.naour@skf.com>
      Cc: Oleksij Rempel <o.rempel@pengutronix.de>
      Tested-by: NOleksij Rempel <o.rempel@pengutronix.de>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3a8b8ea6
    • R
      net: dsa: microchip: add KSZ9896 to KSZ9477 I2C driver · 13767525
      Romain Naour 提交于
      Add support for the KSZ9896 6-port Gigabit Ethernet Switch to the
      ksz9477 driver. The KSZ9896 supports both SPI (already in) and I2C.
      Signed-off-by: NRomain Naour <romain.naour@skf.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      13767525
    • R
      net: dsa: microchip: add KSZ9896 switch support · 2eb3ff3c
      Romain Naour 提交于
      Add support for the KSZ9896 6-port Gigabit Ethernet Switch to the
      ksz9477 driver.
      
      Although the KSZ9896 is already listed in the device tree binding
      documentation since a1c0ed24 (dt-bindings: net: dsa: document
      additional Microchip KSZ9477 family switches) the chip id
      (0x00989600) is not recognized by ksz_switch_detect() and rejected
      by the driver.
      
      The KSZ9896 is similar to KSZ9897 but has only one configurable
      MII/RMII/RGMII/GMII cpu port.
      Signed-off-by: NRomain Naour <romain.naour@skf.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      2eb3ff3c
  3. 06 9月, 2022 1 次提交
  4. 05 9月, 2022 3 次提交
  5. 03 9月, 2022 1 次提交
  6. 01 9月, 2022 1 次提交
  7. 31 8月, 2022 17 次提交
  8. 29 8月, 2022 1 次提交
    • S
      net: dsa: xrs700x: Use irqsave variant for u64 stats update · 3f8ae9fe
      Sebastian Andrzej Siewior 提交于
      xrs700x_read_port_counters() updates the stats from a worker using the
      u64_stats_update_begin() version. This is okay on 32-UP since on the
      reader side preemption is disabled.
      On 32bit-SMP the writer can be preempted by the reader at which point
      the reader will spin on the seqcount until writer continues and
      completes the update.
      
      Assigning the mib_mutex mutex to the underlying seqcount would ensure
      proper synchronisation. The API for that on the u64_stats_init() side
      isn't available. Since it is the only user, just use disable interrupts
      during the update.
      
      Use u64_stats_update_begin_irqsave() on the writer side to ensure an
      uninterrupted update.
      
      Fixes: ee00b24f ("net: dsa: add Arrow SpeedChips XRS700x driver")
      Cc: Andrew Lunn <andrew@lunn.ch>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: George McCollister <george.mccollister@gmail.com>
      Cc: Vivien Didelot <vivien.didelot@gmail.com>
      Cc: Vladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Acked-by: NGeorge McCollister <george.mccollister@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3f8ae9fe