netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v3 00/15] Add packet trap policers support
@ 2020-03-30 19:38 Ido Schimmel
  2020-03-30 19:38 ` [PATCH net-next v3 01/15] devlink: " Ido Schimmel
                   ` (15 more replies)
  0 siblings, 16 replies; 22+ messages in thread
From: Ido Schimmel @ 2020-03-30 19:38 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, jiri, roopa, nikolay, andrew, f.fainelli,
	vivien.didelot, mlxsw, Ido Schimmel

From: Ido Schimmel <idosch@mellanox.com>

Background
==========

Devices capable of offloading the kernel's datapath and perform
functions such as bridging and routing must also be able to send (trap)
specific packets to the kernel (i.e., the CPU) for processing.

For example, a device acting as a multicast-aware bridge must be able to
trap IGMP membership reports to the kernel for processing by the bridge
module.

Motivation
==========

In most cases, the underlying device is capable of handling packet rates
that are several orders of magnitude higher compared to those that can
be handled by the CPU.

Therefore, in order to prevent the underlying device from overwhelming
the CPU, devices usually include packet trap policers that are able to
police the trapped packets to rates that can be handled by the CPU.

Proposed solution
=================

This patch set allows capable device drivers to register their supported
packet trap policers with devlink. User space can then tune the
parameters of these policers (currently, rate and burst size) and read
from the device the number of packets that were dropped by the policer,
if supported.

These packet trap policers can then be bound to existing packet trap
groups, which are used to aggregate logically related packet traps. As a
result, trapped packets are policed to rates that can be handled the
host CPU.

Example usage
=============

Instantiate netdevsim:
# echo "10 1" > /sys/bus/netdevsim/new_device

Dump available packet trap policers:
# devlink trap policer show
netdevsim/netdevsim10:
  policer 1 rate 1000 burst 128
  policer 2 rate 2000 burst 256
  policer 3 rate 3000 burst 512

Change the parameters of a packet trap policer:
# devlink trap policer set netdevsim/netdevsim10 policer 3 rate 100 burst 16

Bind a packet trap policer to a packet trap group:
# devlink trap group set netdevsim/netdevsim10 group acl_drops policer 3

Dump parameters and statistics of a packet trap policer:
# devlink -s trap policer show netdevsim/netdevsim10 policer 3
netdevsim/netdevsim10:
  policer 3 rate 100 burst 16
    stats:
        rx:
          dropped 92

Unbind a packet trap policer from a packet trap group:
# devlink trap group set netdevsim/netdevsim10 group acl_drops nopolicer

Patch set overview
==================

Patch #1 adds the core infrastructure in devlink which allows capable
device drivers to register their supported packet trap policers with
devlink.

Patch #2 extends the existing devlink-trap documentation.

Patch #3 extends netdevsim to register a few dummy packet trap policers
with devlink. Used later on to selftests the core infrastructure.

Patches #4-#5 adds infrastructure in devlink to allow binding of packet
trap policers to packet trap groups.

Patch #6 extends netdevsim to allow such binding.

Patch #7 adds a selftest over netdevsim that verifies the core
devlink-trap policers functionality.

Patches #8-#14 gradually add devlink-trap policers support in mlxsw.

Patch #15 adds a selftest over mlxsw. All registered packet trap
policers are verified to handle the configured rate and burst size.

Future plans
============

* Allow changing default association between packet traps and packet
  trap groups
* Add more packet traps. For example, for control packets (e.g., IGMP)

v3:
* Rebase

v2 (address comments from Jiri and Jakub):
* Patch #1: Add 'strict_start_type' in devlink policy
* Patch #1: Have device drivers provide max/min rate/burst size for each
  policer. Use them to check validity of user provided parameters
* Patch #3: Remove check about burst size being a power of 2 and instead
  add a debugfs knob to fail the operation
* Patch #3: Provide max/min rate/burst size when registering policers
  and remove the validity checks from nsim_dev_devlink_trap_policer_set()
* Patch #5: Check for presence of 'DEVLINK_ATTR_TRAP_POLICER_ID' in
  devlink_trap_group_set() and bail if not present
* Patch #5: Add extack error message in case trap group was partially
  modified
* Patch #7: Add test case with new 'fail_trap_policer_set' knob
* Patch #7: Add test case for partially modified trap group
* Patch #10: Provide max/min rate/burst size when registering policers
* Patch #11: Remove the max/min validity checks from
  __mlxsw_sp_trap_policer_set()

