1. 14 4月, 2021 3 次提交
    • O
      net: stmmac: introduce dma_recycle_rx_skbufs for stmmac_reinit_rx_buffers · 80f573c9
      Ong Boon Leong 提交于
      Rearrange RX buffer page_pool recycling logics into dma_recycle_rx_skbufs,
      so that we prepare stmmac_reinit_rx_buffers() for XSK pool expansion.
      Signed-off-by: NOng Boon Leong <boon.leong.ong@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      80f573c9
    • O
      net: stmmac: rearrange RX buffer allocation and free functions · 4298255f
      Ong Boon Leong 提交于
      This patch restructures the per RX queue buffer allocation from page_pool
      to stmmac_alloc_rx_buffers().
      
      We also rearrange dma_free_rx_skbufs() so that it can be used in
      init_dma_rx_desc_rings() during freeing of RX buffer in the event of
      page_pool allocation failure to replace the more efficient method earlier.
      The replacement is needed to make the RX buffer alloc and free method
      scalable to XDP ZC xsk_pool alloc and free later.
      Signed-off-by: NOng Boon Leong <boon.leong.ong@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4298255f
    • 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
  2. 08 4月, 2021 1 次提交
  3. 07 4月, 2021 1 次提交
  4. 04 4月, 2021 6 次提交
    • O
      net: stmmac: Add support for XDP_REDIRECT action · 8b278a5b
      Ong Boon Leong 提交于
      This patch adds the support of XDP_REDIRECT to another remote cpu for
      further action. It also implements ndo_xdp_xmit ops, enabling the driver
      to transmit packets forwarded to it by XDP program running on another
      interface.
      
      This patch has been tested using "xdp_redirect_cpu" for XDP_REDIRECT
      + drop testing. It also been tested with "xdp_redirect" sample app
      which can be used to exercise ndo_xdp_xmit ops. The burst traffics are
      generated using pktgen_sample03_burst_single_flow.sh in samples/pktgen
      directory.
      
      v4: Move xdp_do_flush() processing into stmmac_finalize_xdp_rx() and
          combined the XDP verdict of XDP TX and REDIRECT together.
      
      v3: Added 'nq->trans_start = jiffies' to avoid TX time-out as we are
          sharing TX queue between slow path and XDP. Thanks to Jakub Kicinski
          for point out.
      Signed-off-by: NOng Boon Leong <boon.leong.ong@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      8b278a5b
    • O
      net: stmmac: Add support for XDP_TX action · be8b38a7
      Ong Boon Leong 提交于
      This patch adds support for XDP_TX action which enables XDP program to
      transmit back received frames.
      
      This patch has been tested with the "xdp2" app located in samples/bpf
      dir. The DUT receives burst traffic packet generated using pktgen script
      'pktgen_sample03_burst_single_flow.sh'.
      
      v4: Moved stmmac_tx_timer_arm() to be done once at the end of NAPI RX.
          Fixed stmmac_xdp_xmit_back() to return STMMAC_XDP_CONSUMED if
          XDP buffer to frame conversion fails. Thanks to Jakub's input.
      
      v3: Added 'nq->trans_start = jiffies' to avoid TX time-out as we are
          sharing TX queue between slow path and XDP. Thanks to Jakub Kicinski
          for pointing out.
      Signed-off-by: NOng Boon Leong <boon.leong.ong@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      be8b38a7
    • O
      net: stmmac: Add initial XDP support · 5fabb012
      Ong Boon Leong 提交于
      This patch adds the initial XDP support to stmmac driver. It supports
      XDP_PASS, XDP_DROP and XDP_ABORTED actions. Upcoming patches will add
      support for XDP_TX and XDP_REDIRECT.
      
      To support XDP headroom, this patch adds page_offset into RX buffer and
      change the dma_sync_single_for_device|cpu(). The DMA address used for
      RX operation are changed to take into page_offset too. As page_pool
      can handle dma_sync_single_for_device() on behalf of driver with
      PP_FLAG_DMA_SYNC_DEV flag, we skip doing that in stmmac driver.
      
      Current stmmac driver supports split header support (SPH) in RX but
      the flexibility of splitting header and payload at different position
      makes it very complex to be supported for XDP processing. In addition,
      jumbo frame is not supported in XDP to keep the initial codes simple.
      
      This patch has been tested with the sample app "xdp1" located in
      samples/bpf directory for both SKB and Native (XDP) mode. The burst
      traffic generated using pktgen_sample03_burst_single_flow.sh in
      samples/pktgen directory.
      
      Changes in v3:
       - factor in xdp header and tail adjustment done by XDP program.
         Thanks to Jakub Kicinski for pointing out the gap in v2.
      
      Changes in v2:
       - fix for "warning: variable 'len' set but not used" reported by lkp.
      Reported-by: Nkernel test robot <lkp@intel.com>
      Signed-off-by: NOng Boon Leong <boon.leong.ong@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      5fabb012
    • O
      net: stmmac: arrange Tx tail pointer update to stmmac_flush_tx_descriptors · d96febed
      Ong Boon Leong 提交于
      This patch organizes TX tail pointer update into a new function called
      stmmac_flush_tx_descriptors() so that we can reuse it in stmmac_xmit(),
      stmmac_tso_xmit() and up-coming XDP implementation.
      
      Changes to v2:
       - Fix for warning: unused variable ‘desc_size’
         https://patchwork.hopto.org/static/nipa/457321/12170149/build_32bit/stderrSigned-off-by: NOng Boon Leong <boon.leong.ong@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d96febed
    • O
      net: stmmac: make SPH enable/disable to be configurable · d08d32d1
      Ong Boon Leong 提交于
      SPH functionality splits header and payload according to split mode and
      offsef fields (SPLM and SPLOFST). It is beneficials for Linux network
      stack RX processing however it adds a lot of complexity in XDP
      processing.
      
      So, this patch makes the split-header (SPH) capability of the controller
      is stored in "priv->sph_cap" and the enabling/disabling of SPH is decided
      by "priv->sph".
      
      This is to prepare initial XDP enabling for stmmac to disable the use of
      SPH whenever XDP is enabled.
      Signed-off-by: NOng Boon Leong <boon.leong.ong@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d08d32d1
    • O
      net: stmmac: set IRQ affinity hint for multi MSI vectors · 8deec94c
      Ong Boon Leong 提交于
      Certain platform likes Intel mGBE has independent hardware IRQ resources
      for TX and RX DMA operation. In preparation to support XDP TX, we add IRQ
      affinity hint to group both RX and TX queue of the same queue ID to the
      same CPU.
      
      Changes in v2:
       - IRQ affinity hint need to set to null before IRQ is released.
         Thanks to issue reported by Song, Yoong Siang.
      Reported-by: NSong, Yoong Siang <yoong.siang.song@intel.com>
      Signed-off-by: NOng Boon Leong <boon.leong.ong@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      8deec94c
  5. 02 4月, 2021 2 次提交
  6. 01 4月, 2021 2 次提交
  7. 31 3月, 2021 1 次提交
  8. 30 3月, 2021 1 次提交
  9. 29 3月, 2021 1 次提交
  10. 27 3月, 2021 1 次提交
    • M
      net: stmmac: Fix kernel panic due to NULL pointer dereference of fpe_cfg · 63c173ff
      Mohammad Athari Bin Ismail 提交于
      In this patch, "net: stmmac: support FPE link partner hand-shaking
      procedure", priv->plat->fpe_cfg wouldn`t be "devm_kzalloc"ed if
      dma_cap->frpsel is 0 (Flexible Rx Parser is not supported in SoC) in
      tc_init(). So, fpe_cfg will be remain as NULL and accessing it will cause
      kernel panic.
      
      To fix this, move the "devm_kzalloc"ing of priv->plat->fpe_cfg before
      dma_cap->frpsel checking in tc_init(). Additionally, checking of
      priv->dma_cap.fpesel is added before calling stmmac_fpe_link_state_handle()
      as only FPE supported SoC is allowed to call the function.
      
      Below is the kernel panic dump reported by Marek Szyprowski
      <m.szyprowski@samsung.com>:
      
      meson8b-dwmac ff3f0000.ethernet eth0: PHY [0.0:00] driver [RTL8211F Gigabit Ethernet] (irq=35)
      meson8b-dwmac ff3f0000.ethernet eth0: No Safety Features support found
      meson8b-dwmac ff3f0000.ethernet eth0: PTP not supported by HW
      meson8b-dwmac ff3f0000.ethernet eth0: configuring for phy/rgmii link mode
      Unable to handle kernel NULL pointer dereference at virtual address 0000000000000001
      Mem abort info:
      ...
      user pgtable: 4k pages, 48-bit VAs, pgdp=00000000044eb000
      [0000000000000001] pgd=0000000000000000, p4d=0000000000000000
      Internal error: Oops: 96000004 [#1] PREEMPT SMP
      Modules linked in: dw_hdmi_i2s_audio dw_hdmi_cec meson_gxl realtek meson_gxbb_wdt snd_soc_meson_axg_sound_card dwmac_generic axg_audio meson_dw_hdmi crct10dif_ce snd_soc_meson_card_utils snd_soc_meson_axg_tdmout panfrost rc_odroid gpu_sched reset_meson_audio_arb meson_ir snd_soc_meson_g12a_tohdmitx snd_soc_meson_axg_frddr sclk_div clk_phase snd_soc_meson_codec_glue dwmac_meson8b snd_soc_meson_axg_fifo stmmac_platform meson_rng meson_drm stmmac rtc_meson_vrtc rng_core meson_canvas pwm_meson dw_hdmi mdio_mux_meson_g12a pcs_xpcs snd_soc_meson_axg_tdm_interface snd_soc_meson_axg_tdm_formatter nvmem_meson_efuse display_connector
      CPU: 1 PID: 7 Comm: kworker/u8:0 Not tainted 5.12.0-rc4-next-20210325+
      Hardware name: Hardkernel ODROID-C4 (DT)
      Workqueue: events_power_efficient phylink_resolve
      pstate: 20400009 (nzCv daif +PAN -UAO -TCO BTYPE=--)
      pc : stmmac_mac_link_up+0x14c/0x348 [stmmac]
      lr : stmmac_mac_link_up+0x284/0x348 [stmmac] ...
      Call trace:
       stmmac_mac_link_up+0x14c/0x348 [stmmac]
       phylink_resolve+0x104/0x420
       process_one_work+0x2a8/0x718
       worker_thread+0x48/0x460
       kthread+0x134/0x160
       ret_from_fork+0x10/0x18
      Code: b971ba60 350007c0 f958c260 f9402000 (39400401)
      ---[ end trace 0c9deb6c510228aa ]---
      
      Fixes: 5a558611 ("net: stmmac: support FPE link partner hand-shaking
      procedure")
      Reported-by: NMarek Szyprowski <m.szyprowski@samsung.com>
      Signed-off-by: NMohammad Athari Bin Ismail <mohammad.athari.ismail@intel.com>
      Tested-by: NMarek Szyprowski <m.szyprowski@samsung.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      63c173ff
  11. 26 3月, 2021 5 次提交
  12. 25 3月, 2021 2 次提交
  13. 23 3月, 2021 1 次提交
    • W
      net: stmmac: platform: fix build error with !CONFIG_PM_SLEEP · 7ec05a60
      Wei Yongjun 提交于
      Get rid of the CONFIG_PM_SLEEP ifdefery to fix the build error
      and use __maybe_unused for the suspend()/resume() hooks to avoid
      build warning:
      
      drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c:769:21:
       error: 'stmmac_runtime_suspend' undeclared here (not in a function); did you mean 'stmmac_suspend'?
        769 |  SET_RUNTIME_PM_OPS(stmmac_runtime_suspend, stmmac_runtime_resume, NULL)
            |                     ^~~~~~~~~~~~~~~~~~~~~~
      ./include/linux/pm.h:342:21: note: in definition of macro 'SET_RUNTIME_PM_OPS'
        342 |  .runtime_suspend = suspend_fn, \
            |                     ^~~~~~~~~~
      drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c:769:45:
       error: 'stmmac_runtime_resume' undeclared here (not in a function)
        769 |  SET_RUNTIME_PM_OPS(stmmac_runtime_suspend, stmmac_runtime_resume, NULL)
            |                                             ^~~~~~~~~~~~~~~~~~~~~
      ./include/linux/pm.h:343:20: note: in definition of macro 'SET_RUNTIME_PM_OPS'
        343 |  .runtime_resume = resume_fn, \
            |                    ^~~~~~~~~
      
      Fixes: 5ec55823 ("net: stmmac: add clocks management for gmac driver")
      Reported-by: NHulk Robot <hulkci@huawei.com>
      Signed-off-by: NWei Yongjun <weiyongjun1@huawei.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7ec05a60
  14. 20 3月, 2021 1 次提交
    • C
      net: stmmac: dwmac-sun8i: Provide TX and RX fifo sizes · 014dfa26
      Corentin Labbe 提交于
      MTU cannot be changed on dwmac-sun8i. (ip link set eth0 mtu xxx returning EINVAL)
      This is due to tx_fifo_size being 0, since this value is used to compute valid
      MTU range.
      Like dwmac-sunxi (with commit 806fd188 ("net: stmmac: dwmac-sunxi: Provide TX and RX fifo sizes"))
      dwmac-sun8i need to have tx and rx fifo sizes set.
      I have used values from datasheets.
      After this patch, setting a non-default MTU (like 1000) value works and network is still useable.
      
      Tested-on: sun8i-h3-orangepi-pc
      Tested-on: sun8i-r40-bananapi-m2-ultra
      Tested-on: sun50i-a64-bananapi-m64
      Tested-on: sun50i-h5-nanopi-neo-plus2
      Tested-on: sun50i-h6-pine-h64
      Fixes: 9f93ac8d ("net-next: stmmac: Add dwmac-sun8i")
      Reported-by: NBelisko Marek <marek.belisko@gmail.com>
      Signed-off-by: NCorentin Labbe <clabbe@baylibre.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      014dfa26
  15. 19 3月, 2021 5 次提交
  16. 18 3月, 2021 2 次提交
    • O
      net: stmmac: add per-queue TX & RX coalesce ethtool support · db2f2842
      Ong Boon Leong 提交于
      Extending the driver to support per-queue RX and TX coalesce settings in
      order to support below commands:
      
      To show per-queue coalesce setting:-
       $ ethtool --per-queue <DEVNAME> queue_mask <MASK> --show-coalesce
      
      To set per-queue coalesce setting:-
       $ ethtool --per-queue <DEVNAME> queue_mask <MASK> --coalesce \
           [rx-usecs N] [rx-frames M] [tx-usecs P] [tx-frames Q]
      Signed-off-by: NOng Boon Leong <boon.leong.ong@intel.com>
      Acked-by: NJakub Kicinski <kuba@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      db2f2842
    • V
      net: stmmac: add timestamp correction to rid CDC sync error · 3600be5f
      Voon Weifeng 提交于
      According to Synopsis DesignWare EQoS Databook, the Clock Domain Cross
      synchronization error is introduced tue to the clock(GMII Tx/Rx clock)
      being different at the capture as compared to the PTP
      clock(clk_ptp_ref_i) that is used to generate the time.
      
      The CDC synchronization error is almost equal to 2 times the clock
      period of the PTP clock(clk_ptp_ref_i).
      
      On a Intel Tigerlake platform (with Marvell 88E2110 external PHY):
      
      Before applying this patch (with CDC synchronization error):
      ptp4l[64.044]: rms    8 max   13 freq +30877 +/-  11 delay   216 +/-   0
      ptp4l[65.047]: rms   13 max   20 freq +30869 +/-  17 delay   213 +/-   0
      ptp4l[66.050]: rms   12 max   20 freq +30857 +/-  11 delay   213 +/-   0
      ptp4l[67.052]: rms   11 max   22 freq +30849 +/-  10 delay   215 +/-   0
      ptp4l[68.055]: rms   10 max   16 freq +30853 +/-  13 delay   215 +/-   0
      ptp4l[69.057]: rms    7 max   13 freq +30848 +/-   9 delay   216 +/-   0
      ptp4l[70.060]: rms    8 max   13 freq +30846 +/-  10 delay   216 +/-   0
      ptp4l[71.063]: rms    9 max   15 freq +30836 +/-   8 delay   218 +/-   0
      
      After applying this patch (CDC syncrhonization error is taken care of):
      ptp4l[61.516]: rms  773 max  824 freq +31526 +/- 158 delay   200 +/-   0
      ptp4l[62.519]: rms  427 max  596 freq +31668 +/-  39 delay   198 +/-   0
      ptp4l[63.522]: rms  113 max  206 freq +31482 +/-  57 delay   198 +/-   0
      ptp4l[64.525]: rms   40 max   56 freq +31316 +/-  29 delay   200 +/-   0
      ptp4l[65.528]: rms   47 max   56 freq +31255 +/-  17 delay   200 +/-   0
      ptp4l[66.531]: rms   26 max   36 freq +31246 +/-   9 delay   200 +/-   0
      ptp4l[67.534]: rms   12 max   18 freq +31254 +/-  12 delay   202 +/-   0
      ptp4l[68.537]: rms    7 max   12 freq +31263 +/-  10 delay   202 +/-   0
      Signed-off-by: NVoon Weifeng <weifeng.voon@intel.com>
      Signed-off-by: NWong Vee Khee <vee.khee.wong@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3600be5f
  17. 16 3月, 2021 5 次提交