1. 18 Aug, 2019 11 commits
  2. 17 Aug, 2019 29 commits
    • David S. Miller's avatar
      Merge branch 'stmmac-next' · d83d508b
      David S. Miller authored
      Jose Abreu says:
      
      ====================
      net: stmmac: Improvements for -next
      
      Couple of improvements for -next tree. More info in commit logs.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d83d508b
    • Jose Abreu's avatar
      net: stmmac: selftests: Add selftest for VLAN TX Offload · 94e18382
      Jose Abreu authored
      Add 2 new selftests for VLAN Insertion offloading. Tests are for inner
      and outer VLAN offloading.
      Signed-off-by: default avatarJose Abreu <joabreu@synopsys.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      94e18382
    • Jose Abreu's avatar
      net: stmmac: Add support for VLAN Insertion Offload · 30d93227
      Jose Abreu authored
      Adds the logic to insert a given VLAN ID in a packet. This is offloaded
      to HW and its descriptor based. For now, only XGMAC implements the
      necessary callbacks.
      Signed-off-by: default avatarJose Abreu <joabreu@synopsys.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      30d93227
    • Jose Abreu's avatar
      net: stmmac: xgmac: Add EEE support · 81b945ae
      Jose Abreu authored
      Add support for EEE in XGMAC cores by implementing the necessary
      callbacks.
      Signed-off-by: default avatarJose Abreu <joabreu@synopsys.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      81b945ae
    • Jose Abreu's avatar
      net: stmmac: selftests: Add tests for SA Insertion/Replacement · 8180d579
      Jose Abreu authored
      Add 4 new tests:
      	- SA Insertion (register based)
      	- SA Insertion (descriptor based)
      	- SA Replacament (register based)
      	- SA Replacement (descriptor based)
      Signed-off-by: default avatarJose Abreu <joabreu@synopsys.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8180d579
    • Jose Abreu's avatar
      net: stmmac: Add support for SA Insertion/Replacement in XGMAC cores · 8000ddc0
      Jose Abreu authored
      Add the support for Source Address Insertion and Replacement in XGMAC
      cores. Two methods are supported: Descriptor based and register based.
      Signed-off-by: default avatarJose Abreu <joabreu@synopsys.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8000ddc0
    • Jose Abreu's avatar
      net: stmmac: Add ethtool register dump for XGMAC cores · bfc56530
      Jose Abreu authored
      Add the ethtool interface to dump the register map in XGMAC cores.
      
      Changes from v2:
      	- Remove uneeded memset (Jakub)
      Signed-off-by: default avatarJose Abreu <joabreu@synopsys.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      bfc56530
    • Jose Abreu's avatar
      net: stmmac: dwxgmac: Add Flexible PPS support · 95eaf3cd
      Jose Abreu authored
      Add the support for Flexible PPS in XGMAC cores.
      Signed-off-by: default avatarJose Abreu <joabreu@synopsys.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      95eaf3cd
    • Jose Abreu's avatar
      net: stmmac: Add a counter for Split Header packets · b5418e13
      Jose Abreu authored
      Add a counter that increments each time a packet with split header is
      received.
      Signed-off-by: default avatarJose Abreu <joabreu@synopsys.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b5418e13
    • Jose Abreu's avatar
      net: stmmac: Add Split Header support and enable it in XGMAC cores · 67afd6d1
      Jose Abreu authored
      Add the support for Split Header feature in the RX path and enable it in
      XGMAC cores.
      
      This does not impact neither beneficts bandwidth but it does reduces CPU
      usage because without the feature all the entire packet is memcpy'ed,
      while that with the feature only the header is.
      
      With Split Header disabled 'perf stat -d' gives:
      86870.624945 task-clock (msec)      #    0.429 CPUs utilized
           1073352 context-switches       #    0.012 M/sec
                 1 cpu-migrations         #    0.000 K/sec
               213 page-faults            #    0.002 K/sec
      327113872376 cycles                 #    3.766 GHz (62.53%)
       56618161216 instructions           #    0.17  insn per cycle (75.06%)
       10742205071 branches               #  123.658 M/sec (75.36%)
         584309242 branch-misses          #    5.44% of all branches (75.19%)
       17594787965 L1-dcache-loads        #  202.540 M/sec (74.88%)
        4003773131 L1-dcache-load-misses  #   22.76% of all L1-dcache hits (74.89%)
        1313301468 LLC-loads              #   15.118 M/sec (49.75%)
         355906510 LLC-load-misses        #   27.10% of all LL-cache hits (49.92%)
      
      With Split Header enabled 'perf stat -d' gives:
      49324.456539 task-clock (msec)     #    0.245 CPUs utilized
           2542387 context-switches      #    0.052 M/sec
                 1 cpu-migrations        #    0.000 K/sec
               213 page-faults           #    0.004 K/sec
      177092791469 cycles                #    3.590 GHz (62.30%)
       68555756017 instructions          #    0.39  insn per cycle (75.16%)
       12697019382 branches              #  257.418 M/sec (74.81%)
         442081897 branch-misses         #    3.48% of all branches (74.79%)
       20337958358 L1-dcache-loads       #  412.330 M/sec (75.46%)
        3820210140 L1-dcache-load-misses #   18.78% of all L1-dcache hits (75.35%)
        1257719198 LLC-loads             #   25.499 M/sec (49.73%)
         685543923 LLC-load-misses       #   54.51% of all LL-cache hits (49.86%)
      
      Changes from v2:
      	- Reword commit message (Jakub)
      Changes from v1:
      	- Add performance info (David)
      	- Add misssing dma_sync_single_for_device()
      Signed-off-by: default avatarJose Abreu <joabreu@synopsys.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      67afd6d1
    • Jose Abreu's avatar
      net: stmmac: xgmac: Correctly return that RX descriptor is not last one · c887e02a
      Jose Abreu authored
      Return the correct value when RX descriptor is not the last one.
      Signed-off-by: default avatarJose Abreu <joabreu@synopsys.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c887e02a
    • Jose Abreu's avatar
      net: stmmac: Prepare to add Split Header support · ec222003
      Jose Abreu authored
      In order to add Split Header support, stmmac_rx() needs to take into
      account that packet may be split accross multiple descriptors.
      
      Refactor the logic of this function in order to support this scenario.
      
      Changes from v2:
      	- Fixup if condition detection (Jakub)
      	- Don't stop NAPI with unfinished packet (Jakub)
      	- Use napi_alloc_skb() (Jakub)
      Signed-off-by: default avatarJose Abreu <joabreu@synopsys.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ec222003
    • Jose Abreu's avatar
      net: stmmac: Get correct timestamp values from XGMAC · 25e80cd0
      Jose Abreu authored
      TX Timestamp in XGMAC comes from MAC instead of descriptors. Implement
      this in a new callback.
      
      Also, RX Timestamp in XGMAC must be cheked against corruption and we need
      a barrier to make sure that descriptor fields are read correctly.
      
      Changes from v2:
      	- Rework return code check (Jakub)
      Changes from v1:
      	- Rework the get timestamp function (David)
      Signed-off-by: default avatarJose Abreu <joabreu@synopsys.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      25e80cd0
    • David S. Miller's avatar
      Merge branch 'drop_monitor-for-offloaded-paths' · 83beee5a
      David S. Miller authored
      Ido Schimmel says:
      
      ====================
      Add drop monitor for offloaded data paths
      
      Users have several ways to debug the kernel and understand why a packet
      was dropped. For example, using drop monitor and perf. Both utilities
      trace kfree_skb(), which is the function called when a packet is freed
      as part of a failure. The information provided by these tools is
      invaluable when trying to understand the cause of a packet loss.
      
      In recent years, large portions of the kernel data path were offloaded
      to capable devices. Today, it is possible to perform L2 and L3
      forwarding in hardware, as well as tunneling (IP-in-IP and VXLAN).
      Different TC classifiers and actions are also offloaded to capable
      devices, at both ingress and egress.
      
      However, when the data path is offloaded it is not possible to achieve
      the same level of introspection since packets are dropped by the
      underlying device and never reach the kernel.
      
      This patchset aims to solve this by allowing users to monitor packets
      that the underlying device decided to drop along with relevant metadata
      such as the drop reason and ingress port.
      
      The above is achieved by exposing a fundamental capability of devices
      capable of data path offloading - packet trapping. In much the same way
      as drop monitor registers its probe function with the kfree_skb()
      tracepoint, the device is instructed to pass to the CPU (trap) packets
      that it decided to drop in various places in the pipeline.
      
      The configuration of the device to pass such packets to the CPU is
      performed using devlink, as it is not specific to a port, but rather to
      a device. In the future, we plan to control the policing of such packets
      using devlink, in order not to overwhelm the CPU.
      
      While devlink is used as the control path, the dropped packets are
      passed along with metadata to drop monitor, which reports them to
      userspace as netlink events. This allows users to use the same interface
      for the monitoring of both software and hardware drops.
      
      Logically, the solution looks as follows:
      
                                          Netlink event: Packet w/ metadata
                                                         Or a summary of recent drops
                                        ^
                                        |
               Userspace                |
              +---------------------------------------------------+
               Kernel                   |
                                        |
                                +-------+--------+
                                |                |
                                |  drop_monitor  |
                                |                |
                                +-------^--------+
                                        |
                                        |
                                        |
                                   +----+----+
                                   |         |      Kernel's Rx path
                                   | devlink |      (non-drop traps)
                                   |         |
                                   +----^----+      ^
                                        |           |
                                        +-----------+
                                        |
                                +-------+-------+
                                |               |
                                | Device driver |
                                |               |
                                +-------^-------+
               Kernel                   |
              +---------------------------------------------------+
               Hardware                 |
                                        | Trapped packet
                                        |
                                     +--+---+
                                     |      |
                                     | ASIC |
                                     |      |
                                     +------+
      
      In order to reduce the patch count, this patchset only includes
      integration with netdevsim. A follow-up patchset will add devlink-trap
      support in mlxsw.
      
      Patches #1-#7 extend drop monitor to also monitor hardware originated
      drops.
      
      Patches #8-#10 add the devlink-trap infrastructure.
      
      Patches #11-#12 add devlink-trap support in netdevsim.
      
      Patches #13-#16 add tests for the generic infrastructure over netdevsim.
      
      Example
      =======
      
      Instantiate netdevsim
      ---------------------
      
      List supported traps
      --------------------
      
      netdevsim/netdevsim10:
        name source_mac_is_multicast type drop generic true action drop group l2_drops
        name vlan_tag_mismatch type drop generic true action drop group l2_drops
        name ingress_vlan_filter type drop generic true action drop group l2_drops
        name ingress_spanning_tree_filter type drop generic true action drop group l2_drops
        name port_list_is_empty type drop generic true action drop group l2_drops
        name port_loopback_filter type drop generic true action drop group l2_drops
        name fid_miss type exception generic false action trap group l2_drops
        name blackhole_route type drop generic true action drop group l3_drops
        name ttl_value_is_too_small type exception generic true action trap group l3_drops
        name tail_drop type drop generic true action drop group buffer_drops
      
      Enable a trap
      -------------
      
      Query statistics
      ----------------
      
      netdevsim/netdevsim10:
        name blackhole_route type drop generic true action trap group l3_drops
          stats:
              rx:
                bytes 7384 packets 52
      
      Monitor dropped packets
      -----------------------
      
      dropwatch> set alertmode packet
      Setting alert mode
      Alert mode successfully set
      dropwatch> set sw true
      setting software drops monitoring to 1
      dropwatch> set hw true
      setting hardware drops monitoring to 1
      dropwatch> start
      Enabling monitoring...
      Kernel monitoring activated.
      Issue Ctrl-C to stop monitoring
      drop at: ttl_value_is_too_small (l3_drops)
      origin: hardware
      input port ifindex: 55
      input port name: eth0
      timestamp: Mon Aug 12 10:52:20 2019 445911505 nsec
      protocol: 0x800
      length: 142
      original length: 142
      
      drop at: ip6_mc_input+0x8b8/0xef8 (0xffffffff9e2bb0e8)
      origin: software
      input port ifindex: 4
      timestamp: Mon Aug 12 10:53:37 2019 024444587 nsec
      protocol: 0x86dd
      length: 110
      original length: 110
      
      Future plans
      ============
      
      * Provide more drop reasons as well as more metadata
      * Add dropmon support to libpcap, so that tcpdump/tshark could
        specifically listen on dropmon traffic, instead of capturing all
        netlink packets via nlmon interface
      
      Changes in v3:
      * Place test with the rest of the netdevsim tests
      * Fix test to load netdevsim module
      * Move devlink helpers from the test to devlink_lib.sh. Will be used
        by mlxsw tests
      * Re-order netdevsim includes in alphabetical order
      * Fix reverse xmas tree in netdevsim
      * Remove double include in netdevsim
      
      Changes in v2:
      * Use drop monitor to report dropped packets instead of devlink
      * Add drop monitor patches
      * Add test cases
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      83beee5a
    • Ido Schimmel's avatar
    • Ido Schimmel's avatar
      selftests: devlink_trap: Add test cases for devlink-trap · b3cb7df9
      Ido Schimmel authored
      Add test cases for devlink-trap on top of the netdevsim implementation.
      
      The tests focus on the devlink-trap core infrastructure and user space
      API. They test both good and bad flows and also dismantle of the netdev
      and devlink device used to report trapped packets.
      
      This allows device drivers to focus their tests on device-specific
      functionality.
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b3cb7df9
    • Ido Schimmel's avatar
      selftests: forwarding: devlink_lib: Add devlink-trap helpers · a054c8d9
      Ido Schimmel authored
      Add helpers to interact with devlink-trap, such as setting the action of
      a trap and retrieving statistics.
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a054c8d9
    • Ido Schimmel's avatar
      selftests: forwarding: devlink_lib: Allow tests to define devlink device · bc030d9c
      Ido Schimmel authored
      For tests that create their network interfaces dynamically or do not use
      interfaces at all (as with netdevsim) it is useful to define their own
      devlink device instead of deriving it from the first network interface.
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      bc030d9c
    • Ido Schimmel's avatar
    • Ido Schimmel's avatar
      netdevsim: Add devlink-trap support · da58f90f
      Ido Schimmel authored
      Have netdevsim register its trap groups and traps with devlink during
      initialization and periodically report trapped packets to devlink core.
      
      Since netdevsim is not a real device, the trapped packets are emulated
      using a workqueue that periodically reports a UDP packet with a random
      5-tuple from each active packet trap and from each running netdev.
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      da58f90f
    • Ido Schimmel's avatar
      Documentation: Add devlink-trap documentation · f3047ca0
      Ido Schimmel authored
      Add initial documentation of the devlink-trap mechanism, explaining the
      background, motivation and the semantics of the interface.
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f3047ca0
    • Ido Schimmel's avatar
      devlink: Add generic packet traps and groups · 391203ab
      Ido Schimmel authored
      Add generic packet traps and groups that can report dropped packets as
      well as exceptions such as TTL error.
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      391203ab
    • Ido Schimmel's avatar
      devlink: Add packet trap infrastructure · 0f420b6c
      Ido Schimmel authored
      Add the basic packet trap infrastructure that allows device drivers to
      register their supported packet traps and trap groups with devlink.
      
      Each driver is expected to provide basic information about each
      supported trap, such as name and ID, but also the supported metadata
      types that will accompany each packet trapped via the trap. The
      currently supported metadata type is just the input port, but more will
      be added in the future. For example, output port and traffic class.
      
      Trap groups allow users to set the action of all member traps. In
      addition, users can retrieve per-group statistics in case per-trap
      statistics are too narrow. In the future, the trap group object can be
      extended with more attributes, such as policer settings which will limit
      the amount of traffic generated by member traps towards the CPU.
      
      Beside registering their packet traps with devlink, drivers are also
      expected to report trapped packets to devlink along with relevant
      metadata. devlink will maintain packets and bytes statistics for each
      packet trap and will potentially report the trapped packet with its
      metadata to user space via drop monitor netlink channel.
      
      The interface towards the drivers is simple and allows devlink to set
      the action of the trap. Currently, only two actions are supported:
      'trap' and 'drop'. When set to 'trap', the device is expected to provide
      the sole copy of the packet to the driver which will pass it to devlink.
      When set to 'drop', the device is expected to drop the packet and not
      send a copy to the driver. In the future, more actions can be added,
      such as 'mirror'.
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0f420b6c
    • Ido Schimmel's avatar
      drop_monitor: Allow user to start monitoring hardware drops · 8e94c3bc
      Ido Schimmel authored
      Drop monitor has start and stop commands, but so far these were only
      used to start and stop monitoring of software drops.
      
      Now that drop monitor can also monitor hardware drops, we should allow
      the user to control these as well.
      
      Do that by adding SW and HW flags to these commands. If no flag is
      specified, then only start / stop monitoring software drops. This is
      done in order to maintain backward-compatibility with existing user
      space applications.
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8e94c3bc
    • Ido Schimmel's avatar
      drop_monitor: Add support for summary alert mode for hardware drops · d40e1deb
      Ido Schimmel authored
      In summary alert mode a notification is sent with a list of recent drop
      reasons and a count of how many packets were dropped due to this reason.
      
      To avoid expensive operations in the context in which packets are
      dropped, each CPU holds an array whose number of entries is the maximum
      number of drop reasons that can be encoded in the netlink notification.
      Each entry stores the drop reason and a count. When a packet is dropped
      the array is traversed and a new entry is created or the count of an
      existing entry is incremented.
      
      Later, in process context, the array is replaced with a newly allocated
      copy and the old array is encoded in a netlink notification. To avoid
      breaking user space, the notification includes the ancillary header,
      which is 'struct net_dm_alert_msg' with number of entries set to '0'.
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d40e1deb
    • Ido Schimmel's avatar
      drop_monitor: Add support for packet alert mode for hardware drops · 5e58109b
      Ido Schimmel authored
      In a similar fashion to software drops, extend drop monitor to send
      netlink events when packets are dropped by the underlying hardware.
      
      The main difference is that instead of encoding the program counter (PC)
      from which kfree_skb() was called in the netlink message, we encode the
      hardware trap name. The two are mostly equivalent since they should both
      help the user understand why the packet was dropped.
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5e58109b
    • Ido Schimmel's avatar
      drop_monitor: Consider all monitoring states before performing configuration · 80cebed8
      Ido Schimmel authored
      The drop monitor configuration (e.g., alert mode) is global, but user
      will be able to enable monitoring of only software or hardware drops.
      
      Therefore, ensure that monitoring of both software and hardware drops are
      disabled before allowing drop monitor configuration to take place.
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      80cebed8
    • Ido Schimmel's avatar
      drop_monitor: Add basic infrastructure for hardware drops · edd3d007
      Ido Schimmel authored
      Export a function that can be invoked in order to report packets that
      were dropped by the underlying hardware along with metadata.
      
      Subsequent patches will add support for the different alert modes.
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      edd3d007
    • Ido Schimmel's avatar
      drop_monitor: Initialize hardware per-CPU data · cac1174f
      Ido Schimmel authored
      Like software drops, hardware drops also need the same type of per-CPU
      data. Therefore, initialize it during module initialization and
      de-initialize it during module exit.
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      cac1174f