1. Nov 30, 2023
    • Stanislav Fomichev's avatar
      xsk: Add TX timestamp and TX checksum offload support · 48eb03dd
      Stanislav Fomichev authored
      
      
      This change actually defines the (initial) metadata layout
      that should be used by AF_XDP userspace (xsk_tx_metadata).
      The first field is flags which requests appropriate offloads,
      followed by the offload-specific fields. The supported per-device
      offloads are exported via netlink (new xsk-flags).
      
      The offloads themselves are still implemented in a bit of a
      framework-y fashion that's left from my initial kfunc attempt.
      I'm introducing new xsk_tx_metadata_ops which drivers are
      supposed to implement. The drivers are also supposed
      to call xsk_tx_metadata_request/xsk_tx_metadata_complete in
      the right places. Since xsk_tx_metadata_{request,_complete}
      are static inline, we don't incur any extra overhead doing
      indirect calls.
      
      The benefit of this scheme is as follows:
      - keeps all metadata layout parsing away from driver code
      - makes it easy to grep and see which drivers implement what
      - don't need any extra flags to maintain to keep track of what
        offloads are implemented; if the callback is implemented - the offload
        is supported (used by netlink reporting code)
      
      Two offloads are defined right now:
      1. XDP_TXMD_FLAGS_CHECKSUM: skb-style csum_start+csum_offset
      2. XDP_TXMD_FLAGS_TIMESTAMP: writes TX timestamp back into metadata
         area upon completion (tx_timestamp field)
      
      XDP_TXMD_FLAGS_TIMESTAMP is also implemented for XDP_COPY mode: it writes
      SW timestamp from the skb destructor (note I'm reusing hwtstamps to pass
      metadata pointer).
      
      The struct is forward-compatible and can be extended in the future
      by appending more fields.
      
      Reviewed-by: default avatarSong Yoong Siang <yoong.siang.song@intel.com>
      Signed-off-by: default avatarStanislav Fomichev <sdf@google.com>
      Acked-by: default avatarJakub Kicinski <kuba@kernel.org>
      Link: https://lore.kernel.org/r/20231127190319.1190813-3-sdf@google.com
      
      
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      48eb03dd
    • Stanislav Fomichev's avatar
      xsk: Support tx_metadata_len · 341ac980
      Stanislav Fomichev authored
      
      
      For zerocopy mode, tx_desc->addr can point to an arbitrary offset
      and carry some TX metadata in the headroom. For copy mode, there
      is no way currently to populate skb metadata.
      
      Introduce new tx_metadata_len umem config option that indicates how many
      bytes to treat as metadata. Metadata bytes come prior to tx_desc address
      (same as in RX case).
      
      The size of the metadata has mostly the same constraints as XDP:
      - less than 256 bytes
      - 8-byte aligned (compared to 4-byte alignment on xdp, due to 8-byte
        timestamp in the completion)
      - non-zero
      
      This data is not interpreted in any way right now.
      
      Reviewed-by: default avatarSong Yoong Siang <yoong.siang.song@intel.com>
      Signed-off-by: default avatarStanislav Fomichev <sdf@google.com>
      Reviewed-by: default avatarJakub Kicinski <kuba@kernel.org>
      Link: https://lore.kernel.org/r/20231127190319.1190813-2-sdf@google.com
      
      
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      341ac980
  2. Nov 29, 2023
  3. Nov 28, 2023
  4. Nov 27, 2023
    • Yonghong Song's avatar
      bpf: Fix a few selftest failures due to llvm18 change · b16904fd
      Yonghong Song authored
      With latest upstream llvm18, the following test cases failed:
      
        $ ./test_progs -j
        #13/2    bpf_cookie/multi_kprobe_link_api:FAIL
        #13/3    bpf_cookie/multi_kprobe_attach_api:FAIL
        #13      bpf_cookie:FAIL
        #77      fentry_fexit:FAIL
        #78/1    fentry_test/fentry:FAIL
        #78      fentry_test:FAIL
        #82/1    fexit_test/fexit:FAIL
        #82      fexit_test:FAIL
        #112/1   kprobe_multi_test/skel_api:FAIL
        #112/2   kprobe_multi_test/link_api_addrs:FAIL
        [...]
        #112     kprobe_multi_test:FAIL
        #356/17  test_global_funcs/global_func17:FAIL
        #356     test_global_funcs:FAIL
      
      Further analysis shows llvm upstream patch [1] is responsible for the above
      failures. For example, for function bpf_fentry_test7() in net/bpf/test_run.c,
      without [1], the asm code is:
      
        0000000000000400 <bpf_fentry_test7>:
           400: f3 0f 1e fa                   endbr64
           404: e8 00 00 00 00                callq   0x409 <bpf_fentry_test7+0x9>
           409: 48 89 f8                      movq    %rdi, %rax
           40c: c3                            retq
           40d: 0f 1f 00                      nopl    (%rax)
      
      ... and with [1], the asm code is:
      
        0000000000005d20 <bpf_fentry_test7.specialized.1>:
          5d20: e8 00 00 00 00                callq   0x5d25 <bpf_fentry_test7.specialized.1+0x5>
          5d25: c3                            retq
      
      ... and <bpf_fentry_test7.specialized.1> is called instead of <bpf_fentry_test7>
      and this caused test failures for #13/#77 etc. except #356.
      
      For test case #356/17, with [1] (progs/test_global_func17.c)), the main prog
      looks like:
      
        0000000000000000 <global_func17>:
             0:       b4 00 00 00 2a 00 00 00 w0 = 0x2a
             1:       95 00 00 00 00 00 00 00 exit
      
      ... which passed verification while the test itself expects a verification
      failure.
      
      Let us add 'barrier_var' style asm code in both places to prevent function
      specialization which caused selftests failure.
      
        [1] https://github.com/llvm/llvm-project/pull/72903
      
      
      
      Signed-off-by: default avatarYonghong Song <yonghong.song@linux.dev>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20231127050342.1945270-1-yonghong.song@linux.dev
      b16904fd
  5. Nov 24, 2023
  6. Nov 23, 2023
    • Paolo Abeni's avatar
      Merge branch 'ice-restore-timestamp-config-after-reset' · e50a8061
      Paolo Abeni authored
      Tony Nguyen says:
      
      ====================
      ice: restore timestamp config after reset
      
      Jake Keller says:
      
      We recently discovered during internal validation that the ice driver has
      not been properly restoring Tx timestamp configuration after a device reset,
      which resulted in application failures after a device reset.
      
      After some digging, it turned out this problem is two-fold. Since the
      introduction of the PTP support the driver has been clobbering the storage
      of the current timestamp configuration during reset. Thus after a reset, the
      driver will no longer perform Tx or Rx timestamps, and will report
      timestamp configuration as disabled if SIOCGHWTSTAMP ioctl is issued.
      
      In addition, the recently merged auxiliary bus support code missed that
      PFINT_TSYN_MSK must be reprogrammed on the clock owner for E822 devices.
      Failure to restore this register configuration results in the driver no
      longer responding to interrupts from other ports. Depending on the traffic
      pattern, this can either result in increased latency responding to
      timestamps on the non-owner ports, or it can result in the driver never
      reporting any timestamps. The configuration of PFINT_TSYN_MSK was only done
      during initialization. Due to this, the Tx timestamp issue persists even if
      userspace reconfigures timestamping.
      
      This series fixes both issues, as well as removes a redundant Tx ring field
      since we can rely on the skb flag as the primary detector for a Tx timestamp
      request.
      
      Note that I don't think this series will directly apply to older stable
      releases (even v6.6) as we recently refactored a lot of the PTP code to
      support auxiliary bus. Patch 2/3 only matters for the post-auxiliary bus
      implementation. The principle of patch 1/3 and 3/3 could apply as far back
      as the initial PTP support, but I don't think it will apply cleanly as-is.
      ====================
      
      Link: https://lore.kernel.org/r/20231121211259.3348630-1-anthony.l.nguyen@intel.com
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      e50a8061
    • Jacob Keller's avatar
      ice: restore timestamp configuration after device reset · 77580179
      Jacob Keller authored
      The driver calls ice_ptp_cfg_timestamp() during ice_ptp_prepare_for_reset()
      to disable timestamping while the device is resetting. This operation
      destroys the user requested configuration. While the driver does call
      ice_ptp_cfg_timestamp in ice_rebuild() to restore some hardware settings
      after a reset, it unconditionally passes true or false, resulting in
      failure to restore previous user space configuration.
      
      This results in a device reset forcibly disabling timestamp configuration
      regardless of current user settings.
      
      This was not detected previously due to a quirk of the LinuxPTP ptp4l
      application. If ptp4l detects a missing timestamp, it enters a fault state
      and performs recovery logic which includes executing SIOCSHWTSTAMP again,
      restoring the now accidentally cleared configuration.
      
      Not every application does this, and for these applications, timestamps
      will mysteriously stop after a PF reset, without being restored until an
      application restart.
      
      Fix this by replacing ice_ptp_cfg_timestamp() with two new functions:
      
      1) ice_ptp_disable_timestamp_mode() which unconditionally disables the
         timestamping logic in ice_ptp_prepare_for_reset() and ice_ptp_release()
      
      2) ice_ptp_restore_timestamp_mode() which calls
         ice_ptp_restore_tx_interrupt() to restore Tx timestamping configuration,
         calls ice_set_rx_tstamp() to restore Rx timestamping configuration, and
         issues an immediate TSYN_TX interrupt to ensure that timestamps which
         may have occurred during the device reset get processed.
      
      Modify the ice_ptp_set_timestamp_mode to directly save the user
      configuration and then call ice_ptp_restore_timestamp_mode. This way, reset
      no longer destroys the saved user configuration.
      
      This obsoletes the ice_set_tx_tstamp() function which can now be safely
      removed.
      
      With this change, all devices should now restore Tx and Rx timestamping
      functionality correctly after a PF reset without application intervention.
      
      Fixes: 77a78115 ("ice: enable receive hardware timestamping")
      Fixes: ea9b847c
      
       ("ice: enable transmit timestamps for E810 devices")
      Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Reviewed-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      77580179
    • Jacob Keller's avatar
      ice: unify logic for programming PFINT_TSYN_MSK · 7d606a1e
      Jacob Keller authored
      Commit d938a8cc ("ice: Auxbus devices & driver for E822 TS") modified
      how Tx timestamps are handled for E822 devices. On these devices, only the
      clock owner handles reading the Tx timestamp data from firmware. To do
      this, the PFINT_TSYN_MSK register is modified from the default value to one
      which enables reacting to a Tx timestamp on all PHY ports.
      
      The driver currently programs PFINT_TSYN_MSK in different places depending
      on whether the port is the clock owner or not. For the clock owner, the
      PFINT_TSYN_MSK value is programmed during ice_ptp_init_owner just before
      calling ice_ptp_tx_ena_intr to program the PHY ports.
      
      For the non-clock owner ports, the PFINT_TSYN_MSK is programmed during
      ice_ptp_init_port.
      
      If a large enough device reset occurs, the PFINT_TSYN_MSK register will be
      reset to the default value in which only the PHY associated directly with
      the PF will cause the Tx timestamp interrupt to trigger.
      
      The driver lacks logic to reprogram the PFINT_TSYN_MSK register after a
      device reset. For the E822 device, this results in the PF no longer
      responding to interrupts for other ports. This results in failure to
      deliver Tx timestamps to user space applications.
      
      Rename ice_ptp_configure_tx_tstamp to ice_ptp_cfg_tx_interrupt, and unify
      the logic for programming PFINT_TSYN_MSK and PFINT_OICR_ENA into one place.
      This function will program both registers according to the combination of
      user configuration and device requirements.
      
      This ensures that PFINT_TSYN_MSK is always restored when we configure the
      Tx timestamp interrupt.
      
      Fixes: d938a8cc
      
       ("ice: Auxbus devices & driver for E822 TS")
      Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Reviewed-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      7d606a1e
    • Jacob Keller's avatar
      ice: remove ptp_tx ring parameter flag · 0ffb08b1
      Jacob Keller authored
      Before performing a Tx timestamp in ice_stamp(), the driver checks a ptp_tx
      ring variable to see if timestamping is enabled on that ring. This value is
      set for all rings whenever userspace configures Tx timestamping.
      
      Ostensibly this was done to avoid wasting cycles checking other fields when
      timestamping has not been enabled. However, for Tx timestamps we already
      get an individual per-SKB flag indicating whether userspace wants to
      request a timestamp on that packet. We do not gain much by also having
      a separate flag to check for whether timestamping was enabled.
      
      In fact, the driver currently fails to restore the field after a PF reset.
      Because of this, if a PF reset occurs, timestamps will be disabled.
      
      Since this flag doesn't add value in the hotpath, remove it and always
      provide a timestamp if the SKB flag has been set.
      
      A following change will fix the reset path to properly restore user
      timestamping configuration completely.
      
      This went unnoticed for some time because one of the most common
      applications using Tx timestamps, ptp4l, will reconfigure the socket as
      part of its fault recovery logic.
      
      Fixes: ea9b847c
      
       ("ice: enable transmit timestamps for E810 devices")
      Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Reviewed-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      0ffb08b1
    • Paolo Abeni's avatar
      Merge branch 'amd-xgbe-fixes-to-handle-corner-cases' · d9775fb6
      Paolo Abeni authored
      Raju Rangoju says:
      
      ====================
      amd-xgbe: fixes to handle corner-cases
      
      This series include bug fixes to amd-xgbe driver.
      ====================
      
      Link: https://lore.kernel.org/r/20231121191435.4049995-1-Raju.Rangoju@amd.com
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      d9775fb6
    • Raju Rangoju's avatar
      amd-xgbe: propagate the correct speed and duplex status · 7a2323ac
      Raju Rangoju authored
      xgbe_get_link_ksettings() does not propagate correct speed and duplex
      information to ethtool during cable unplug. Due to which ethtool reports
      incorrect values for speed and duplex.
      
      Address this by propagating correct information.
      
      Fixes: 7c12aa08
      
       ("amd-xgbe: Move the PHY support into amd-xgbe")
      Acked-by: default avatarShyam Sundar S K <Shyam-sundar.S-k@amd.com>
      Signed-off-by: default avatarRaju Rangoju <Raju.Rangoju@amd.com>
      Reviewed-by: default avatarWojciech Drewek <wojciech.drewek@intel.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      7a2323ac
    • Raju Rangoju's avatar
      amd-xgbe: handle the corner-case during tx completion · 7121205d
      Raju Rangoju authored
      The existing implementation uses software logic to accumulate tx
      completions until the specified time (1ms) is met and then poll them.
      However, there exists a tiny gap which leads to a race between
      resetting and checking the tx_activate flag. Due to this the tx
      completions are not reported to upper layer and tx queue timeout
      kicks-in restarting the device.
      
      To address this, introduce a tx cleanup mechanism as part of the
      periodic maintenance process.
      
      Fixes: c5aa9e3b
      
       ("amd-xgbe: Initial AMD 10GbE platform driver")
      Acked-by: default avatarShyam Sundar S K <Shyam-sundar.S-k@amd.com>
      Signed-off-by: default avatarRaju Rangoju <Raju.Rangoju@amd.com>
      Reviewed-by: default avatarWojciech Drewek <wojciech.drewek@intel.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      7121205d
    • Raju Rangoju's avatar
      amd-xgbe: handle corner-case during sfp hotplug · 676ec538
      Raju Rangoju authored
      Force the mode change for SFI in Fixed PHY configurations. Fixed PHY
      configurations needs PLL to be enabled while doing mode set. When the
      SFP module isn't connected during boot, driver assumes AN is ON and
      attempts auto-negotiation. However, if the connected SFP comes up in
      Fixed PHY configuration the link will not come up as PLL isn't enabled
      while the initial mode set command is issued. So, force the mode change
      for SFI in Fixed PHY configuration to fix link issues.
      
      Fixes: e57f7a3f
      
       ("amd-xgbe: Prepare for working with more than one type of phy")
      Acked-by: default avatarShyam Sundar S K <Shyam-sundar.S-k@amd.com>
      Signed-off-by: default avatarRaju Rangoju <Raju.Rangoju@amd.com>
      Reviewed-by: default avatarWojciech Drewek <wojciech.drewek@intel.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      676ec538
    • Lorenzo Bianconi's avatar
      net: veth: fix ethtool stats reporting · 818ad9cc
      Lorenzo Bianconi authored
      Fix a possible misalignment between page_pool stats and tx xdp_stats
      reported in veth_get_ethtool_stats routine.
      The issue can be reproduced configuring the veth pair with the
      following tx/rx queues:
      
      $ip link add v0 numtxqueues 2 numrxqueues 4 type veth peer name v1 \
       numtxqueues 1 numrxqueues 1
      
      and loading a simple XDP program on v0 that just returns XDP_PASS.
      In this case on v0 the page_pool stats overwrites tx xdp_stats for queue 1.
      Fix the issue incrementing pp_idx of dev->real_num_tx_queues * VETH_TQ_STATS_LEN
      since we always report xdp_stats for all tx queues in ethtool.
      
      Fixes: 4fc41805
      
       ("net: veth: add page_pool stats")
      Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
      Link: https://lore.kernel.org/r/c5b5d0485016836448453f12846c7c4ab75b094a.1700593593.git.lorenzo@kernel.org
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      818ad9cc
    • Niklas Söderlund's avatar
      dt-bindings: net: renesas,ethertsn: Add Ethernet TSN · c5b9f479
      Niklas Söderlund authored
      
      
      Add bindings for Renesas R-Car Ethernet TSN End-station IP. The RTSN
      device provides Ethernet network.
      
      Signed-off-by: default avatarNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
      Reviewed-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
      Link: https://lore.kernel.org/r/20231121183738.656192-1-niklas.soderlund+renesas@ragnatech.se
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      c5b9f479
    • Suman Ghosh's avatar
      octeontx2-pf: Fix ntuple rule creation to direct packet to VF with higher Rx queue than its PF · 4aa1d8f8
      Suman Ghosh authored
      It is possible to add a ntuple rule which would like to direct packet to
      a VF whose number of queues are greater/less than its PF's queue numbers.
      For example a PF can have 2 Rx queues but a VF created on that PF can have
      8 Rx queues. As of today, ntuple rule will reject rule because it is
      checking the requested queue number against PF's number of Rx queues.
      As a part of this fix if the action of a ntuple rule is to move a packet
      to a VF's queue then the check is removed. Also, a debug information is
      printed to aware user that it is user's responsibility to cross check if
      the requested queue number on that VF is a valid one.
      
      Fixes: f0a1913f
      
       ("octeontx2-pf: Add support for ethtool ntuple filters")
      Signed-off-by: default avatarSuman Ghosh <sumang@marvell.com>
      Reviewed-by: default avatarWojciech Drewek <wojciech.drewek@intel.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/r/20231121165624.3664182-1-sumang@marvell.com
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      4aa1d8f8