Ido Schimmel (15):
  devlink: Add packet trap policers support
  Documentation: Add description of packet trap policers
  netdevsim: Add devlink-trap policer support
  devlink: Add packet trap group parameters support
  devlink: Allow setting of packet trap group parameters
  netdevsim: Add support for setting of packet trap group parameters
  selftests: netdevsim: Add test cases for devlink-trap policers
  mlxsw: reg: Extend QPCR register
  mlxsw: spectrum: Track used packet trap policer IDs
  mlxsw: spectrum_trap: Prepare policers for registration with devlink
  mlxsw: spectrum_trap: Add devlink-trap policer support
  mlxsw: spectrum_trap: Do not initialize dedicated discard policer
  mlxsw: spectrum_trap: Switch to use correct packet trap group
  mlxsw: spectrum_trap: Add support for setting of packet trap group
    parameters
  selftests: mlxsw: Add test cases for devlink-trap policers

 .../networking/devlink/devlink-trap.rst       |  26 +
 drivers/net/ethernet/mellanox/mlxsw/core.c    |  71 +++
 drivers/net/ethernet/mellanox/mlxsw/core.h    |  14 +
 drivers/net/ethernet/mellanox/mlxsw/reg.h     |  19 +-
 .../net/ethernet/mellanox/mlxsw/spectrum.c    |  50 +-
 .../net/ethernet/mellanox/mlxsw/spectrum.h    |  17 +
 .../ethernet/mellanox/mlxsw/spectrum_trap.c   | 336 ++++++++++--
 .../ethernet/mellanox/mlxsw/spectrum_trap.h   |  24 +
 drivers/net/netdevsim/dev.c                   | 110 +++-
 drivers/net/netdevsim/netdevsim.h             |   3 +
 include/net/devlink.h                         |  90 ++-
 include/uapi/linux/devlink.h                  |  11 +
 net/core/devlink.c                            | 515 +++++++++++++++++-
 .../drivers/net/mlxsw/devlink_trap_policer.sh | 384 +++++++++++++
 .../drivers/net/netdevsim/devlink_trap.sh     | 116 ++++
 .../selftests/net/forwarding/devlink_lib.sh   |  43 ++
 16 files changed, 1778 insertions(+), 51 deletions(-)
 create mode 100644 drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.h
 create mode 100755 tools/testing/selftests/drivers/net/mlxsw/devlink_trap_policer.sh

-- 
2.24.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2020-03-31  0:55 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-30 19:38 [PATCH net-next v3 00/15] Add packet trap policers support Ido Schimmel
2020-03-30 19:38 ` [PATCH net-next v3 01/15] devlink: " Ido Schimmel
2020-03-30 23:16   ` Jakub Kicinski
2020-03-30 19:38 ` [PATCH net-next v3 02/15] Documentation: Add description of packet trap policers Ido Schimmel
2020-03-30 19:38 ` [PATCH net-next v3 03/15] netdevsim: Add devlink-trap policer support Ido Schimmel
2020-03-30 23:17   ` Jakub Kicinski
2020-03-30 19:38 ` [PATCH net-next v3 04/15] devlink: Add packet trap group parameters support Ido Schimmel
2020-03-30 23:18   ` Jakub Kicinski
2020-03-30 19:38 ` [PATCH net-next v3 05/15] devlink: Allow setting of packet trap group parameters Ido Schimmel
2020-03-30 23:20   ` Jakub Kicinski
2020-03-30 19:38 ` [PATCH net-next v3 06/15] netdevsim: Add support for " Ido Schimmel
2020-03-30 23:20   ` Jakub Kicinski
2020-03-30 19:38 ` [PATCH net-next v3 07/15] selftests: netdevsim: Add test cases for devlink-trap policers Ido Schimmel
2020-03-30 19:38 ` [PATCH net-next v3 08/15] mlxsw: reg: Extend QPCR register Ido Schimmel
2020-03-30 19:38 ` [PATCH net-next v3 09/15] mlxsw: spectrum: Track used packet trap policer IDs Ido Schimmel
2020-03-30 19:38 ` [PATCH net-next v3 10/15] mlxsw: spectrum_trap: Prepare policers for registration with devlink Ido Schimmel
2020-03-30 19:38 ` [PATCH net-next v3 11/15] mlxsw: spectrum_trap: Add devlink-trap policer support Ido Schimmel
2020-03-30 19:38 ` [PATCH net-next v3 12/15] mlxsw: spectrum_trap: Do not initialize dedicated discard policer Ido Schimmel
2020-03-30 19:38 ` [PATCH net-next v3 13/15] mlxsw: spectrum_trap: Switch to use correct packet trap group Ido Schimmel
2020-03-30 19:38 ` [PATCH net-next v3 14/15] mlxsw: spectrum_trap: Add support for setting of packet trap group parameters Ido Schimmel
2020-03-30 19:38 ` [PATCH net-next v3 15/15] selftests: mlxsw: Add test cases for devlink-trap policers Ido Schimmel
2020-03-31  0:55 ` [PATCH net-next v3 00/15] Add packet trap policers support David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).