1. 14 8月, 2021 1 次提交
  2. 05 8月, 2021 1 次提交
  3. 04 8月, 2021 1 次提交
  4. 28 7月, 2021 4 次提交
  5. 22 6月, 2021 2 次提交
    • F
      net: fec: add ndo_select_queue to fix TX bandwidth fluctuations · 52c4a1a8
      Fugang Duan 提交于
      As we know that AVB is enabled by default, and the ENET IP design is
      queue 0 for best effort, queue 1&2 for AVB Class A&B. Bandwidth of each
      queue 1&2 set in driver is 50%, TX bandwidth fluctuated when selecting
      tx queues randomly with FEC_QUIRK_HAS_AVB quirk available.
      
      This patch adds ndo_select_queue callback to select queues for
      transmitting to fix this issue. It will always return queue 0 if this is
      not a vlan packet, and return queue 1 or 2 based on priority of vlan
      packet.
      
      You may complain that in fact we only use single queue for trasmitting
      if we are not targeted to VLAN. Yes, but seems we have no choice, since
      AVB is enabled when the driver probed, we can't switch this feature
      dynamicly. After compare multiple queues to single queue, TX throughput
      almost no improvement.
      
      One way we can implemet is to configure the driver to multiple queues
      with Round-robin scheme by default. Then add ndo_setup_tc callback to
      enable/disable AVB feature for users. Unfortunately, ENET AVB IP seems
      not follow the standard 802.1Qav spec. We only can program
      DMAnCFG[IDLE_SLOPE] field to calculate bandwidth fraction. And idle
      slope is restricted to certain valus (a total of 19). It's far away from
      CBS QDisc implemented in Linux TC framework. If you strongly suggest to do
      this, I think we only can support limited numbers of bandwidth and reject
      others, but it's really urgly and wried.
      
      With this patch, VLAN tagged packets route to queue 0/1/2 based on vlan
      priority; VLAN untagged packets route to queue 0.
      Tested-by: NFrieder Schrempf <frieder.schrempf@kontron.de>
      Reported-by: NFrieder Schrempf <frieder.schrempf@kontron.de>
      Signed-off-by: NFugang Duan <fugang.duan@nxp.com>
      Signed-off-by: NJoakim Zhang <qiangqing.zhang@nxp.com>
      Reported-by: Nkernel test robot <lkp@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      52c4a1a8
    • J
      net: fec: add FEC_QUIRK_HAS_MULTI_QUEUES represents i.MX6SX ENET IP · 471ff445
      Joakim Zhang 提交于
      Frieder Schrempf reported a TX throuthput issue [1], it happens quite often
      that the measured bandwidth in TX direction drops from its expected/nominal
      value to something like ~50% (for 100M) or ~67% (for 1G) connections.
      
      [1] https://lore.kernel.org/linux-arm-kernel/421cc86c-b66f-b372-32f7-21e59f9a98bc@kontron.de/
      
      The issue becomes clear after digging into it, Net core would select
      queues when transmitting packets. Since FEC have not impletemented
      ndo_select_queue callback yet, so it will call netdev_pick_tx to select
      queues randomly.
      
      For i.MX6SX ENET IP with AVB support, driver default enables this
      feature. According to the setting of QOS/RCMRn/DMAnCFG registers, AVB
      configured to Credit-based scheme, 50% bandwidth of each queue 1&2.
      
      With below tests let me think more:
      1) With FEC_QUIRK_HAS_AVB quirk, can reproduce TX bandwidth fluctuations issue.
      2) Without FEC_QUIRK_HAS_AVB quirk, can't reproduce TX bandwidth fluctuations issue.
      
      The related difference with or w/o FEC_QUIRK_HAS_AVB quirk is that, whether we
      program FTYPE field of TxBD or not. As I describe above, AVB feature is
      enabled by default. With FEC_QUIRK_HAS_AVB quirk, frames in queue 0
      marked as non-AVB, and frames in queue 1&2 marked as AVB Class A&B. It's
      unreasonable if frames in queue 1&2 are not required to be time-sensitive.
      So when Net core select tx queues ramdomly, Credit-based scheme would work
      and lead to TX bandwidth fluctuated. On the other hand, w/o
      FEC_QUIRK_HAS_AVB quirk, frames in queue 1&2 are all marked as non-AVB, so
      Credit-based scheme would not work.
      
      Till now, how can we fix this TX throughput issue? Yes, please remove
      FEC_QUIRK_HAS_AVB quirk if you suffer it from time-nonsensitive networking.
      However, this quirk is used to indicate i.MX6SX, other setting depends
      on it. So this patch adds a new quirk FEC_QUIRK_HAS_MULTI_QUEUES to
      represent i.MX6SX, it is safe for us remove FEC_QUIRK_HAS_AVB quirk
      now.
      
      FEC_QUIRK_HAS_AVB quirk is set by default in the driver, and users may
      not know much about driver details, they would waste effort to find the
      root cause, that is not we want. The following patch is a implementation
      to fix it and users don't need to modify the driver.
      Tested-by: NFrieder Schrempf <frieder.schrempf@kontron.de>
      Reported-by: NFrieder Schrempf <frieder.schrempf@kontron.de>
      Signed-off-by: NJoakim Zhang <qiangqing.zhang@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      471ff445
  6. 13 5月, 2021 2 次提交
  7. 21 4月, 2021 1 次提交
  8. 14 4月, 2021 1 次提交
    • M
      of: net: pass the dst buffer to of_get_mac_address() · 83216e39
      Michael Walle 提交于
      of_get_mac_address() returns a "const void*" pointer to a MAC address.
      Lately, support to fetch the MAC address by an NVMEM provider was added.
      But this will only work with platform devices. It will not work with
      PCI devices (e.g. of an integrated root complex) and esp. not with DSA
      ports.
      
      There is an of_* variant of the nvmem binding which works without
      devices. The returned data of a nvmem_cell_read() has to be freed after
      use. On the other hand the return of_get_mac_address() points to some
      static data without a lifetime. The trick for now, was to allocate a
      device resource managed buffer which is then returned. This will only
      work if we have an actual device.
      
      Change it, so that the caller of of_get_mac_address() has to supply a
      buffer where the MAC address is written to. Unfortunately, this will
      touch all drivers which use the of_get_mac_address().
      
      Usually the code looks like:
      
        const char *addr;
        addr = of_get_mac_address(np);
        if (!IS_ERR(addr))
          ether_addr_copy(ndev->dev_addr, addr);
      
      This can then be simply rewritten as:
      
        of_get_mac_address(np, ndev->dev_addr);
      
      Sometimes is_valid_ether_addr() is used to test the MAC address.
      of_get_mac_address() already makes sure, it just returns a valid MAC
      address. Thus we can just test its return code. But we have to be
      careful if there are still other sources for the MAC address before the
      of_get_mac_address(). In this case we have to keep the
      is_valid_ether_addr() call.
      
      The following coccinelle patch was used to convert common cases to the
      new style. Afterwards, I've manually gone over the drivers and fixed the
      return code variable: either used a new one or if one was already
      available use that. Mansour Moufid, thanks for that coccinelle patch!
      
      <spml>
      @a@
      identifier x;
      expression y, z;
      @@
      - x = of_get_mac_address(y);
      + x = of_get_mac_address(y, z);
        <...
      - ether_addr_copy(z, x);
        ...>
      
      @@
      identifier a.x;
      @@
      - if (<+... x ...+>) {}
      
      @@
      identifier a.x;
      @@
        if (<+... x ...+>) {
            ...
        }
      - else {}
      
      @@
      identifier a.x;
      expression e;
      @@
      - if (<+... x ...+>@e)
      -     {}
      - else
      + if (!(e))
            {...}
      
      @@
      expression x, y, z;
      @@
      - x = of_get_mac_address(y, z);
      + of_get_mac_address(y, z);
        ... when != x
      </spml>
      
      All drivers, except drivers/net/ethernet/aeroflex/greth.c, were
      compile-time tested.
      Suggested-by: NAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: NMichael Walle <michael@walle.cc>
      Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      83216e39
  9. 10 4月, 2021 1 次提交
  10. 03 2月, 2021 1 次提交
  11. 27 1月, 2021 1 次提交
    • L
      net: fec: Fix temporary RMII clock reset on link up · c730ab42
      Laurent Badel 提交于
      fec_restart() does a hard reset of the MAC module when the link status
      changes to up. This temporarily resets the R_CNTRL register which controls
      the MII mode of the ENET_OUT clock. In the case of RMII, the clock
      frequency momentarily drops from 50MHz to 25MHz until the register is
      reconfigured. Some link partners do not tolerate this glitch and
      invalidate the link causing failure to establish a stable link when using
      PHY polling mode. Since as per IEEE802.3 the criteria for link validity
      are PHY-specific, what the partner should tolerate cannot be assumed, so
      avoid resetting the MII clock by using software reset instead of hardware
      reset when the link is up. This is generally relevant only if the SoC
      provides the clock to an external PHY and the PHY is configured for RMII.
      Signed-off-by: NLaurent Badel <laurentbadel@eaton.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      c730ab42
  12. 23 1月, 2021 1 次提交
  13. 17 11月, 2020 1 次提交
    • Z
      net: fec: Fix reference count leak in fec series ops · da875fa5
      Zhang Qilong 提交于
      pm_runtime_get_sync() will increment pm usage at first and it will
      resume the device later. If runtime of the device has error or
      device is in inaccessible state(or other error state), resume
      operation will fail. If we do not call put operation to decrease
      the reference, it will result in reference count leak. Moreover,
      this device cannot enter the idle state and always stay busy or other
      non-idle state later. So we fixed it by replacing it with
      pm_runtime_resume_and_get.
      
      Fixes: 8fff755e ("net: fec: Ensure clocks are enabled while using mdio bus")
      Signed-off-by: NZhang Qilong <zhangqilong3@huawei.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      da875fa5
  14. 30 10月, 2020 1 次提交
  15. 13 10月, 2020 1 次提交
    • M
      net: fec: Fix phy_device lookup for phy_reset_after_clk_enable() · 64a632da
      Marek Vasut 提交于
      The phy_reset_after_clk_enable() is always called with ndev->phydev,
      however that pointer may be NULL even though the PHY device instance
      already exists and is sufficient to perform the PHY reset.
      
      This condition happens in fec_open(), where the clock must be enabled
      first, then the PHY must be reset, and then the PHY IDs can be read
      out of the PHY.
      
      If the PHY still is not bound to the MAC, but there is OF PHY node
      and a matching PHY device instance already, use the OF PHY node to
      obtain the PHY device instance, and then use that PHY device instance
      when triggering the PHY reset.
      
      Fixes: 1b0a83ac ("net: fec: add phy_reset_after_clk_enable() support")
      Signed-off-by: NMarek Vasut <marex@denx.de>
      Cc: Christoph Niedermaier <cniedermaier@dh-electronics.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: NXP Linux Team <linux-imx@nxp.com>
      Cc: Richard Leitner <richard.leitner@skidata.com>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      64a632da
  16. 09 10月, 2020 1 次提交
  17. 08 9月, 2020 1 次提交
  18. 15 8月, 2020 1 次提交
  19. 17 7月, 2020 1 次提交
  20. 13 7月, 2020 1 次提交
    • A
      net: fec: Set max MTU size to allow the MTU to be changed · 59193053
      Andrew Lunn 提交于
      The FEC allocates 2K buffers, but looses some of it due to
      alignment. It can however support an MTU bigger than the default. This
      is particularly interesting when used in combination with Ethernet
      switches supporting DSA, which have extra headers. The DSA core will
      try to increase the MTU to support these extra headers. If the max
      size defaults to that of standard Ethernet we get a warning. By
      setting the max to what the driver actually supports, we avoid this
      warning.
      Signed-off-by: NAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      59193053
  21. 08 7月, 2020 1 次提交
    • T
      net: ethernet: fec: prevent tx starvation under high rx load · 7cdaa4cc
      Tobias Waldekranz 提交于
      In the ISR, we poll the event register for the queues in need of
      service and then enter polled mode. After this point, the event
      register will never be read again until we exit polled mode.
      
      In a scenario where a UDP flow is routed back out through the same
      interface, i.e. "router-on-a-stick" we'll typically only see an rx
      queue event initially. Once we start to process the incoming flow
      we'll be locked polled mode, but we'll never clean the tx rings since
      that event is never caught.
      
      Eventually the netdev watchdog will trip, causing all buffers to be
      dropped and then the process starts over again.
      
      Rework the NAPI poll to keep trying to consome the entire budget as
      long as new events are coming in, making sure to service all rx/tx
      queues, in priority order, on each pass.
      
      Fixes: 4d494cdc ("net: fec: change data structure to support multiqueue")
      Signed-off-by: NTobias Waldekranz <tobias@waldekranz.com>
      Tested-by: NFugang Duan <fugang.duan@nxp.com>
      Reviewed-by: NFugang Duan <fugang.duan@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7cdaa4cc
  22. 19 6月, 2020 1 次提交
  23. 02 6月, 2020 1 次提交
  24. 27 5月, 2020 1 次提交
    • F
      net: ethernet: fec: move GPR register offset and bit into DT · 8a448bf8
      Fugang Duan 提交于
      The commit da722186 (net: fec: set GPR bit on suspend by DT
      configuration) set the GPR reigster offset and bit in driver for
      wake on lan feature.
      
      But it introduces two issues here:
      - one SOC has two instances, they have different bit
      - different SOCs may have different offset and bit
      
      So to support wake-on-lan feature on other i.MX platforms, it should
      configure the GPR reigster offset and bit from DT.
      
      So the patch is to improve the commit da722186 (net: fec: set GPR
      bit on suspend by DT configuration) to support multiple ethernet
      instances on i.MX series.
      
      v2:
       * switch back to store the quirks bitmask in driver_data
      v3:
       * suggested by Sascha Hauer, use a struct fec_devinfo for
         abstracting differences between different hardware variants,
         it can give more freedom to describe the differences.
      Signed-off-by: NFugang Duan <fugang.duan@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      8a448bf8
  25. 03 5月, 2020 1 次提交
    • A
      net: ethernet: fec: Replace interrupt driven MDIO with polled IO · f166f890
      Andrew Lunn 提交于
      Measurements of the MDIO bus have shown that driving the MDIO bus
      using interrupts is slow. Back to back MDIO transactions take about
      90us, with 25us spent performing the transaction, and the remainder of
      the time the bus is idle.
      
      Replacing the completion interrupt with polled IO results in back to
      back transactions of 40us. The polling loop waiting for the hardware
      to complete the transaction takes around 28us. Which suggests
      interrupt handling has an overhead of 50us, and polled IO nearly
      halves this overhead, and doubles the MDIO performance.
      
      Care has to be taken when setting the MII_SPEED register, or it can
      trigger an MII event> That then upsets the polling, due to an
      unexpected pending event.
      Suggested-by: NChris Heally <cphealy@gmail.com>
      Signed-off-by: NAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f166f890
  26. 01 5月, 2020 1 次提交
  27. 30 4月, 2020 1 次提交
  28. 29 4月, 2020 1 次提交
    • A
      net: ethernet: fec: Prevent MII event after MII_SPEED write · 790ab249
      Andrew Lunn 提交于
      The change to polled IO for MDIO completion assumes that MII events
      are only generated for MDIO transactions. However on some SoCs writing
      to the MII_SPEED register can also trigger an MII event. As a result,
      the next MDIO read has a pending MII event, and immediately reads the
      data registers before it contains useful data. When the read does
      complete, another MII event is posted, which results in the next read
      also going wrong, and the cycle continues.
      
      By writing 0 to the MII_DATA register before writing to the speed
      register, this MII event for the MII_SPEED is suppressed, and polled
      IO works as expected.
      
      Fixes: 29ae6bd1 ("net: ethernet: fec: Replace interrupt driven MDIO with polled IO")
      Reported-by: NAndy Duan <fugang.duan@nxp.com>
      Suggested-by: NAndy Duan <fugang.duan@nxp.com>
      Signed-off-by: NAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      790ab249
  29. 21 4月, 2020 3 次提交
  30. 08 4月, 2020 1 次提交
  31. 13 3月, 2020 1 次提交
  32. 12 3月, 2020 1 次提交
  33. 04 3月, 2020 1 次提交