mbox series

[RESEND2,iproute2,net-next,0/3] devlink rate support

Message ID 1623396337-30106-1-git-send-email-dlinkin@nvidia.com (mailing list archive)
Headers show
Series devlink rate support | expand

Message

Dmytro Linkin June 11, 2021, 7:25 a.m. UTC
From: Dmytro Linkin <dlinkin@nvidia.com>

Resend rebased on top of net-next. Dropped header update patch.

Serries implements devlink rate commands, which are:
- Dump particular or all rate objects (JSON or non-JSON)
- Add/Delete node rate object
- Set tx rate share/max values for rate object
- Set/Unset parent rate object for other rate object

Examples:

Display all rate objects:

    # devlink port function rate show
    pci/0000:03:00.0/1 type leaf parent some_group
    pci/0000:03:00.0/2 type leaf tx_share 12Mbit
    pci/0000:03:00.0/some_group type node tx_share 1Gbps tx_max 5Gbps

Display leaf rate object bound to the 1st devlink port of the
pci/0000:03:00.0 device:

    # devlink port function rate show pci/0000:03:00.0/1
    pci/0000:03:00.0/1 type leaf

Display node rate object with name some_group of the pci/0000:03:00.0
device:

    # devlink port function rate show pci/0000:03:00.0/some_group
    pci/0000:03:00.0/some_group type node

Display leaf rate object rate values using IEC units:

    # devlink -i port function rate show pci/0000:03:00.0/2
    pci/0000:03:00.0/2 type leaf 11718Kibit

Display pci/0000:03:00.0/2 leaf rate object as pretty JSON output:

    # devlink -jp port function rate show pci/0000:03:00.0/2
    {
        "rate": {
            "pci/0000:03:00.0/2": {
                "type": "leaf",
                "tx_share": 1500000
            }
        }
    }

Create node rate object with name "1st_group" on pci/0000:03:00.0 device:

    # devlink port function rate add pci/0000:03:00.0/1st_group

Create node rate object with specified parameters:

    # devlink port function rate add pci/0000:03:00.0/2nd_group \
        tx_share 10Mbit tx_max 30Mbit parent 1st_group

Set parameters to the specified leaf rate object:

    # devlink port function rate set pci/0000:03:00.0/1 \
        tx_share 2Mbit tx_max 10Mbit

Set leaf's parent to "1st_group":

    # devlink port function rate set pci/0000:03:00.0/1 parent 1st_group

Unset leaf's parent:

    # devlink port function rate set pci/0000:03:00.0/1 noparent

Delete node rate object:

    # devlink port function rate del pci/0000:03:00.0/2nd_group

Rate values can be specified in bits or bytes per second (bit|bps), with
any SI (k, m, g, t) or IEC (ki, mi, gi, ti) prefix. Bare number means
bits per second. Units also printed in "show" command output, but not
necessarily the same which were specified with "set" or "add" command.
-i/--iec switch force output in IEC units. JSON output always print
values as bytes per sec.

Dmytro Linkin (3):
  devlink: Add helper function to validate object handler
  devlink: Add port func rate support
  devlink: Add ISO/IEC switch

 devlink/devlink.c       | 527 +++++++++++++++++++++++++++++++++++++++++++++---
 man/man8/devlink-port.8 |   8 +
 man/man8/devlink-rate.8 | 270 +++++++++++++++++++++++++
 man/man8/devlink.8      |   4 +
 4 files changed, 780 insertions(+), 29 deletions(-)
 create mode 100644 man/man8/devlink-rate.8

Comments

David Ahern June 12, 2021, 4:39 a.m. UTC | #1
On 6/11/21 1:25 AM, dlinkin@nvidia.com wrote:
> From: Dmytro Linkin <dlinkin@nvidia.com>
> 
> Resend rebased on top of net-next. Dropped header update patch.
> 
> Serries implements devlink rate commands, which are:
> - Dump particular or all rate objects (JSON or non-JSON)
> - Add/Delete node rate object
> - Set tx rate share/max values for rate object
> - Set/Unset parent rate object for other rate object
> 
> Examples:
> 
> Display all rate objects:
> 
>     # devlink port function rate show
>     pci/0000:03:00.0/1 type leaf parent some_group
>     pci/0000:03:00.0/2 type leaf tx_share 12Mbit
>     pci/0000:03:00.0/some_group type node tx_share 1Gbps tx_max 5Gbps
> 
> Display leaf rate object bound to the 1st devlink port of the
> pci/0000:03:00.0 device:
> 
>     # devlink port function rate show pci/0000:03:00.0/1
>     pci/0000:03:00.0/1 type leaf
> 
> Display node rate object with name some_group of the pci/0000:03:00.0
> device:
> 
>     # devlink port function rate show pci/0000:03:00.0/some_group
>     pci/0000:03:00.0/some_group type node
> 
> Display leaf rate object rate values using IEC units:
> 
>     # devlink -i port function rate show pci/0000:03:00.0/2
>     pci/0000:03:00.0/2 type leaf 11718Kibit
> 
> Display pci/0000:03:00.0/2 leaf rate object as pretty JSON output:
> 
>     # devlink -jp port function rate show pci/0000:03:00.0/2
>     {
>         "rate": {
>             "pci/0000:03:00.0/2": {
>                 "type": "leaf",
>                 "tx_share": 1500000
>             }
>         }
>     }
> 
> Create node rate object with name "1st_group" on pci/0000:03:00.0 device:
> 
>     # devlink port function rate add pci/0000:03:00.0/1st_group
> 
> Create node rate object with specified parameters:
> 
>     # devlink port function rate add pci/0000:03:00.0/2nd_group \
>         tx_share 10Mbit tx_max 30Mbit parent 1st_group
> 
> Set parameters to the specified leaf rate object:
> 
>     # devlink port function rate set pci/0000:03:00.0/1 \
>         tx_share 2Mbit tx_max 10Mbit
> 
> Set leaf's parent to "1st_group":
> 
>     # devlink port function rate set pci/0000:03:00.0/1 parent 1st_group
> 
> Unset leaf's parent:
> 
>     # devlink port function rate set pci/0000:03:00.0/1 noparent
> 
> Delete node rate object:
> 
>     # devlink port function rate del pci/0000:03:00.0/2nd_group
> 
> Rate values can be specified in bits or bytes per second (bit|bps), with
> any SI (k, m, g, t) or IEC (ki, mi, gi, ti) prefix. Bare number means
> bits per second. Units also printed in "show" command output, but not
> necessarily the same which were specified with "set" or "add" command.
> -i/--iec switch force output in IEC units. JSON output always print
> values as bytes per sec.
> 
> Dmytro Linkin (3):
>   devlink: Add helper function to validate object handler
>   devlink: Add port func rate support
>   devlink: Add ISO/IEC switch
> 
>  devlink/devlink.c       | 527 +++++++++++++++++++++++++++++++++++++++++++++---
>  man/man8/devlink-port.8 |   8 +
>  man/man8/devlink-rate.8 | 270 +++++++++++++++++++++++++
>  man/man8/devlink.8      |   4 +
>  4 files changed, 780 insertions(+), 29 deletions(-)
>  create mode 100644 man/man8/devlink-rate.8
> 

applied to iproute2-next. Thanks,