1. Dec 09, 2022
    • Jacob Keller's avatar
      ice: synchronize the misc IRQ when tearing down Tx tracker · f0ae1240
      Jacob Keller authored
      Since commit 1229b339
      
       ("ice: Add low latency Tx timestamp read") the
      ice driver has used a threaded IRQ for handling Tx timestamps. This change
      did not add a call to synchronize_irq during ice_ptp_release_tx_tracker.
      Thus it is possible that an interrupt could occur just as the tracker is
      being removed. This could lead to a use-after-free of the Tx tracker
      structure data.
      
      Fix this by calling sychronize_irq in ice_ptp_release_tx_tracker after
      we've cleared the init flag. In addition, make sure that we re-check the
      init flag at the end of ice_ptp_tx_tstamp before we exit ensuring that we
      will stop polling for new timestamps once the tracker de-initialization has
      begun.
      
      Refactor the ts_handled variable into "more_timestamps" so that we can
      simply directly assign this boolean instead of relying on an initialized
      value of true. This makes the new combined check easier to read.
      
      With this change, the ice_ptp_release_tx_tracker function will now wait for
      the threaded interrupt to complete if it was executing while the init flag
      was cleared.
      
      Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      f0ae1240
    • Jacob Keller's avatar
      ice: check Tx timestamp memory register for ready timestamps · 10e4b4a3
      Jacob Keller authored
      
      
      The PHY for E822 based hardware has a register which indicates which
      timestamps are valid in the PHY timestamp memory block. Each bit in the
      register indicates whether the associated index in the timestamp memory is
      valid.
      
      Hardware sets this bit when the timestamp is captured, and clears the bit
      when the timestamp is read. Use of this register is important as reading
      timestamp registers can impact the way that hardware generates timestamp
      interrupts.
      
      This occurs because the PHY has an internal value which is incremented
      when hardware captures a timestamp and decremented when software reads a
      timestamp. Reading timestamps which are not marked as valid still decrement
      the internal value and can result in the Tx timestamp interrupt not
      triggering in the future.
      
      To prevent this, use the timestamp memory value to determine which
      timestamps are ready to be read. The ice_get_phy_tx_tstamp_ready function
      reads this value. For E810 devices, this just always returns with all bits
      set.
      
      Skip any timestamp which is not set in this bitmap, avoiding reading extra
      timestamps on E822 devices.
      
      The stale check against a cached timestamp value is no longer necessary for
      PHYs which support the timestamp ready bitmap properly. E810 devices still
      need this. Introduce a new verify_cached flag to the ice_ptp_tx structure.
      Use this to determine if we need to perform the verification against the
      cached timestamp value. Set this to 1 for the E810 Tx tracker init
      function. Notice that many of the fields in ice_ptp_tx are simple 1 bit
      flags. Save some structure space by using bitfields of length 1 for these
      values.
      
      Modify the ICE_PTP_TS_VALID check to simply drop the timestamp immediately
      so that in an event of getting such an invalid timestamp the driver does
      not attempt to re-read the timestamp again in a future poll of the
      register.
      
      With these changes, the driver now reads each timestamp register exactly
      once, and does not attempt any re-reads. This ensures the interrupt
      tracking logic in the PHY will not get stuck.
      
      Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      10e4b4a3
    • Jacob Keller's avatar
      ice: handle discarding old Tx requests in ice_ptp_tx_tstamp · 0dd92862
      Jacob Keller authored
      
      
      Currently the driver uses the PTP kthread to process handling and
      discarding of stale Tx timestamp requests. The function
      ice_ptp_tx_tstamp_cleanup is used for this.
      
      A separate thread creates complications for the driver as we now have both
      the main Tx timestamp processing IRQ checking timestamps as well as the
      kthread.
      
      Rather than using the kthread to handle this, simply check for stale
      timestamps within the ice_ptp_tx_tstamp function. This function must
      already process the timestamps anyways.
      
      If a Tx timestamp has been waiting for 2 seconds we simply clear the bit
      and discard the SKB. This avoids the complication of having separate
      threads polling, reducing overall CPU work.
      
      Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      0dd92862
    • Jacob Keller's avatar
      ice: always call ice_ptp_link_change and make it void · 6b1ff5d3
      Jacob Keller authored
      
      
      The ice_ptp_link_change function is currently only called for E822 based
      hardware. Future changes are going to extend this function to perform
      additional tasks on link change.
      
      Always call this function, moving the E810 check from the callers down to
      just before we call the E822-specific function required to restart the PHY.
      
      This function also returns an error value, but none of the callers actually
      check it. In general, the errors it produces are more likely systemic
      problems such as invalid or corrupt port numbers. No caller checks these,
      and so no warning is logged.
      
      Re-order the flag checks so that ICE_FLAG_PTP is checked first. Drop the
      unnecessary check for ICE_FLAG_PTP_SUPPORTED, as ICE_FLAG_PTP will not be
      set except when ICE_FLAG_PTP_SUPPORTED is set.
      
      Convert the port checks to WARN_ON_ONCE, in order to generate a kernel
      stack trace when they are hit.
      
      Convert the function to void since no caller actually checks these return
      values.
      
      Co-developed-by: default avatarDave Ertman <david.m.ertman@intel.com>
      Signed-off-by: default avatarDave Ertman <david.m.ertman@intel.com>
      Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      6b1ff5d3
    • Jacob Keller's avatar
      ice: fix misuse of "link err" with "link status" · 11722c39
      Jacob Keller authored
      
      
      The ice_ptp_link_change function has a comment which mentions "link
      err" when referring to the current link status. We are storing the status
      of whether link is up or down, which is not an error.
      
      It is appears that this use of err accidentally got included due to an
      overzealous search and replace when removing the ice_status enum and local
      status variable.
      
      Fix the wording to use the correct term.
      
      Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      11722c39
    • Karol Kolacinski's avatar
      ice: Reset TS memory for all quads · 407b66c0
      Karol Kolacinski authored
      
      
      In E822 products, the owner PF should reset memory for all quads, not
      only for the one where assigned lport is.
      
      Signed-off-by: default avatarKarol Kolacinski <karol.kolacinski@intel.com>
      Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      407b66c0
    • Milena Olech's avatar
      ice: Remove the E822 vernier "bypass" logic · 0357d5ca
      Milena Olech authored
      
      
      The E822 devices support an extended "vernier" calibration which enables
      higher precision timestamps by accounting for delays in the PHY, and
      compensating for them. These delays are measured by hardware as part of its
      vernier calibration logic.
      
      The driver currently starts the PHY in "bypass" mode which skips
      the compensation. Then it later attempts to switch from bypass to vernier.
      This unfortunately does not work as expected. Instead of properly
      compensating for the delays, the hardware continues operating in bypass
      without the improved precision expected.
      
      Because we cannot dynamically switch between bypass and vernier mode,
      refactor the driver to always operate in vernier mode. This has a slight
      downside: Tx timestamp and Rx timestamp requests that occur as the very
      first packet set after link up will not complete properly and may be
      reported to applications as missing timestamps.
      
      This occurs frequently in test environments where traffic is light or
      targeted specifically at testing PTP. However, in practice most
      environments will have transmitted or received some data over the network
      before such initial requests are made.
      
      Signed-off-by: default avatarMilena Olech <milena.olech@intel.com>
      Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      0357d5ca
    • Sergey Temerkhanov's avatar
      ice: Use more generic names for ice_ptp_tx fields · 6b5cbc8c
      Sergey Temerkhanov authored
      
      
      Some supported devices have per-port timestamp memory blocks while
      others have shared ones within quads. Rename the struct ice_ptp_tx
      fields to reflect the block entities it works with
      
      Signed-off-by: default avatarSergey Temerkhanov <sergey.temerkhanov@intel.com>
      Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      6b5cbc8c
    • Oleksij Rempel's avatar
  2. Dec 08, 2022
  3. Dec 07, 2022
    • Paolo Abeni's avatar
      Merge branch 'cn10kb-mac-block-support' · a2220b54
      Paolo Abeni authored
      Hariprasad Kelam says:
      
      ====================
      CN10KB MAC block support
      
      OcteonTx2's next gen platform the CN10KB has RPM_USX MAC which has a
      different serdes when compared to RPM MAC. Though the underlying
      HW is different, the CSR interface has been designed largely inline
      with RPM MAC, with few exceptions though. So we are using the same
      CGX driver for RPM_USX MAC as well and will have a different set of APIs
      for RPM_USX where ever necessary.
      
      The RPM and RPM_USX blocks support a different number of LMACS.
      RPM_USX support 8 LMACS per MAC block whereas legacy RPM supports only 4
      LMACS per MAC. with this RPM_USX support double the number of DMAC filters
      and fifo size.
      
      This patchset adds initial support for CN10KB's RPM_USX  MAC i.e
      registering the driver and defining MAC operations (mac_ops). With these
      changes PF and VF netdev packet path will work and PF and VF netdev drivers
      are able to configure MAC features like pause frames,PFC and loopback etc.
      
      Also implements FEC stats for CN10K Mac block RPM and CN10KB Mac block
      RPM_USX and extends ethtool support for PF and VF drivers by defining
      get_fec_stats API to display FEC stats.
      ====================
      
      Link: https://lore.kernel.org/r/20221205070521.21860-1-hkelam@marvell.com
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      a2220b54
    • Hariprasad Kelam's avatar
      octeontx2-af: Add FEC stats for RPM/RPM_USX block · 84ad3642
      Hariprasad Kelam authored
      
      
      CN10K silicon MAC block RPM and CN10KB silicon MAC block RPM_USX
      both support BASER and RSFEC modes.
      
      Also MAC (CGX) on OcteonTx2 silicon variants and MAC (RPM) on
      OcteonTx3 CN10K are different and FEC stats need to be read
      differently. CN10KB MAC block (RPM_USX) fec csr offsets are same
      as CN10K MAC block (RPM) mac_ops points to same fn(). Upper layer
      interface between  RVU AF and PF netdev is  kept same. Based on
      silicon variant appropriate fn() pointer is called to  read FEC stats
      
      Signed-off-by: default avatarHariprasad Kelam <hkelam@marvell.com>
      Signed-off-by: default avatarSunil Kovvuri Goutham <sgoutham@marvell.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      84ad3642