1. 02 Jul, 2019 18 commits
    • Yunsheng Lin's avatar
      net: link_watch: prevent starvation when processing linkwatch wq · 27ba4059
      Yunsheng Lin authored
      When user has configured a large number of virtual netdev, such
      as 4K vlans, the carrier on/off operation of the real netdev
      will also cause it's virtual netdev's link state to be processed
      in linkwatch. Currently, the processing is done in a work queue,
      which may cause rtnl locking starvation problem and worker
      starvation problem for other work queue, such as irqfd_inject wq.
      
      This patch releases the cpu when link watch worker has processed
      a fixed number of netdev' link watch event, and schedule the
      work queue again when there is still link watch event remaining.
      Signed-off-by: default avatarYunsheng Lin <linyunsheng@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      27ba4059
    • David S. Miller's avatar
      Merge branch 'mlxsw-PTP-timestamping-support' · 0d0bcacc
      David S. Miller authored
      Ido Schimmel says:
      
      ====================
      mlxsw: PTP timestamping support
      
      This is the second patchset adding PTP support in mlxsw. Next patchset
      will add PTP shapers which are required to maintain accuracy under rates
      lower than 40Gb/s, while subsequent patchsets will add tracepoints and
      selftests.
      
      Petr says:
      
      This patch set introduces support for retrieving and processing hardware
      timestamps for PTP packets.
      
      The way PTP timestamping works on Spectrum-1 is that there are two queues
      associated with each front panel port. When a packet is timestamped, the
      timestamp is put to one of the queues: timestamps for transmitted packets
      to one and for received packets to the other. Activity on these queues is
      signaled through the events PTP_ING_FIFO and PTP_EGR_FIFO.
      
      Packets themselves arrive through two traps: PTP0 and PTP1. It is possible
      to configure which PTP messages should be trapped under which PTP trap. On
      Spectrum systems, mlxsw will use PTP0 for event messages (which need
      timestamping), and PTP1 for general messages (which do not).
      
      There are therefore four relevant traps: receive of PTP event resp. general
      message, and receive of timestamp for a transmitted resp. received PTP
      packet. The obvious point where to put the new logic is a custom listener
      to the mentioned traps.
      
      Besides handling ingress traffic (be in packets or timestamps), the driver
      also needs to handle timestamping of transmitted packets. One option would
      be to invoke the relevant logic from mlxsw_core_ptp_transmitted(). However
      on Spectrum-2, the timestamps are actually delivered through the completion
      queue, and for that reason this patchset opts to invoke the logic from the
      PCI code, via core and the driver, to a chip-specific operation. That way
      the invocation will be done in a place where a Spectrum-2 implementation
      will have an opportunity to extract the timestamp.
      
      As indicated above, the PTP FIFO signaling happens independently from
      packet delivery. A packet corresponding to any given timestamp could be
      delivered sooner or later than the timestamp itself. Additionally, the
      queues are only four elements deep, and it is therefore possible that the
      timestamp for a delivered packet never arrives at all. Similarly a PTP
      packet might be dropped due to CPU traffic pressure, and never be delivered
      even if the corresponding timestamp was.
      
      The driver thus needs to hold a cache of as-yet-unmatched SKBs and
      timestamps. The first piece to arrive (be it timestamp or SKB) is put to
      this cache. When the other piece arrives, the timestamp is attached to the
      SKB and that is passed on. A delayed work is run at regular intervals to
      prune the old unmatched entries.
      
      As mentioned above, the mechanism for timestamp delivery changes on
      Spectrum-2, where timestamps are part of completion queue elements, and all
      packets are timestamped. All this bookkeeping is therefore unnecessary on
      Spectrum-2. For this reason, this patchset spends some time introducing
      Spectrum-1 specific artifacts such as a possibility to register a given
      trap only on Spectrum-1.
      
      Patches #1-#4 describe new registers.
      
      Patches #5 and #6 introduce the possibility to register certain traps
      only on some systems. The list of Spectrum-1 specific traps is left empty
      at this point.
      
      Patch #7 hooks into packet receive path by registering PTP traps
      and appropriate handlers (that however do nothing of substance yet).
      
      Patch #8 adds a helper to allow storing custom data to SKB->cb.
      
      Patch #9 adds a call into the PCI completion queue handler that invokes,
      via core and spectrum code, a PTP transmit handler. (Which also does not do
      anything interesting yet.)
      
      Patch #10 introduces code to invoke PTP initialization and adds data types
      for the cache of unmatched entries.
      
      Patches #11 and #12 implement the timestamping itself. In #11, the PHC
      spin_locks are converted to _bh variants, because unlike normal PHC path,
      which runs in process context, timestamp processing runs as soft interrupt.
      Then #12 introduces the code for saving and retrieval of unmatched entries,
      invokes PTP classifier to identify packets of interest, registers timestamp
      FIFO events, and handles decoding and attaching timestamps to packets.
      
      Patch #13 introduces a garbage collector for left-behind entries that have
      not been matched for about a second.
      
      In patch #14, PTP message types are configured to arrive as PTP0
      (events) or PTP1 (everything else) as appropriate. At this point, the PTP
      packets start arriving through the traps, but because PTP is disabled and
      there is no way to enable it yet, they are always just passed to the usual
      receive path right away.
      
      Finally patches #15 and #16 add the plumbing to actually make it possible
      to enable this code through SIOCSHWTSTAMP ioctl, and to advertise the
      hardware timestamping capabilities through ethtool.
      
      v2:
      - Patch #12:
          - In mlxsw_sp1_ptp_fifo_event_func(), post-increment when iterating over PTP
            FIFO records.
      - Patch #14:
          - Change namespace of message type enumerators from MLXSW_ to MLXSW_SP_.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0d0bcacc
    • Petr Machata's avatar
      mlxsw: spectrum: PTP: Support ethtool get_ts_info · 87ee07f8
      Petr Machata authored
      The get_ts_info callback is used for obtaining information about
      timestamping capabilities of a network device. On Spectrum-1, implement
      it to advertise the PHC and the capability to do HW timestamping, and
      the supported RX and TX filters.
      Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      87ee07f8
    • Petr Machata's avatar
      mlxsw: spectrum: PTP: Support SIOCGHWTSTAMP, SIOCSHWTSTAMP ioctls · 87486427
      Petr Machata authored
      The SIOCSHWTSTAMP ioctl configures HW timestamping on a given port.
      Dispatch the ioctls to per-chip handler (which add to ptp_ops). Find
      which PTP messages need to be timestamped and configure MTPPPC
      accordingly.
      
      The SIOCGHWTSTAMP ioctl is getter for the current configuration.
      Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      87486427
    • Petr Machata's avatar
      mlxsw: spectrum: PTP: Configure PTP traps and FIFO events · a773c76c
      Petr Machata authored
      Configure MTPTPT to set which message types should arrive under which
      PTP trap, and MOGCR to clear the timestamp queue after its contents are
      reported through PTP_ING_FIFO or PTP_EGR_FIFO.
      
      With this configuration, PTP packets start arriving through the PTP
      traps. However since timestamping is disabled by default and there is
      currently no way to enable it, they will not be timestamped.
      Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a773c76c
    • Petr Machata's avatar
      mlxsw: spectrum: PTP: Garbage-collect unmatched entries · 5d23e415
      Petr Machata authored
      On Spectrum-1, timestamped PTP packets and the corresponding timestamps
      need to be kept in caches until both are available, at which point they are
      matched up and packets forwarded as appropriate. However, not all packets
      will ever see their timestamp, and not all timestamps will ever see their
      packet. It is therefore necessary to dispose of such abandoned entries.
      
      To that end, introduce a garbage collector to collect entries that have
      not had their counterpart turn up within about a second. The GC
      maintains a monotonously-increasing value of GC cycle. Every entry that
      is put to the hash table is annotated with the GC cycle at which it
      should be collected. When the GC runs, it walks the hash table, and
      collects the objects according to their GC cycle annotation.
      Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5d23e415
    • Petr Machata's avatar
      mlxsw: spectrum: PTP: Support timestamping on Spectrum-1 · d92e4e6e
      Petr Machata authored
      On Spectrum-1, timestamps arrive through a pair of dedicated events:
      MLXSW_TRAP_ID_PTP_ING_FIFO and _EGR_FIFO. The payload delivered with
      those traps is contents of the timestamp FIFO at a given port in a given
      direction. Add a Spectrum-1-specific handler for these two events which
      decodes the timestamps and forwards them to the PTP module.
      
      Add a function that parses a packet, dispatching to ptp_classify_raw(),
      and decodes PTP message type, domain number, and sequence ID. Add a new
      mlxsw dependency on the PTP classifier.
      
      Add helpers that can store and retrieve unmatched timestamps and SKBs to
      the hash table added in a preceding patch.
      
      Add the matching code itself: upon arrival of a timestamp or a packet,
      look up the corresponding unmatched entry, and match it up. If there is
      none, add a new unmatched entry. This logic is the same on ingress as on
      egress.
      
      Packets and timestamps that never matched need to be eventually disposed
      of. A garbage collector added in a follow-up patch will take care of
      that. Since currently all this code is turned off, no crud will
      accumulate in the hash table.
      Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d92e4e6e
    • Petr Machata's avatar
      mlxsw: spectrum: PTP: Disable BH when working with PHC · 89e602ee
      Petr Machata authored
      Up until now, the PTP hardware clock code was only invoked in the process
      context (SYS_clock_adjtime -> do_clock_adjtime -> k_clock::clock_adj ->
      pc_clock_adjtime -> posix_clock_operations::clock_adjtime ->
      ptp_clock_info::adjtime -> mlxsw_spectrum).
      
      In order to enable HW timestamping, which is tied into trap handling, it
      will be necessary to take the clock lock from the PCI queue handler
      tasklets as well.
      
      Therefore use the _bh variants when handling the clock lock. Incidentally,
      Documentation/ptp/ptp.txt recommends _irqsave variants, but that's
      unnecessarily strong for our needs.
      Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      89e602ee
    • Petr Machata's avatar
      mlxsw: spectrum: PTP: Add PTP initialization / finalization · 810256ce
      Petr Machata authored
      Add two ptp_ops: init and fini, to initialize and finalize the PTP
      subsystem. Call as appropriate from mlxsw_sp_init() and _fini().
      
      Lay the groundwork for Spectrum-1 support. On Spectrum-1, the received
      timestamped packets and their corresponding timestamps arrive
      independently, and need to be matched up. Introduce the related data types
      and add to struct mlxsw_sp_ptp_state the hash table that will keep the
      unmatched entries.
      Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      810256ce
    • Petr Machata's avatar
      mlxsw: pci: PTP: Hook into packet transmit path · 0714256c
      Petr Machata authored
      On Spectrum-1, timestamps are delivered separately from the packets, and
      need to paired up. Therefore, at some point after mlxsw_sp_port_xmit()
      is invoked, it is necessary to involve the chip-specific driver code to
      allow it to do the necessary bookkeeping and matching.
      
      On Spectrum-2, timestamps are delivered in CQE. For that reason,
      position the point of driver involvement into mlxsw_pci_cqe_sdq_handle()
      to make it hopefully easier to extend for Spectrum-2 in the future.
      
      To tell the driver what port the packet was sent on, keep tx_info
      in SKB control buffer.
      
      Introduce a new driver core interface mlxsw_core_ptp_transmitted(), a
      driver callback ptp_transmitted, and a PTP op transmitted. The callee is
      responsible for taking care of releasing the SKB passed to the new
      interfaces, and correspondingly have the new stub callbacks just call
      dev_kfree_skb_any().
      
      Follow-up patches will introduce the actual content into
      mlxsw_sp1_ptp_transmitted() in particular.
      Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0714256c
    • Petr Machata's avatar
      mlxsw: core: Add support for using SKB control buffer · d7cd206d
      Petr Machata authored
      The SKB control buffer is useful (and used) for bookkeeping of information
      related to that SKB. Add helpers so that the mlxsw driver(s) can safely use
      the buffer as well. The structure is currently empty, individual users will
      add members to it as necessary.
      
      Note that SKB allocation functions already clear the buffer, so the cleanup
      is only necessary when ndo_start_xmit is called.
      Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d7cd206d
    • Petr Machata's avatar
      mlxsw: spectrum: PTP: Hook into packet receive path · aed4b572
      Petr Machata authored
      When configured, the Spectrum hardware can recognize PTP packets and
      trap them to the CPU using dedicated traps, PTP0 and PTP1.
      
      One reason to get PTP packets under dedicated traps is to have a
      separate policer suitable for the amount of PTP traffic expected when
      switch is operated as a boundary clock. For this, add two new trap
      groups, MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP0 and _PTP1, and associate the
      two PTP traps with these two groups.
      
      In the driver, specifically for Spectrum-1, event PTP packets will need
      to be paired up with their timestamps. Those arrive through a different
      set of traps, added later in the patch set. To support this future use,
      introduce a new PTP op, ptp_receive.
      
      It is possible to configure which PTP messages should be trapped under
      which PTP trap. On Spectrum systems, we will use PTP0 for event
      packets (which need timestamping), and PTP1 for control packets (which
      do not). Thus configure PTP0 trap with a custom callback that defers to
      the ptp_receive op.
      
      Additionally, L2 PTP packets are actually trapped through the LLDP trap,
      not through any of the PTP traps. So treat the LLDP trap the same way as
      the PTP0 trap. Unlike PTP traps, which are currently still disabled,
      LLDP trap is active. Correspondingly, have all the implementations of
      the ptp_receive op return true, which the handler treats as a signal to
      forward the packet immediately.
      Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      aed4b572
    • Petr Machata's avatar
      mlxsw: spectrum: Add support for traps specific to Spectrum-1 · dadbc6bc
      Petr Machata authored
      On Spectrum-1, timestamps for PTP packets are delivered through queues
      of ingress and egress timestamps. There are two event traps
      corresponding to activity on each of those queues. This mechanism is
      absent on Spectrum-2, and therefore the traps should only be registered
      on Spectrum-1.
      
      Carry a chip-specific listener array in mlxsw_sp->listeners and
      listeners_count. Register listeners from that array in
      mlxsw_sp_traps_init(). Add a new listener array for Spectrum-1 traps and
      configure the newly-added mlxsw_sp->listeners with this array.
      
      The listener array is empty for now, the events will be added in a later
      patch.
      Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      dadbc6bc
    • Petr Machata's avatar
      mlxsw: spectrum: Extract a helper for trap registration · 4b6b91ed
      Petr Machata authored
      On Spectrum-1, timestamps for PTP packets are delivered through queues
      of ingress and egress timestamps. There are two event traps
      corresponding to activity on each of those queues. This mechanism is
      absent on Spectrum-2, and therefore the traps should only be registered
      on Spectrum-1.
      
      Extract out of mlxsw_sp_traps_init() a generic helper,
      mlxsw_sp_traps_register(), and likewise with _unregister(). The new helpers
      will later be called with Spectrum-1-specific traps.
      Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4b6b91ed
    • Petr Machata's avatar
      mlxsw: reg: Add Monitoring Global Configuration Register · 41ce78b9
      Petr Machata authored
      This register serves to configure global parameters of certain
      monitoring operations. The following patches will use it to configure
      that when PTP timestamps are delivered through the PTP FIFO traps, the
      FIFO in question is cleared as well.
      Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      41ce78b9
    • Petr Machata's avatar
      mlxsw: reg: Add Time Precision Packet Timestamping Reading · 98b9028e
      Petr Machata authored
      The MTPPTR is used for reading the per port PTP timestamp FIFO.
      Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      98b9028e
    • Petr Machata's avatar
      mlxsw: reg: Add Monitoring Precision Time Protocol Trap Register · 4dfecb65
      Petr Machata authored
      This register is used for configuring under which trap to deliver PTP
      packets depending on type of the packet.
      Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4dfecb65
    • Petr Machata's avatar
      mlxsw: reg: Add Monitoring Time Precision Packet Port Configuration Register · da28e878
      Petr Machata authored
      This register serves for configuration of which PTP messages should be
      timestamped. This is a global configuration, despite the register name.
      Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      da28e878
  2. 01 Jul, 2019 4 commits
  3. 30 Jun, 2019 1 commit
    • David S. Miller's avatar
      Merge branch '10GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue · 11697cfc
      David S. Miller authored
      Jeff Kirsher says:
      
      ====================
      Intel Wired LAN Driver Updates 2019-06-28
      
      This series contains a smorgasbord of updates to many of the Intel
      drivers.
      
      Gustavo A. R. Silva updates the ice and iavf drivers to use the
      strcut_size() helper where possible.
      
      Miguel increases the pause and refresh time for flow control in the
      e1000e driver during reset for certain devices.
      
      Dann Frazier fixes a potential NULL pointer dereference in ixgbe driver
      when using non-IPSec enabled devices.
      
      Colin Ian King fixes a potential overflow during a shift in the ixgbe
      driver.  Also fixes a potential NULL pointer dereference in the iavf
      driver by adding a check.
      
      Venkatesh Srinivas converts the e1000 driver to use dma_wmb() instead of
      wmb() for doorbell writes to avoid SFENCEs in the transmit and receive
      paths.
      
      Arjan updates the e1000e driver to improve boot time by over 100 msec by
      reducing the usleep ranges suring system startup.
      
      Artem updates the igb driver register dump in ethtool, first prepares
      the register dump for future additions of registers in the dump, then
      secondly, adds the RR2DCDELAY register to the dump.  When dealing with
      time-sensitive networks, this register is helpful in determining your
      latency from the device to the ring.
      
      Alex fixes the ixgbevf driver to use the current cached link state,
      rather than trying to re-check the value from the PF.
      
      Harshitha adds support for MACVLAN offloads in i40e by using channels as
      MACVLAN interfaces.
      
      Detlev Casanova updates the e1000e driver to use delayed work instead of
      timers to run the watchdog.
      
      Vitaly fixes an issue in e1000e, where when disconnecting and
      reconnecting the physical cable connection, the NIC enters a DMoff
      state.  This state causes a mismatch in link and duplexing, so check the
      PCIm function state and perform a PHY reset when in this state to
      resolve the issue.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      11697cfc
  4. 29 Jun, 2019 10 commits
  5. 28 Jun, 2019 7 commits