OSDN Git Service

devlink: Allow setting tx rate for devlink rate leaf objects
authorDmytro Linkin <dlinkin@nvidia.com>
Wed, 2 Jun 2021 12:17:22 +0000 (15:17 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 2 Jun 2021 21:08:37 +0000 (14:08 -0700)
commit1897db2ec3109eb1dd07b357c95c5e03d54e41b9
tree6706a5c71aaa0e2464ff49186f03fd41cc93cb02
parenta27d8e352bf252eb44b04c9e628a8d759956bdd2
devlink: Allow setting tx rate for devlink rate leaf objects

Implement support for DEVLINK_CMD_RATE_SET command with new attributes
DEVLINK_ATTR_RATE_TX_{SHARE|MAX} that are used to set devlink rate
shared/max tx rate values. Extend devlink ops with new callbacks
rate_leaf_tx_{share|max}_set() to allow supporting drivers to implement
rate control through devlink.

New attributes are optional. Driver implementations are allowed to
support either or both of them.

Shared rate example:

$ devlink port function rate set netdevsim/netdevsim10/0 tx_share 10mbit

$ devlink port function rate show netdevsim/netdevsim10/0
netdevsim/netdevsim10/0: type leaf tx_share 10mbit

Max rate example:

$ devlink port function rate set netdevsim/netdevsim10/0 tx_max 100mbit

$ devlink port function rate show netdevsim/netdevsim10/0
netdevsim/netdevsim10/0: type leaf tx_max 100mbit

Co-developed-by: Vlad Buslov <vladbu@nvidia.com>
Signed-off-by: Vlad Buslov <vladbu@nvidia.com>
Signed-off-by: Dmytro Linkin <dlinkin@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/devlink.h
include/uapi/linux/devlink.h
net/core/devlink.c