DEVLINK-RATE(8)

okay bestie, gather round, because we're talking about devlink-rate โ€” the devlink rate management page, Linux edition, and honestly? it's giving traffic-shaping main character energy ๐Ÿ‘‘


โœจ NAME โœจ

devlink-rate โ€” devlink rate management ๐ŸŽ€


๐ŸŒธ SYNOPSIS ๐ŸŒธ

devlink [ OPTIONS ] port function rate  { COMMAND | help }

OPTIONS := { -j[son] | -p[retty] | -i[ec] }

devlink port function rate show [ { DEV/PORT_INDEX | DEV/NODE_NAME } ]

devlink port function rate set { DEV/PORT_INDEX | DEV/NODE_NAME } [
        tx_share VALUE ] [ tx_max VALUE ] [ tx_priority N ] [ tx_weight
        N ] [ tc-bw INDEX:N ] [ { parent NODE_NAME | noparent } ]

devlink port function rate add DEV/NODE_NAME [ tx_share VALUE ] [ tx_max
        VALUE ] [ tx_priority N ] [ tx_weight N ] [ tc-bw INDEX:N ] [ {
        parent NODE_NAME | noparent } ]

devlink port function rate del DEV/NODE_NAME

devlink port function rate help

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

bestie it literally shows you a rate object. or, if you don't name one, it shows you all of them. no cap.

a rate object can show up as one of two types:

  • leaf โ€” this is one single devlink port, bestie. it's created/destroyed by the driver and bound to the devlink port. like, for example, some drivers may create a leaf rate object for every devlink port associated with VF. and since leaves have a 1-to-1 mapping to their devlink port, in user space they're referred to as the corresponding devlink port DEV/PORT_INDEX โœจ
  • node โ€” a group of rate objects, highkey a little friend group ๐Ÿซถ. created/deleted by the user (see the commands below) and bound to the devlink device rather than to the devlink port. in userspace it's referred to as DEV/NODE_NAME, where node name can be any, except decimal number, to avoid collisions with leafs. yes, the naming lore is real.

the command output shows the rate object identifier, its type, and its rate values, along with the parent node name. rate values are printed in SI units which are more suitable to represent the specific value. to print values in IEC units, the -i switch is used. JSON (-j) output always prints rate values in bytes per second. zero rate values means "unlimited" rates and are omitted in the output, as well as the parent node name. periodt ๐Ÿ’…

lets you set a rate object's parameters. and if any parameter is specified multiple times, the last occurrence is the one that's used. the way that works is iconic honestly.

  • DEV/PORT_INDEX โ€” specifies devlink leaf rate object.
  • DEV/NODE_NAME โ€” specifies devlink node rate object.
  • tx_share VALUE โ€” specifies minimal tx rate value shared among all rate objects. if the rate object is a part of some rate group, then this value is shared with rate objects of this rate group. sharing is caring ๐Ÿฅฐ
  • tx_max VALUE โ€” specifies maximum tx rate value. that's the ceiling, bestie.
  • tx_priority N โ€” allows for usage of strict priority arbiter among siblings. this arbitration scheme attempts to schedule nodes based on their priority as long as the nodes remain within their bandwidth limit. the higher the priority, the higher the probability that the node will get selected for scheduling. it's giving "pick me" but make it networking ๐Ÿ‘‘
  • tx_weight N โ€” allows for usage of Weighted Fair Queuing arbitration scheme among siblings. this arbitration scheme can be used simultaneously with the strict priority. as a node is configured with a higher rate it gets more BW relative to its siblings. values are relative like percentage points, they basically tell how much BW the node should take relative to its siblings.
  • tc-bw INDEX:N โ€” allows the user to assign relative bandwidth shares to specific traffic classes using the IEEE 802.1Qaz standard. the values determine how bandwidth is distributed between traffic classes in proportion to one another. if not specified, the default bandwidth allocation is applied.
  • VALUE โ€” these parameters accept a floating point number, possibly followed by either a unit (both SI and IEC units supported).
    • bit or a bare number โ€” bits per second
    • kbit โ€” kilobits per second
    • mbit โ€” megabits per second
    • gbit โ€” gigabits per second
    • tbit โ€” terabits per second
    • bps โ€” bytes per second
    • kbps โ€” kilobytes per second
    • mbps โ€” megabytes per second
    • gbps โ€” gigabytes per second
    • tbps โ€” terabytes per second

to specify in IEC units, replace the SI prefix (k-, m-, g-, t-) with IEC prefix (ki-, mi-, gi- and ti-) respectively. input is case-insensitive ๐Ÿ’…

  • INDEX โ€” these parameters represent the traffic class index in the tc-bw option. the traffic class is specified as an integer value, ranging from 0 to 7, which maps to the defined traffic classes under the IEEE 802.1Qaz standard.
  • N โ€” these parameters accept an integer meaning weight or priority of a node.
  • parent NODE_NAME | noparent โ€” set the rate object parent to an existing node with name NODE_NAME, or unset the parent. rate limits of the parent node are applied to all its children. actual behavior is a detail of the driver's implementation. setting the parent to an empty ("") name, due to the kernel logic, is treated as unsetting the parent. lowkey sneaky but that's the rule ๐Ÿซ 

creates a rate object of type node and sets parameters. parameters same as for the "set" command.

  • DEV/NODE_NAME โ€” specifies the devlink node rate object to create.

delete the specified devlink node rate object.

bestie, listen: a node can't be deleted if there is any child. the user must explicitly unset the parent. no shortcuts, no skipping. ๐Ÿ™ˆ
  • DEV/NODE_NAME โ€” specifies the devlink node rate object to delete.

display devlink rate usage information. that's it, that's the vibe โœจ


๐Ÿ’– 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 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 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 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

๐Ÿซถ SEE ALSO ๐Ÿซถ

devlink(8), devlink-port(8)


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Dmytro Linkin <dlinkin@nvidia.com>


and that's the whole page bestie!! this one's from the iproute2 era, dated 12 Mar 2021 โ€” go off, you understood every single flag, no cap ๐Ÿ’œโœจ

๐Ÿ“ฆ where this page comes from