xref: /linux/Documentation/netlink/specs/net_shaper.yaml (revision 25768de50b1f2dbb6ea44bd5148a87fe2c9c3688)
104e65df9SPaolo Abeni# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
204e65df9SPaolo Abeniname: net-shaper
304e65df9SPaolo Abeni
404e65df9SPaolo Abenidoc: |
504e65df9SPaolo Abeni  Networking HW rate limiting configuration.
604e65df9SPaolo Abeni
704e65df9SPaolo Abeni  This API allows configuring HW shapers available on the network
804e65df9SPaolo Abeni  devices at different levels (queues, network device) and allows
904e65df9SPaolo Abeni  arbitrary manipulation of the scheduling tree of the involved
1004e65df9SPaolo Abeni  shapers.
1104e65df9SPaolo Abeni
1204e65df9SPaolo Abeni  Each @shaper is identified within the given device, by a @handle,
1304e65df9SPaolo Abeni  comprising both a @scope and an @id.
1404e65df9SPaolo Abeni
1504e65df9SPaolo Abeni  Depending on the @scope value, the shapers are attached to specific
1604e65df9SPaolo Abeni  HW objects (queues, devices) or, for @node scope, represent a
1704e65df9SPaolo Abeni  scheduling group, that can be placed in an arbitrary location of
1804e65df9SPaolo Abeni  the scheduling tree.
1904e65df9SPaolo Abeni
2004e65df9SPaolo Abeni  Shapers can be created with two different operations: the @set
2104e65df9SPaolo Abeni  operation, to create and update a single "attached" shaper, and
2204e65df9SPaolo Abeni  the @group operation, to create and update a scheduling
2304e65df9SPaolo Abeni  group. Only the @group operation can create @node scope shapers.
2404e65df9SPaolo Abeni
2504e65df9SPaolo Abeni  Existing shapers can be deleted/reset via the @delete operation.
2604e65df9SPaolo Abeni
2704e65df9SPaolo Abeni  The user can query the running configuration via the @get operation.
2804e65df9SPaolo Abeni
29*14bba928SPaolo Abeni  Different devices can provide different feature sets, e.g. with no
30*14bba928SPaolo Abeni  support for complex scheduling hierarchy, or for some shaping
31*14bba928SPaolo Abeni  parameters. The user can introspect the HW capabilities via the
32*14bba928SPaolo Abeni  @cap-get operation.
33*14bba928SPaolo Abeni
3404e65df9SPaolo Abenidefinitions:
3504e65df9SPaolo Abeni  -
3604e65df9SPaolo Abeni    type: enum
3704e65df9SPaolo Abeni    name: scope
3804e65df9SPaolo Abeni    doc: Defines the shaper @id interpretation.
3904e65df9SPaolo Abeni    render-max: true
4004e65df9SPaolo Abeni    entries:
4104e65df9SPaolo Abeni      - name: unspec
4204e65df9SPaolo Abeni        doc: The scope is not specified.
4304e65df9SPaolo Abeni      -
4404e65df9SPaolo Abeni        name: netdev
4504e65df9SPaolo Abeni        doc: The main shaper for the given network device.
4604e65df9SPaolo Abeni      -
4704e65df9SPaolo Abeni        name: queue
4804e65df9SPaolo Abeni        doc: |
4904e65df9SPaolo Abeni            The shaper is attached to the given device queue,
5004e65df9SPaolo Abeni            the @id represents the queue number.
5104e65df9SPaolo Abeni      -
5204e65df9SPaolo Abeni        name: node
5304e65df9SPaolo Abeni        doc: |
5404e65df9SPaolo Abeni             The shaper allows grouping of queues or other
5504e65df9SPaolo Abeni             node shapers; can be nested in either @netdev
5604e65df9SPaolo Abeni             shapers or other @node shapers, allowing placement
5704e65df9SPaolo Abeni             in any location of the scheduling tree, except
5804e65df9SPaolo Abeni             leaves and root.
5904e65df9SPaolo Abeni  -
6004e65df9SPaolo Abeni    type: enum
6104e65df9SPaolo Abeni    name: metric
6204e65df9SPaolo Abeni    doc: Different metric supported by the shaper.
6304e65df9SPaolo Abeni    entries:
6404e65df9SPaolo Abeni      -
6504e65df9SPaolo Abeni        name: bps
6604e65df9SPaolo Abeni        doc: Shaper operates on a bits per second basis.
6704e65df9SPaolo Abeni      -
6804e65df9SPaolo Abeni        name: pps
6904e65df9SPaolo Abeni        doc: Shaper operates on a packets per second basis.
7004e65df9SPaolo Abeni
7104e65df9SPaolo Abeniattribute-sets:
7204e65df9SPaolo Abeni  -
7304e65df9SPaolo Abeni    name: net-shaper
7404e65df9SPaolo Abeni    attributes:
7504e65df9SPaolo Abeni      -
7604e65df9SPaolo Abeni        name: handle
7704e65df9SPaolo Abeni        type: nest
7804e65df9SPaolo Abeni        nested-attributes: handle
7904e65df9SPaolo Abeni        doc: Unique identifier for the given shaper inside the owning device.
8004e65df9SPaolo Abeni      -
8104e65df9SPaolo Abeni        name: metric
8204e65df9SPaolo Abeni        type: u32
8304e65df9SPaolo Abeni        enum: metric
8404e65df9SPaolo Abeni        doc: Metric used by the given shaper for bw-min, bw-max and burst.
8504e65df9SPaolo Abeni      -
8604e65df9SPaolo Abeni        name: bw-min
8704e65df9SPaolo Abeni        type: uint
8804e65df9SPaolo Abeni        doc: Guaranteed bandwidth for the given shaper.
8904e65df9SPaolo Abeni      -
9004e65df9SPaolo Abeni        name: bw-max
9104e65df9SPaolo Abeni        type: uint
9204e65df9SPaolo Abeni        doc: Maximum bandwidth for the given shaper or 0 when unlimited.
9304e65df9SPaolo Abeni      -
9404e65df9SPaolo Abeni        name: burst
9504e65df9SPaolo Abeni        type: uint
9604e65df9SPaolo Abeni        doc: |
9704e65df9SPaolo Abeni          Maximum burst-size for shaping. Should not be interpreted
9804e65df9SPaolo Abeni          as a quantum.
9904e65df9SPaolo Abeni      -
10004e65df9SPaolo Abeni        name: priority
10104e65df9SPaolo Abeni        type: u32
10204e65df9SPaolo Abeni        doc: |
10304e65df9SPaolo Abeni          Scheduling priority for the given shaper. The priority
10404e65df9SPaolo Abeni          scheduling is applied to sibling shapers.
10504e65df9SPaolo Abeni      -
10604e65df9SPaolo Abeni        name: weight
10704e65df9SPaolo Abeni        type: u32
10804e65df9SPaolo Abeni        doc: |
10904e65df9SPaolo Abeni          Relative weight for round robin scheduling of the
11004e65df9SPaolo Abeni          given shaper.
11104e65df9SPaolo Abeni          The scheduling is applied to all sibling shapers
11204e65df9SPaolo Abeni          with the same priority.
11304e65df9SPaolo Abeni      -
11404e65df9SPaolo Abeni        name: ifindex
11504e65df9SPaolo Abeni        type: u32
11604e65df9SPaolo Abeni        doc: Interface index owning the specified shaper.
11704e65df9SPaolo Abeni      -
11804e65df9SPaolo Abeni        name: parent
11904e65df9SPaolo Abeni        type: nest
12004e65df9SPaolo Abeni        nested-attributes: handle
12104e65df9SPaolo Abeni        doc: |
12204e65df9SPaolo Abeni          Identifier for the parent of the affected shaper.
12304e65df9SPaolo Abeni          Only needed for @group operation.
12404e65df9SPaolo Abeni      -
12504e65df9SPaolo Abeni        name: leaves
12604e65df9SPaolo Abeni        type: nest
12704e65df9SPaolo Abeni        multi-attr: true
12804e65df9SPaolo Abeni        nested-attributes: leaf-info
12904e65df9SPaolo Abeni        doc: |
13004e65df9SPaolo Abeni           Describes a set of leaves shapers for a @group operation.
13104e65df9SPaolo Abeni  -
13204e65df9SPaolo Abeni    name: handle
13304e65df9SPaolo Abeni    attributes:
13404e65df9SPaolo Abeni      -
13504e65df9SPaolo Abeni        name: scope
13604e65df9SPaolo Abeni        type: u32
13704e65df9SPaolo Abeni        enum: scope
13804e65df9SPaolo Abeni        doc: Defines the shaper @id interpretation.
13904e65df9SPaolo Abeni      -
14004e65df9SPaolo Abeni        name: id
14104e65df9SPaolo Abeni        type: u32
14204e65df9SPaolo Abeni        doc: |
14304e65df9SPaolo Abeni          Numeric identifier of a shaper. The id semantic depends on
14404e65df9SPaolo Abeni          the scope. For @queue scope it's the queue id and for @node
14504e65df9SPaolo Abeni          scope it's the node identifier.
14604e65df9SPaolo Abeni  -
14704e65df9SPaolo Abeni    name: leaf-info
14804e65df9SPaolo Abeni    subset-of: net-shaper
14904e65df9SPaolo Abeni    attributes:
15004e65df9SPaolo Abeni      -
15104e65df9SPaolo Abeni        name: handle
15204e65df9SPaolo Abeni      -
15304e65df9SPaolo Abeni        name: priority
15404e65df9SPaolo Abeni      -
15504e65df9SPaolo Abeni        name: weight
156*14bba928SPaolo Abeni  -
157*14bba928SPaolo Abeni    name: caps
158*14bba928SPaolo Abeni    attributes:
159*14bba928SPaolo Abeni      -
160*14bba928SPaolo Abeni        name: ifindex
161*14bba928SPaolo Abeni        type: u32
162*14bba928SPaolo Abeni        doc: Interface index queried for shapers capabilities.
163*14bba928SPaolo Abeni      -
164*14bba928SPaolo Abeni        name: scope
165*14bba928SPaolo Abeni        type: u32
166*14bba928SPaolo Abeni        enum: scope
167*14bba928SPaolo Abeni        doc: The scope to which the queried capabilities apply.
168*14bba928SPaolo Abeni      -
169*14bba928SPaolo Abeni        name: support-metric-bps
170*14bba928SPaolo Abeni        type: flag
171*14bba928SPaolo Abeni        doc: The device accepts 'bps' metric for bw-min, bw-max and burst.
172*14bba928SPaolo Abeni      -
173*14bba928SPaolo Abeni        name: support-metric-pps
174*14bba928SPaolo Abeni        type: flag
175*14bba928SPaolo Abeni        doc: The device accepts 'pps' metric for bw-min, bw-max and burst.
176*14bba928SPaolo Abeni      -
177*14bba928SPaolo Abeni        name: support-nesting
178*14bba928SPaolo Abeni        type: flag
179*14bba928SPaolo Abeni        doc: |
180*14bba928SPaolo Abeni          The device supports nesting shaper belonging to this scope
181*14bba928SPaolo Abeni          below 'node' scoped shapers. Only 'queue' and 'node'
182*14bba928SPaolo Abeni          scope can have flag 'support-nesting'.
183*14bba928SPaolo Abeni      -
184*14bba928SPaolo Abeni        name: support-bw-min
185*14bba928SPaolo Abeni        type: flag
186*14bba928SPaolo Abeni        doc: The device supports a minimum guaranteed B/W.
187*14bba928SPaolo Abeni      -
188*14bba928SPaolo Abeni        name: support-bw-max
189*14bba928SPaolo Abeni        type: flag
190*14bba928SPaolo Abeni        doc: The device supports maximum B/W shaping.
191*14bba928SPaolo Abeni      -
192*14bba928SPaolo Abeni        name: support-burst
193*14bba928SPaolo Abeni        type: flag
194*14bba928SPaolo Abeni        doc: The device supports a maximum burst size.
195*14bba928SPaolo Abeni      -
196*14bba928SPaolo Abeni        name: support-priority
197*14bba928SPaolo Abeni        type: flag
198*14bba928SPaolo Abeni        doc: The device supports priority scheduling.
199*14bba928SPaolo Abeni      -
200*14bba928SPaolo Abeni        name: support-weight
201*14bba928SPaolo Abeni        type: flag
202*14bba928SPaolo Abeni        doc: The device supports weighted round robin scheduling.
20304e65df9SPaolo Abeni
20404e65df9SPaolo Abenioperations:
20504e65df9SPaolo Abeni  list:
20604e65df9SPaolo Abeni    -
20704e65df9SPaolo Abeni      name: get
20804e65df9SPaolo Abeni      doc: |
20904e65df9SPaolo Abeni        Get information about a shaper for a given device.
21004e65df9SPaolo Abeni      attribute-set: net-shaper
21104e65df9SPaolo Abeni
21204e65df9SPaolo Abeni      do:
21304e65df9SPaolo Abeni        pre: net-shaper-nl-pre-doit
21404e65df9SPaolo Abeni        post: net-shaper-nl-post-doit
21504e65df9SPaolo Abeni        request:
21604e65df9SPaolo Abeni          attributes: &ns-binding
21704e65df9SPaolo Abeni            - ifindex
21804e65df9SPaolo Abeni            - handle
21904e65df9SPaolo Abeni        reply:
22004e65df9SPaolo Abeni          attributes: &ns-attrs
22104e65df9SPaolo Abeni            - ifindex
22204e65df9SPaolo Abeni            - parent
22304e65df9SPaolo Abeni            - handle
22404e65df9SPaolo Abeni            - metric
22504e65df9SPaolo Abeni            - bw-min
22604e65df9SPaolo Abeni            - bw-max
22704e65df9SPaolo Abeni            - burst
22804e65df9SPaolo Abeni            - priority
22904e65df9SPaolo Abeni            - weight
23004e65df9SPaolo Abeni
23104e65df9SPaolo Abeni      dump:
23204e65df9SPaolo Abeni        pre: net-shaper-nl-pre-dumpit
23304e65df9SPaolo Abeni        post: net-shaper-nl-post-dumpit
23404e65df9SPaolo Abeni        request:
23504e65df9SPaolo Abeni          attributes:
23604e65df9SPaolo Abeni            - ifindex
23704e65df9SPaolo Abeni        reply:
23804e65df9SPaolo Abeni          attributes: *ns-attrs
23904e65df9SPaolo Abeni    -
24004e65df9SPaolo Abeni      name: set
24104e65df9SPaolo Abeni      doc: |
24204e65df9SPaolo Abeni        Create or update the specified shaper.
24304e65df9SPaolo Abeni        The set operation can't be used to create a @node scope shaper,
24404e65df9SPaolo Abeni        use the @group operation instead.
24504e65df9SPaolo Abeni      attribute-set: net-shaper
24604e65df9SPaolo Abeni      flags: [ admin-perm ]
24704e65df9SPaolo Abeni
24804e65df9SPaolo Abeni      do:
24904e65df9SPaolo Abeni        pre: net-shaper-nl-pre-doit
25004e65df9SPaolo Abeni        post: net-shaper-nl-post-doit
25104e65df9SPaolo Abeni        request:
25204e65df9SPaolo Abeni          attributes:
25304e65df9SPaolo Abeni            - ifindex
25404e65df9SPaolo Abeni            - handle
25504e65df9SPaolo Abeni            - metric
25604e65df9SPaolo Abeni            - bw-min
25704e65df9SPaolo Abeni            - bw-max
25804e65df9SPaolo Abeni            - burst
25904e65df9SPaolo Abeni            - priority
26004e65df9SPaolo Abeni            - weight
26104e65df9SPaolo Abeni
26204e65df9SPaolo Abeni    -
26304e65df9SPaolo Abeni      name: delete
26404e65df9SPaolo Abeni      doc: |
26504e65df9SPaolo Abeni        Clear (remove) the specified shaper. When deleting
26604e65df9SPaolo Abeni        a @node shaper, reattach all the node's leaves to the
26704e65df9SPaolo Abeni        deleted node's parent.
26804e65df9SPaolo Abeni        If, after the removal, the parent shaper has no more
26904e65df9SPaolo Abeni        leaves and the parent shaper scope is @node, the parent
27004e65df9SPaolo Abeni        node is deleted, recursively.
27104e65df9SPaolo Abeni        When deleting a @queue shaper or a @netdev shaper,
27204e65df9SPaolo Abeni        the shaper disappears from the hierarchy, but the
27304e65df9SPaolo Abeni        queue/device can still send traffic: it has an implicit
27404e65df9SPaolo Abeni        node with infinite bandwidth. The queue's implicit node
27504e65df9SPaolo Abeni        feeds an implicit RR node at the root of the hierarchy.
27604e65df9SPaolo Abeni      attribute-set: net-shaper
27704e65df9SPaolo Abeni      flags: [ admin-perm ]
27804e65df9SPaolo Abeni
27904e65df9SPaolo Abeni      do:
28004e65df9SPaolo Abeni        pre: net-shaper-nl-pre-doit
28104e65df9SPaolo Abeni        post: net-shaper-nl-post-doit
28204e65df9SPaolo Abeni        request:
28304e65df9SPaolo Abeni          attributes: *ns-binding
28404e65df9SPaolo Abeni
28504e65df9SPaolo Abeni    -
28604e65df9SPaolo Abeni      name: group
28704e65df9SPaolo Abeni      doc: |
28804e65df9SPaolo Abeni        Create or update a scheduling group, attaching the specified
28904e65df9SPaolo Abeni        @leaves shapers under the specified node identified by @handle.
29004e65df9SPaolo Abeni        The @leaves shapers scope must be @queue and the node shaper
29104e65df9SPaolo Abeni        scope must be either @node or @netdev.
29204e65df9SPaolo Abeni        When the node shaper has @node scope, if the @handle @id is not
29304e65df9SPaolo Abeni        specified, a new shaper of such scope is created, otherwise the
29404e65df9SPaolo Abeni        specified node must already exist.
29504e65df9SPaolo Abeni        When updating an existing node shaper, the specified @leaves are
29604e65df9SPaolo Abeni        added to the existing node; such node will also retain any preexisting
29704e65df9SPaolo Abeni        leave.
29804e65df9SPaolo Abeni        The @parent handle for a new node shaper defaults to the parent
29904e65df9SPaolo Abeni        of all the leaves, provided all the leaves share the same parent.
30004e65df9SPaolo Abeni        Otherwise @parent handle must be specified.
30104e65df9SPaolo Abeni        The user can optionally provide shaping attributes for the node
30204e65df9SPaolo Abeni        shaper.
30304e65df9SPaolo Abeni        The operation is atomic, on failure no change is applied to
30404e65df9SPaolo Abeni        the device shaping configuration, otherwise the @node shaper
30504e65df9SPaolo Abeni        full identifier, comprising @binding and @handle, is provided
30604e65df9SPaolo Abeni        as the reply.
30704e65df9SPaolo Abeni      attribute-set: net-shaper
30804e65df9SPaolo Abeni      flags: [ admin-perm ]
30904e65df9SPaolo Abeni
31004e65df9SPaolo Abeni      do:
31104e65df9SPaolo Abeni        pre: net-shaper-nl-pre-doit
31204e65df9SPaolo Abeni        post: net-shaper-nl-post-doit
31304e65df9SPaolo Abeni        request:
31404e65df9SPaolo Abeni          attributes:
31504e65df9SPaolo Abeni            - ifindex
31604e65df9SPaolo Abeni            - parent
31704e65df9SPaolo Abeni            - handle
31804e65df9SPaolo Abeni            - metric
31904e65df9SPaolo Abeni            - bw-min
32004e65df9SPaolo Abeni            - bw-max
32104e65df9SPaolo Abeni            - burst
32204e65df9SPaolo Abeni            - priority
32304e65df9SPaolo Abeni            - weight
32404e65df9SPaolo Abeni            - leaves
32504e65df9SPaolo Abeni        reply:
32604e65df9SPaolo Abeni          attributes: *ns-binding
327*14bba928SPaolo Abeni
328*14bba928SPaolo Abeni    -
329*14bba928SPaolo Abeni      name: cap-get
330*14bba928SPaolo Abeni      doc: |
331*14bba928SPaolo Abeni        Get the shaper capabilities supported by the given device
332*14bba928SPaolo Abeni        for the specified scope.
333*14bba928SPaolo Abeni      attribute-set: caps
334*14bba928SPaolo Abeni
335*14bba928SPaolo Abeni      do:
336*14bba928SPaolo Abeni        pre: net-shaper-nl-cap-pre-doit
337*14bba928SPaolo Abeni        post: net-shaper-nl-cap-post-doit
338*14bba928SPaolo Abeni        request:
339*14bba928SPaolo Abeni          attributes:
340*14bba928SPaolo Abeni            - ifindex
341*14bba928SPaolo Abeni            - scope
342*14bba928SPaolo Abeni        reply:
343*14bba928SPaolo Abeni          attributes: &cap-attrs
344*14bba928SPaolo Abeni            - ifindex
345*14bba928SPaolo Abeni            - scope
346*14bba928SPaolo Abeni            - support-metric-bps
347*14bba928SPaolo Abeni            - support-metric-pps
348*14bba928SPaolo Abeni            - support-nesting
349*14bba928SPaolo Abeni            - support-bw-min
350*14bba928SPaolo Abeni            - support-bw-max
351*14bba928SPaolo Abeni            - support-burst
352*14bba928SPaolo Abeni            - support-priority
353*14bba928SPaolo Abeni            - support-weight
354*14bba928SPaolo Abeni
355*14bba928SPaolo Abeni      dump:
356*14bba928SPaolo Abeni        pre: net-shaper-nl-cap-pre-dumpit
357*14bba928SPaolo Abeni        post: net-shaper-nl-cap-post-dumpit
358*14bba928SPaolo Abeni        request:
359*14bba928SPaolo Abeni          attributes:
360*14bba928SPaolo Abeni            - ifindex
361*14bba928SPaolo Abeni        reply:
362*14bba928SPaolo Abeni          attributes: *cap-attrs
363