net: introduce TX H/W shaping API
Subsystems (8)
Paolo Abeni
maintainerv3 cover net: introduce TX H/W shaping API
We have a plurality of shaping-related drivers API, but none flexible enough to meet existing demand from vendors[1].
This series introduces new device APIs to configure in a flexible way TX H/W shaping. The new functionalities are exposed via a newly defined generic netlink interface and include introspection capabilities. Some self-tests are included, on top of a dummy netdevsim implementation, and a basic implementation for the iavf driver.
Some usage examples:
* Configure shaping on a given queue:
./tools/net/ynl/cli.py --spec Documentation/netlink/specs/shaper.yaml \
--do set --json '{"ifindex":'$IFINDEX',
"shaper": {"handle":
{"scope": "queue", "id":'$QUEUEID' },
"bw-max": 2000000 }}'* Container B/W sharing
The orchestration infrastructure wants to group the container-related queues under a RR scheduling and limit the aggregate bandwidth:
./tools/net/ynl/cli.py --spec Documentation/netlink/specs/shaper.yaml \
--do group --json '{"ifindex":'$IFINDEX',
"inputs": [
{"handle": {"scope": "queue", "id":'$QID1' },
"weight": '$W1'},
{"handle": {"scope": "queue", "id":'$QID2' },
"weight": '$W2'}],
{"handle": {"scope": "queue", "id":'$QID3' },
"weight": '$W3'}],
"output": { "handle": {"scope":"netdev"},
"output": { "handle": {"scope":"netdev"},
"bw-max": 10000000}}'{'handle': {'id': 0, 'scope': 'netdev'}}
* Delegation
A container wants to set a B/W limit on 2 of its own queues:
./tools/net/ynl/cli.py --spec Documentation/netlink/specs/shaper.yaml \
--do group --json '{"ifindex":'$IFINDEX',
"inputs": [
{"handle": {"scope": "queue", "id":'$QID1' },
"weight": '$W1'},
{"handle": {"scope": "queue", "id":'$QID2' },
"weight": '$W2'}],
"output": { "handle": {"scope":"detached"},
"bw-max": 5000000}}'{'handle': {'id': 0, 'scope': 'detached'}}
* Cleanup:
Deleting a single queue shaper:
./tools/net/ynl/cli.py --spec Documentation/netlink/specs/shaper.yaml \
--do delete --json \
'{"ifindex":'$IFINDEX',
"handle": {"scope": "queue", "id":'$QID1' }}'deleting the last shaper under a group deletes the group, too:
./tools/net/ynl/cli.py --spec Documentation/netlink/specs/shaper.yaml \
--do delete --json \
'{"ifindex":'$IFINDEX',
"handle": {"scope": "queue", "id":'$QID2' }}'
./tools/net/ynl/cli.py --spec Documentation/netlink/specs/shaper.yaml \
--do get --json '{"ifindex":'$IF',
"handle": { "scope": "detached", "id": 0}}'
Netlink error: Invalid argument
nl_len = 80 (64) nl_flags = 0x300 nl_type = 2
error: -22
extack: {'msg': "Can't find shaper for handle 10000000"}Changes from RFC v2:
- added patch 1
- fixed deprecated API usage
RFC v2: https://lore.kernel.org/netdev/[email protected]/
Changes from RFC v1:
- set() and delete() ops operate on a single shaper
- added group() op to allow grouping and nesting
- split the NL implementation into multiple patches to help reviewing
RFC v1: https://lore.kernel.org/netdev/[email protected]/
[1] https://lore.kernel.org/netdev/[email protected]/
Paolo Abeni (8):
tools: ynl: lift an assumption about spec file name
netlink: spec: add shaper YAML spec
net-shapers: implement NL get operation
net-shapers: implement NL set and delete operations
net-shapers: implement NL group operation
netlink: spec: add shaper introspection support
net: shaper: implement introspection support
testing: net-drv: add basic shaper test
Sudheer Mogilappagari (2):
iavf: Add net_shaper_ops support
iavf: add support to exchange qos capabilities
Wenjun Wu (2):
virtchnl: support queue rate limit and quanta size configuration
ice: Support VF queue rate limit and quanta size configuration
Documentation/netlink/specs/shaper.yaml | 337 ++++++ Documentation/networking/kapi.rst | 3 + MAINTAINERS | 1 + drivers/net/Kconfig | 1 + drivers/net/ethernet/intel/Kconfig | 1 + drivers/net/ethernet/intel/iavf/iavf.h | 13 + drivers/net/ethernet/intel/iavf/iavf_main.c | 215 +++- drivers/net/ethernet/intel/iavf/iavf_txrx.h | 2 + .../net/ethernet/intel/iavf/iavf_virtchnl.c | 157 ++- drivers/net/ethernet/intel/ice/ice.h | 2 + drivers/net/ethernet/intel/ice/ice_base.c | 2 + drivers/net/ethernet/intel/ice/ice_common.c | 21 + .../net/ethernet/intel/ice/ice_hw_autogen.h | 8 + drivers/net/ethernet/intel/ice/ice_txrx.h | 1 + drivers/net/ethernet/intel/ice/ice_type.h | 1 + drivers/net/ethernet/intel/ice/ice_vf_lib.h | 8 + drivers/net/ethernet/intel/ice/ice_virtchnl.c | 333 ++++++ drivers/net/ethernet/intel/ice/ice_virtchnl.h | 11 + .../intel/ice/ice_virtchnl_allowlist.c | 6 + drivers/net/netdevsim/netdev.c | 37 + include/linux/avf/virtchnl.h | 119 +++ include/linux/netdevice.h | 17 + include/net/net_shaper.h | 169 +++ include/uapi/linux/net_shaper.h | 91 ++ net/Kconfig | 3 + net/Makefile | 1 + net/core/dev.c | 2 + net/core/dev.h | 6 + net/shaper/Makefile | 9 + net/shaper/shaper.c | 963 ++++++++++++++++++ net/shaper/shaper_nl_gen.c | 142 +++ net/shaper/shaper_nl_gen.h | 30 + tools/net/ynl/ynl-gen-c.py | 6 +- tools/testing/selftests/drivers/net/Makefile | 1 + tools/testing/selftests/drivers/net/shaper.py | 267 +++++ .../testing/selftests/net/lib/py/__init__.py | 1 + tools/testing/selftests/net/lib/py/ynl.py | 5 + 37 files changed, 2988 insertions(+), 4 deletions(-) create mode 100644 Documentation/netlink/specs/shaper.yaml create mode 100644 include/net/net_shaper.h create mode 100644 include/uapi/linux/net_shaper.h create mode 100644 net/shaper/Makefile create mode 100644 net/shaper/shaper.c create mode 100644 net/shaper/shaper_nl_gen.c create mode 100644 net/shaper/shaper_nl_gen.h create mode 100755 tools/testing/selftests/drivers/net/shaper.py
Signature · 1 line
2.45.2
Paolo Abeni
maintainerPATCH v3 1/12 tools: ynl: lift an assumption about spec file name
Currently the parsing code generator assumes that the yaml specification file name and the main 'name' attribute carried inside correspond, that is the field is the c-name representation of the file basename.
The above assumption held true within the current tree, but will be hopefully broken soon by the upcoming net shaper specification. Additionally, it makes the field 'name' itself useless.
Lift the assumption, always computing the generated include file name from the generated c file name.
--- tools/net/ynl/ynl-gen-c.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/net/ynl/ynl-gen-c.py +4 -2
@@ -2668,13 +2668,15 @@ def main(): cw.p('#define ' + hdr_prot) cw.nl() + hdr_file=os.path.basename(args.out_file[:-2]) + ".h" + if args.mode == 'kernel': cw.p('#include <net/netlink.h>') cw.p('#include <net/genetlink.h>') cw.nl() if not args.header: if args.out_file: - cw.p(f'#include "{os.path.basename(args.out_file[:-2])}.h"') + cw.p(f'#include "{hdr_file}"') cw.nl() headers = ['uapi/' + parsed.uapi_header] headers += parsed.kernel_family.get('headers', [])
@@ -2686,7 +2688,7 @@ def main(): if family_contains_bitfield32(parsed): cw.p('#include <linux/netlink.h>') else: - cw.p(f'#include "{parsed.name}-user.h"') + cw.p(f'#include "{hdr_file}"') cw.p('#include "ynl.h"') headers = [parsed.uapi_header] for definition in parsed['definitions']:
Signature · 1 line
2.45.2
Paolo Abeni
maintainerPATCH v3 2/12 netlink: spec: add shaper YAML spec
In reply to Paolo AbeniDefine the user-space visible interface to query, configure and delete network shapers via yaml definition.
Add dummy implementations for the relevant NL callbacks.
set() and delete() operations touch a single shaper creating/updating or deleting it.
The group() operation creates a shaper's group, nesting multiple input shapers under the specified output shaper.
---
RFC v1 -> RFC v2:
- u64 -> uint
- net_shapers -> net-shapers
- documented all the attributes
- dropped [ admin-perm ] for get() op
- group op
- set/delete touch a single shaper
--- Documentation/netlink/specs/shaper.yaml | 262 ++++++++++++++++++++++++ MAINTAINERS | 1 + include/uapi/linux/net_shaper.h | 74 +++++++ net/Kconfig | 3 + net/Makefile | 1 + net/shaper/Makefile | 9 + net/shaper/shaper.c | 34 +++ net/shaper/shaper_nl_gen.c | 117 +++++++++++ net/shaper/shaper_nl_gen.h | 27 +++ 9 files changed, 528 insertions(+) create mode 100644 Documentation/netlink/specs/shaper.yaml create mode 100644 include/uapi/linux/net_shaper.h create mode 100644 net/shaper/Makefile create mode 100644 net/shaper/shaper.c create mode 100644 net/shaper/shaper_nl_gen.c create mode 100644 net/shaper/shaper_nl_gen.h
Documentation/netlink/specs/shaper.yaml new file +262 -0
@@ -0,0 +1,262 @@ +# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) + +name: net-shaper + +doc: Network device HW Rate Limiting offload + +definitions: + - + type: enum + name: scope + doc: the different scopes where a shaper can be attached + render-max: true + entries: + - name: unspec + doc: The scope is not specified + - + name: port + doc: The root for the whole H/W + - + name: netdev + doc: The main shaper for the given network device. + - + name: queue + doc: The shaper is attached to the given device queue. + - + name: detached + doc: | + The shaper is not attached to any user-visible network + device component and allows nesting and grouping of + queues or others detached shapers. + - + type: enum + name: metric + doc: different metric each shaper can support + entries: + - + name: bps + doc: Shaper operates on a bits per second basis + - + name: pps + doc: Shaper operates on a packets per second basis + +attribute-sets: + - + name: net-shaper + attributes: + - + name: ifindex + type: u32 + doc: Interface index owing the specified shaper[s] + - + name: handle + type: nest + nested-attributes: handle + doc: Unique identifier for the given shaper + - + name: metric + type: u32 + enum: metric + doc: Metric used by the given shaper for bw-min, bw-max and burst + - + name: bw-min + type: uint + doc: Minimum guaranteed B/W for the given shaper + - + name: bw-max + type: uint + doc: Shaping B/W for the given shaper or 0 when unlimited + - + name: burst + type: uint + doc: Maximum burst-size for bw-min and bw-max + - + name: priority + type: u32 + doc: Scheduling priority for the given shaper + - + name: weight + type: u32 + doc: | + Weighted round robin weight for given shaper. + The scheduling is applied to all the sibling + shapers with the same priority + - + name: scope + type: u32 + enum: scope + doc: The given handle scope + - + name: id + type: u32 + doc: | + The given handle id. The id semantic depends on the actual + scope, e.g. for 'queue' scope it's the queue id, for + 'detached' scope it's the shaper group identifier. + - + name: parent + type: nest + nested-attributes: handle + doc: | + Identifier for the parent of the affected shaper, + The parent handle value is implied by the shaper handle itself, + except for the output shaper in the 'group' operation. + - + name: inputs + type: nest + multi-attr: true + nested-attributes: ns-info + doc: | + Describes a set of inputs shapers for a @group operation + - + name: output + type: nest + nested-attributes: ns-output-info + doc: | + Describes the output shaper for a @group operation + Differently from @inputs and @shaper allow specifying + the shaper parent handle, too. + + - + name: shaper + type: nest + nested-attributes: ns-info + doc: | + Describes a single shaper for a @set operation + - + name: handle + subset-of: net-shaper + attributes: + - + name: scope + - + name: id + - + name: ns-info + subset-of: net-shaper + attributes: + - + name: handle + - + name: metric + - + name: bw-min + - + name: bw-max + - + name: burst + - + name: priority + - + name: weight + - + name: ns-output-info + subset-of: net-shaper + attributes: + - + name: parent + - + name: handle + - + name: metric + - + name: bw-min + - + name: bw-max + - + name: burst + - + name: priority + - + name: weight + +operations: + list: + - + name: get + doc: | + Get / Dump information about a/all the shaper for a given device + attribute-set: net-shaper + + do: + request: + attributes: + - ifindex + - handle + reply: + attributes: &ns-attrs + - parent + - handle + - metric + - bw-min + - bw-max + - burst + - priority + - weight + + dump: + request: + attributes: + - ifindex + reply: + attributes: *ns-attrs + - + name: set + doc: | + Create or configures the specified shaper. + On failures the extack is set accordingly. + Can't create @detached scope shaper, use + the @group operation instead. + attribute-set: net-shaper + flags: [ admin-perm ] + + do: + request: + attributes: + - ifindex + - shaper + + - + name: delete + doc: | + Clear (remove) the specified shaper. If after the removal + the parent shaper has no more children and the parent + shaper scope is @detached, even the parent is deleted, + recursively. + On failures the extack is set accordingly. + attribute-set: net-shaper + flags: [ admin-perm ] + + do: + request: + attributes: + - ifindex + - handle + + - + name: group + doc: | + Group the specified input shapers under the specified + output shaper, eventually creating the latter, if needed. + Input shapers scope must be either @queue or @detached. + Output shaper scope must be either @detached or @netdev. + When using an output @detached scope shaper, if the + @handle @id is not specified, a new shaper of such scope + is created and, otherwise the specified output shaper + must be already existing. + The operation is atomic, on failures the extack is set + accordingly and no change is applied to the device + shaping configuration, otherwise the output shaper + handle is provided as reply. + attribute-set: net-shaper + flags: [ admin-perm ] + + do: + request: + attributes: + - ifindex + - inputs + - output + reply: + attributes: + - handle
MAINTAINERS +1 -0
@@ -15881,6 +15881,7 @@ F: include/linux/inetdevice.h F: include/linux/netdevice.h F: include/uapi/linux/cn_proc.h F: include/uapi/linux/if_* +F: include/uapi/linux/net_shaper.h F: include/uapi/linux/netdevice.h X: drivers/net/wireless/
include/uapi/linux/net_shaper.h new file +74 -0
74 lines not on this page · raw message
net/Kconfig +3 -0
@@ -66,6 +66,9 @@ config SKB_DECRYPTED config SKB_EXTENSIONS bool +config NET_SHAPER + bool + menu "Networking options" source "net/packet/Kconfig"
net/Makefile +1 -0
@@ -79,3 +79,4 @@ obj-$(CONFIG_XDP_SOCKETS) += xdp/ obj-$(CONFIG_MPTCP) += mptcp/ obj-$(CONFIG_MCTP) += mctp/ obj-$(CONFIG_NET_HANDSHAKE) += handshake/ +obj-$(CONFIG_NET_SHAPER) += shaper/
net/shaper/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Makefile for the Generic HANDSHAKE service +# +# Copyright (c) 2024, Red Hat, Inc. +# + +obj-y += shaper.o shaper_nl_gen.o +
net/shaper/shaper.c new file +34 -0
@@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include <linux/kernel.h> +#include <linux/skbuff.h> + +#include "shaper_nl_gen.h" + +int net_shaper_nl_get_doit (struct sk_buff *skb,struct genl_info *info) +{ +return -EOPNOTSUPP ; +} + +int net_shaper_nl_get_dumpit (struct sk_buff *skb, +struct netlink_callback *cb) +{ +return -EOPNOTSUPP ; +} + +int net_shaper_nl_set_doit (struct sk_buff *skb,struct genl_info *info) +{ +return -EOPNOTSUPP ; +} + +int net_shaper_nl_delete_doit (struct sk_buff *skb,struct genl_info *info) +{ +return -EOPNOTSUPP ; +} + +static int __init shaper_init (void ) +{ +return genl_register_family (&net_shaper_nl_family); +} + +subsys_initcall (shaper_init);
net/shaper/shaper_nl_gen.c new file +117 -0
117 lines not on this page · raw message
net/shaper/shaper_nl_gen.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/shaper.yaml */ +/* YNL-GEN kernel header */ + +#ifndef _LINUX_NET_SHAPER_GEN_H +#define _LINUX_NET_SHAPER_GEN_H + +#include <net/netlink.h> +#include <net/genetlink.h> + +#include <uapi/linux/net_shaper.h> + +/* Common nested types */ +extern const struct nla_policy net_shaper_handle_nl_policy[NET_SHAPER_A_ID +1 ]; +extern const struct nla_policy net_shaper_ns_info_nl_policy[NET_SHAPER_A_WEIGHT +1 ]; +extern const struct nla_policy net_shaper_ns_output_info_nl_policy[NET_SHAPER_A_PARENT +1 ]; + +int net_shaper_nl_get_doit (struct sk_buff *skb,struct genl_info *info); +int net_shaper_nl_get_dumpit (struct sk_buff *skb,struct netlink_callback *cb); +int net_shaper_nl_set_doit (struct sk_buff *skb,struct genl_info *info); +int net_shaper_nl_delete_doit (struct sk_buff *skb,struct genl_info *info); +int net_shaper_nl_group_doit (struct sk_buff *skb,struct genl_info *info); + +extern struct genl_family net_shaper_nl_family; + +#endif /* _LINUX_NET_SHAPER_GEN_H */
Signature · 1 line
2.45.2
Donald Hunter
maintainerRe: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
Documentation/netlink/specs/shaper.yaml
Quoted 5 lines · Paolo Abeni
Documentation/netlink/specs/shaper.yaml new file +0
-0
It's probably more user-friendly to use the same filename as the spec name, so net-shaper.yaml
Documentation/netlink/specs/shaper.yaml line 11
Quoted 12 lines
Documentation/netlink/specs/shaper.yaml new file +11
-0@@ -0,0 +1,262 @@ +# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) + +name: net-shaper + +doc: Network device HW Rate Limiting offload + +definitions: + - + type: enum + name: scope + doc: the different scopes where a shaper can be attached
Nit: upper case 'The' to be consistent with rest of docs.
Documentation/netlink/specs/shaper.yaml line 15
Quoted 4 lines
Documentation/netlink/specs/shaper.yaml new file +4
-0+ render-max: true + entries: + - name: unspec + doc: The scope is not specified
What are the semantics of 'unspec' ? When can it be used?
Documentation/netlink/specs/shaper.yaml line 21
Quoted 6 lines
Documentation/netlink/specs/shaper.yaml new file +6
-0+ - + name: port + doc: The root for the whole H/W + - + name: netdev + doc: The main shaper for the given network device.
What are the semantic differences between netdev and port?
Documentation/netlink/specs/shaper.yaml line 30
Quoted 9 lines
Documentation/netlink/specs/shaper.yaml new file +9
-0+ - + name: queue + doc: The shaper is attached to the given device queue. + - + name: detached + doc: | + The shaper is not attached to any user-visible network + device component and allows nesting and grouping of + queues or others detached shapers.
I assume that shapers are always owned by the netdev regardless of attach status?
Documentation/netlink/specs/shaper.yaml line 34
Quoted 4 lines
Documentation/netlink/specs/shaper.yaml new file +4
-0+ - + type: enum + name: metric + doc: different metric each shaper can support
Nit: upper case here as well.
Quoted 6 lines
Documentation/netlink/specs/shaper.yaml new file +6
-0+ entries: + - + name: bps + doc: Shaper operates on a bits per second basis + - + name: pps
Documentation/netlink/specs/shaper.yaml line 50
Quoted 10 lines
Documentation/netlink/specs/shaper.yaml new file +10
-0+ doc: Shaper operates on a packets per second basis + +attribute-sets: + - + name: net-shaper + attributes: + - + name: ifindex + type: u32 + doc: Interface index owing the specified shaper[s]
Typo: this should be 'owning' ?
Quoted 35 lines
Documentation/netlink/specs/shaper.yaml new file +35
-0+ - + name: handle + type: nest + nested-attributes: handle + doc: Unique identifier for the given shaper + - + name: metric + type: u32 + enum: metric + doc: Metric used by the given shaper for bw-min, bw-max and burst + - + name: bw-min + type: uint + doc: Minimum guaranteed B/W for the given shaper + - + name: bw-max + type: uint + doc: Shaping B/W for the given shaper or 0 when unlimited + - + name: burst + type: uint + doc: Maximum burst-size for bw-min and bw-max + - + name: priority + type: u32 + doc: Scheduling priority for the given shaper + - + name: weight + type: u32 + doc: | + Weighted round robin weight for given shaper. + The scheduling is applied to all the sibling + shapers with the same priority + - + name: scope
Documentation/netlink/specs/shaper.yaml line 95
Quoted 10 lines
Documentation/netlink/specs/shaper.yaml new file +10
-0+ type: u32 + enum: scope + doc: The given handle scope + - + name: id + type: u32 + doc: | + The given handle id. The id semantic depends on the actual + scope, e.g. for 'queue' scope it's the queue id, for + 'detached' scope it's the shaper group identifier.
If scope and id are only ever used as attributes of a handle then they would be better specified as a separate attribute-set, instead of mixing them in here and using a subset.
You use 'quoted' references here and @refs elsewhere. It would be good to be consistent. See note below about @ in htmldocs.
Documentation/netlink/specs/shaper.yaml line 103
Quoted 8 lines
Documentation/netlink/specs/shaper.yaml new file +8
-0+ - + name: parent + type: nest + nested-attributes: handle + doc: | + Identifier for the parent of the affected shaper, + The parent handle value is implied by the shaper handle itself, + except for the output shaper in the 'group' operation.
Nit: quoted ref again here
Documentation/netlink/specs/shaper.yaml line 110
Quoted 7 lines
Documentation/netlink/specs/shaper.yaml new file +7
-0+ - + name: inputs + type: nest + multi-attr: true + nested-attributes: ns-info + doc: | + Describes a set of inputs shapers for a @group operation
The @group renders exactly as-is in the generated htmldocs. There may be a more .rst friendly markup you can use that will render better.
Documentation/netlink/specs/shaper.yaml line 119
Quoted 9 lines
Documentation/netlink/specs/shaper.yaml new file +9
-0+ - + name: output + type: nest + nested-attributes: ns-output-info + doc: | + Describes the output shaper for a @group operation + Differently from @inputs and @shaper allow specifying + the shaper parent handle, too. +
Nit: remove the extra blank line here
Quoted 112 lines
Documentation/netlink/specs/shaper.yaml new file +112
-0+ - + name: shaper + type: nest + nested-attributes: ns-info + doc: | + Describes a single shaper for a @set operation + - + name: handle + subset-of: net-shaper + attributes: + - + name: scope + - + name: id + - + name: ns-info + subset-of: net-shaper + attributes: + - + name: handle + - + name: metric + - + name: bw-min + - + name: bw-max + - + name: burst + - + name: priority + - + name: weight + - + name: ns-output-info + subset-of: net-shaper + attributes: + - + name: parent + - + name: handle + - + name: metric + - + name: bw-min + - + name: bw-max + - + name: burst + - + name: priority + - + name: weight + +operations: + list: + - + name: get + doc: | + Get / Dump information about a/all the shaper for a given device + attribute-set: net-shaper + + do: + request: + attributes: + - ifindex + - handle + reply: + attributes: &ns-attrs + - parent + - handle + - metric + - bw-min + - bw-max + - burst + - priority + - weight + + dump: + request: + attributes: + - ifindex + reply: + attributes: *ns-attrs + - + name: set + doc: | + Create or configures the specified shaper. + On failures the extack is set accordingly. + Can't create @detached scope shaper, use + the @group operation instead. + attribute-set: net-shaper + flags: [ admin-perm ] + + do: + request: + attributes: + - ifindex + - shaper + + - + name: delete + doc: | + Clear (remove) the specified shaper. If after the removal + the parent shaper has no more children and the parent + shaper scope is @detached, even the parent is deleted, + recursively. + On failures the extack is set accordingly. + attribute-set: net-shaper + flags: [ admin-perm ] + + do: + request:
Documentation/netlink/specs/shaper.yaml line 241
Quoted 10 lines
Documentation/netlink/specs/shaper.yaml new file +10
-0+ attributes: + - ifindex + - handle + + - + name: group + doc: | + Group the specified input shapers under the specified + output shaper, eventually creating the latter, if needed. + Input shapers scope must be either @queue or @detached.
It says above that you cannot create a detached shaper, so how do you create one to use as an input shaper here? Is this group op more like a multi-create op?
Documentation/netlink/specs/shaper.yaml line 252
Quoted 11 lines
Documentation/netlink/specs/shaper.yaml new file +11
-0+ Output shaper scope must be either @detached or @netdev. + When using an output @detached scope shaper, if the + @handle @id is not specified, a new shaper of such scope + is created and, otherwise the specified output shaper + must be already existing. + The operation is atomic, on failures the extack is set + accordingly and no change is applied to the device + shaping configuration, otherwise the output shaper + handle is provided as reply. + attribute-set: net-shaper + flags: [ admin-perm ]
Does there need to be a reciprocal 'ungroup' operation? Without it, create / group / delete seems like they will have ambiguous semantics.
Quoted 9 lines
Documentation/netlink/specs/shaper.yaml new file +9
-0+ do: + request: + attributes: + - ifindex + - inputs + - output + reply: + attributes: + - handle
Paolo Abeni
maintainerRe: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
Quoted 10 lines · Donald Hunter
Documentation/netlink/specs/shaper.yaml
Quoted 5 lines · Paolo Abeni
Documentation/netlink/specs/shaper.yaml new file +0
-0It's probably more user-friendly to use the same filename as the spec name, so
net-shaper.yaml
No big objection on my side, but if we enforce 'Name:' to be $(basename $file .yaml), the 'Name' field becomes redundant.
[...]
Quoted 6 lines
Documentation/netlink/specs/shaper.yaml line 15
Quoted 4 lines
Documentation/netlink/specs/shaper.yaml new file +4
-0+ render-max: true + entries: + - name: unspec + doc: The scope is not specifiedWhat are the semantics of 'unspec' ? When can it be used?
I guess at this point it can be dropped. It was introduced in a previous incarnation to represent the port parent - the port does not have a parent, being the root of the hierarchy.
Quoted 8 lines
Documentation/netlink/specs/shaper.yaml line 21
Quoted 6 lines
Documentation/netlink/specs/shaper.yaml new file +6
-0+ - + name: port + doc: The root for the whole H/W + - + name: netdev + doc: The main shaper for the given network device.What are the semantic differences between netdev and port?
netdev == Linux network device
port == wire plug
Quoted 10 lines
Documentation/netlink/specs/shaper.yaml line 30
Quoted 9 lines
Documentation/netlink/specs/shaper.yaml new file +9
-0+ - + name: queue + doc: The shaper is attached to the given device queue. + - + name: detached + doc: | + The shaper is not attached to any user-visible network + device component and allows nesting and grouping of + queues or others detached shapers.
Quoted 2 lines
I assume that shapers are always owned by the netdev regardless of attach status?
If you mean that it's up to the netdev clean them up on (netdev) removal, yes.
Quoted 10 lines
Documentation/netlink/specs/shaper.yaml line 110
Quoted 7 lines
+>> + -
Documentation/netlink/specs/shaper.yaml new file +6
-0+ name: inputs + type: nest + multi-attr: true + nested-attributes: ns-info + doc: | + Describes a set of inputs shapers for a @group operationThe @group renders exactly as-is in the generated htmldocs. There may be a more .rst friendly markup you can use that will render better.
Uhm... AFAICS the problem is the target (e.g. 'group') is outside the htmldoc section itself, I can't find any existing markup to serve this purpose well. What about sticking to quotes '' everywhere?
FTR, I used @ following the kdoc style.
[...]
Quoted 10 lines
Documentation/netlink/specs/shaper.yaml line 241
Quoted 6 lines
Documentation/netlink/specs/shaper.yaml new file +6
-0+ - + name: group + doc: | + Group the specified input shapers under the specified + output shaper, eventually creating the latter, if needed. + Input shapers scope must be either @queue or @detached.It says above that you cannot create a detached shaper, so how do you create one to use as an input shaper here? Is this group op more like a multi-create op?
The group operation has the main goal of configuring a single WRR or SP scheduling group atomically. It can creates the needed shapers as needed, see below.
The need for such operation sparks from some H/W constraints:
https://lore.kernel.org/netdev/[email protected]/
Quoted 12 lines
Documentation/netlink/specs/shaper.yaml line 252
Quoted 11 lines
Documentation/netlink/specs/shaper.yaml new file +11
-0+ Output shaper scope must be either @detached or @netdev. + When using an output @detached scope shaper, if the + @handle @id is not specified, a new shaper of such scope + is created and, otherwise the specified output shaper + must be already existing. + The operation is atomic, on failures the extack is set + accordingly and no change is applied to the device + shaping configuration, otherwise the output shaper + handle is provided as reply. + attribute-set: net-shaper + flags: [ admin-perm ]
Quoted 2 lines
Does there need to be a reciprocal 'ungroup' operation? Without it, create / group / delete seems like they will have ambiguous semantics.
I guess we need a better description. Can you please tell where/how the current one is ambiguous?
Thanks,
Paolo
Re: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
Quoted 12 lines · Thu, Aug 01, 2024 at 04:31:04PM CEST, [email protected] wrote:
Quoted 10 lines · Donald Hunter
Documentation/netlink/specs/shaper.yaml
Quoted 5 lines · Paolo Abeni
Documentation/netlink/specs/shaper.yaml new file +0
-0It's probably more user-friendly to use the same filename as the spec name, so
net-shaper.yaml
Quoted 2 lines
No big objection on my side, but if we enforce 'Name:' to be $(basename $file .yaml), the 'Name' field becomes redundant.
I agree with Donald, better to stay consistent.
Quoted 7 lines
[...]
Quoted 5 lines
Quoted 4 lines
Documentation/netlink/specs/shaper.yaml new file +4
-0+ render-max: true + entries: + - name: unspec + doc: The scope is not specified
Quoted 14 lines
Quoted 1 line
What are the semantics of 'unspec' ? When can it be used?
I guess at this point it can be dropped. It was introduced in a previous incarnation to represent the port parent - the port does not have a parent, being the root of the hierarchy.
Quoted 8 lines
Documentation/netlink/specs/shaper.yaml line 21
Quoted 6 lines
Documentation/netlink/specs/shaper.yaml new file +6
-0+ - + name: port + doc: The root for the whole H/W + - + name: netdev + doc: The main shaper for the given network device.What are the semantic differences between netdev and port?
I'm happy that I'm not the only one in the dark :)
Quoted 16 lines
netdev == Linux network device
port == wire plugQuoted 12 lines
Documentation/netlink/specs/shaper.yaml line 30
Quoted 9 lines
Documentation/netlink/specs/shaper.yaml new file +9
-0+ - + name: queue + doc: The shaper is attached to the given device queue. + - + name: detached + doc: | + The shaper is not attached to any user-visible network + device component and allows nesting and grouping of + queues or others detached shapers.I assume that shapers are always owned by the netdev regardless of attach status?
But is it a "status"? It is a scope, can't change. I see you probably got the same confusion as I got, expecting that this can be attached somehow.
Quoted 4 lines
If you mean that it's up to the netdev clean them up on (netdev) removal, yes.
[...]
Donald Hunter
maintainerRe: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
In reply to Paolo AbeniQuoted 9 lines · Paolo Abeni
Quoted 8 lines · Donald Hunter
Quoted 6 lines · Paolo Abeni
Documentation/netlink/specs/shaper.yaml new file +6
-0+ name: inputs + type: nest + multi-attr: true + nested-attributes: ns-info + doc: | + Describes a set of inputs shapers for a @group operation
Quoted 8 lines
Quoted 2 lines
The @group renders exactly as-is in the generated htmldocs. There may be a more .rst friendly markup you can use that will render better.
Uhm... AFAICS the problem is the target (e.g. 'group') is outside the htmldoc section itself, I can't find any existing markup to serve this purpose well. What about sticking to quotes '' everywhere?
FTR, I used @ following the kdoc style.
Yeah, I was just thinking of using .rst markup like ``code`` or italics, but the meaning of @ is pretty obvious when reading the spec. If you stick with @ then we could always teach ynl-to-rst to render it as ``code``.
Quoted 30 lines
[...]
Quoted 9 lines
Documentation/netlink/specs/shaper.yaml line 241
Quoted 6 lines
Documentation/netlink/specs/shaper.yaml new file +6
-0+ - + name: group + doc: | + Group the specified input shapers under the specified + output shaper, eventually creating the latter, if needed. + Input shapers scope must be either @queue or @detached.It says above that you cannot create a detached shaper, so how do you create one to use as an input shaper here? Is this group op more like a multi-create op?
The group operation has the main goal of configuring a single WRR or SP scheduling group atomically. It can creates the needed shapers as needed, see below.
The need for such operation sparks from some H/W constraints:
https://lore.kernel.org/netdev/[email protected]/
Quoted 11 lines
Quoted 11 lines
Documentation/netlink/specs/shaper.yaml new file +11
-0+ Output shaper scope must be either @detached or @netdev. + When using an output @detached scope shaper, if the + @handle @id is not specified, a new shaper of such scope + is created and, otherwise the specified output shaper + must be already existing. + The operation is atomic, on failures the extack is set + accordingly and no change is applied to the device + shaping configuration, otherwise the output shaper + handle is provided as reply. + attribute-set: net-shaper + flags: [ admin-perm ]
Quoted 5 lines
Quoted 2 lines
Does there need to be a reciprocal 'ungroup' operation? Without it, create / group / delete seems like they will have ambiguous semantics.
I guess we need a better description. Can you please tell where/how the current one is ambiguous?
My expectation for 'group' would be to group existing things, with a reciprocal 'ungroup' operation. I think you intend 'group' to both be able to group existing shapers/groups and create a group of shapers.
Am I right in saying that delete lets you delete something from a group (with side-effect of deleting group if it becomes empty), or delete a whole group?
It feels a lot like each of 'set', 'group' and 'delete' are doing multiple things and the interaction between them all becomes challenging to describe, or to handle all the corner cases. I think part of the problem is the mixed terminology of input, output for groups, handle, parent for shapers and using detached to differentiate from 'implicitly attached to a resource'.
Perhaps the API would be better if you had:
- shaper-new
- shaper-delete
- shaper-get/dump
- shaper-set
- group-new
- group-delete
- group-get/dump
- group-set
If you went with Jakub's suggestion to give every shaper n x inputs and an output, then you could recombine groups and shapers and just have 4 ops. And you could rename 'detached' to 'shaper' so that an attachment is one of port, netdev, queue or shaper.
Paolo Abeni
maintainerRe: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
Hi all,
My replies this week will be delayed, please allow for some extra latency.
Quoted 18 lines · Donald Hunter
Quoted 16 lines · Paolo Abeni
Quoted 10 lines · Donald Hunter
Documentation/netlink/specs/shaper.yaml line 110
Quoted 6 lines · Paolo Abeni
Documentation/netlink/specs/shaper.yaml new file +6
-0+ name: inputs + type: nest + multi-attr: true + nested-attributes: ns-info + doc: | + Describes a set of inputs shapers for a @group operationThe @group renders exactly as-is in the generated htmldocs. There may be a more .rst friendly markup you can use that will render better.
Uhm... AFAICS the problem is the target (e.g. 'group') is outside the htmldoc section itself, I can't find any existing markup to serve this purpose well. What about sticking to quotes '' everywhere?
Quoted 6 lines
Quoted 1 line
FTR, I used @ following the kdoc style.
Yeah, I was just thinking of using .rst markup like ``code`` or
italics, but the meaning of @ is pretty obvious when reading the spec. If you stick with @ then we could always teach ynl-to-rst to render it as ``code``.
I'm fine with using @ everywhere.
Quoted 35 lines
Quoted 29 lines
[...]
Quoted 9 lines
Documentation/netlink/specs/shaper.yaml line 241
Quoted 6 lines
Documentation/netlink/specs/shaper.yaml new file +6
-0+ - + name: group + doc: | + Group the specified input shapers under the specified + output shaper, eventually creating the latter, if needed. + Input shapers scope must be either @queue or @detached.It says above that you cannot create a detached shaper, so how do you create one to use as an input shaper here? Is this group op more like a multi-create op?
The group operation has the main goal of configuring a single WRR or SP scheduling group atomically. It can creates the needed shapers as needed, see below.
The need for such operation sparks from some H/W constraints:
https://lore.kernel.org/netdev/[email protected]/
Quoted 11 lines
Quoted 11 lines
Documentation/netlink/specs/shaper.yaml new file +11
-0+ Output shaper scope must be either @detached or @netdev. + When using an output @detached scope shaper, if the + @handle @id is not specified, a new shaper of such scope + is created and, otherwise the specified output shaper + must be already existing. + The operation is atomic, on failures the extack is set + accordingly and no change is applied to the device + shaping configuration, otherwise the output shaper + handle is provided as reply. + attribute-set: net-shaper + flags: [ admin-perm ]Quoted 5 lines
Quoted 2 lines
Does there need to be a reciprocal 'ungroup' operation? Without it, create / group / delete seems like they will have ambiguous semantics.
I guess we need a better description. Can you please tell where/how the current one is ambiguous?
Quoted 7 lines
My expectation for 'group' would be to group existing things, with a reciprocal 'ungroup' operation. I think you intend 'group' to both be able to group existing shapers/groups and create a group of shapers.
Am I right in saying that delete lets you delete something from a group (with side-effect of deleting group if it becomes empty), or delete a whole group?
In the current incarnation, delete() on the whole group is explicitly forbidden. Jakub suggested we should allow such behavior for the delegation use-case.
Quoted 18 lines
It feels a lot like each of 'set', 'group' and 'delete' are doing multiple things and the interaction between them all becomes challenging to describe, or to handle all the corner case > I think part of the problem is the mixed terminology of input, output for groups, handle, parent for shapers and using detached to differentiate from 'implicitly attached to a resource'.
Perhaps the API would be better if you had:
- shaper-new
- shaper-delete
- shaper-get/dump
- shaper-set
- group-new
- group-delete
- group-get/dump
- group-set
Quoted 4 lines
If you went with Jakub's suggestion to give every shaper n x inputs and an output, then you could recombine groups and shapers and just have 4 ops. And you could rename 'detached' to 'shaper' so that an attachment is one of port, netdev, queue or shaper.
I'm unsure I read the above correctly, and I'm unsure it's in the same direction of Jakub's suggestion. AFACS the above is basically the same interface we proposed in the past iteration and was explicitly nacked from Jakub,
Additionally, one of the constraint to be addressed here is allowing to setup/configures all the nodes in a 'group' with a single operation, to deal with H/W limitations. How would the above address such constraint?
Thanks,
Paolo
Jakub Kicinski
maintainerRe: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
Quoted 16 lines · On Mon, 5 Aug 2024 16:35:29 +0200 Paolo Abeni wrote:
Quoted 11 lines
Perhaps the API would be better if you had:
- shaper-new
- shaper-delete
- shaper-get/dump
- shaper-set
- group-new
- group-delete
- group-get/dump
- group-setQuoted 4 lines
If you went with Jakub's suggestion to give every shaper n x inputs and an output, then you could recombine groups and shapers and just have 4 ops. And you could rename 'detached' to 'shaper' so that an attachment is one of port, netdev, queue or shaper.
Quoted 4 lines
I'm unsure I read the above correctly, and I'm unsure it's in the same direction of Jakub's suggestion. AFACS the above is basically the same interface we proposed in the past iteration and was explicitly nacked from Jakub,
To be clear I was against the low level twiddling APIs, where one has to separately create a mux/group/scheduler and "move" all its children under it one by one. (due to the problems it creates with atomic transitions between configurations).
Having shapers separate from the scheduling hierarchy doesn't seem bad, tho I haven't gone thru all the considerations in my head.
Quoted 3 lines
Additionally, one of the constraint to be addressed here is allowing to setup/configures all the nodes in a 'group' with a single operation, to deal with H/W limitations. How would the above address such constraint?
FWIW I think the naming is the major source of confusion :(
Re: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
In reply to Paolo AbeniQuoted 51 lines · Tue, Jul 30, 2024 at 10:39:45PM CEST, [email protected] wrote:
Define the user-space visible interface to query, configure and delete network shapers via yaml definition.
Add dummy implementations for the relevant NL callbacks.
set()anddelete()operations touch a single shaper creating/updating or deleting it.
Thegroup()operation creates a shaper's group, nesting multiple input shapers under the specified output shaper.Signed-off-by Paolo Abeni <[email protected]>---
RFC v1 -> RFC v2:
- u64 -> uint
-net_shapers-> net-shapers
- documented all the attributes
- dropped [ admin-perm ] forget()op
- group op
- set/delete touch a single shaper
---Documentation/netlink/specs/shaper.yaml | 262 ++++++++++++++++++++++++ MAINTAINERS | 1 + include/uapi/linux/net_shaper.h | 74 +++++++ net/Kconfig | 3 + net/Makefile | 1 + net/shaper/Makefile | 9 + net/shaper/shaper.c | 34 +++ net/shaper/shaper_nl_gen.c | 117 +++++++++++ net/shaper/shaper_nl_gen.h | 27 +++ 9 files changed, 528 insertions(+)create mode 100644
Documentation/netlink/specs/shaper.yamlcreate mode 100644include/uapi/linux/net_shaper.hcreate mode 100644net/shaper/Makefile
create mode 100644net/shaper/shaper.c
create mode 100644net/shaper/shaper_nl_gen.ccreate mode 100644net/shaper/shaper_nl_gen.hDocumentation/netlink/specs/shaper.yaml new file +8
-0@@ -0,0 +1,262 @@ +# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) + +name: net-shaper + +doc: Network device HW Rate Limiting offload + +definitions: + -
Documentation/netlink/specs/shaper.yaml line 18
Quoted 10 lines
Documentation/netlink/specs/shaper.yaml new file +10
-0+ type: enum + name: scope + doc: the different scopes where a shaper can be attached + render-max: true + entries: + - name: unspec + doc: The scope is not specified + - + name: port + doc: The root for the whole H/W
What is this "port"?
Documentation/netlink/specs/shaper.yaml line 30
Quoted 12 lines
Documentation/netlink/specs/shaper.yaml new file +12
-0+ - + name: netdev + doc: The main shaper for the given network device. + - + name: queue + doc: The shaper is attached to the given device queue. + - + name: detached + doc: | + The shaper is not attached to any user-visible network + device component and allows nesting and grouping of + queues or others detached shapers.
What is the purpose of the "detached" thing?
Quoted 12 lines
Documentation/netlink/specs/shaper.yaml new file +12
-0+ - + type: enum + name: metric + doc: different metric each shaper can support + entries: + - + name: bps + doc: Shaper operates on a bits per second basis + - + name: pps + doc: Shaper operates on a packets per second basis +
[..]
Quoted 65 lines
Documentation/netlink/specs/shaper.yaml new file +65
-0+ +operations: + list: + - + name: get + doc: | + Get / Dump information about a/all the shaper for a given device + attribute-set: net-shaper + + do: + request: + attributes: + - ifindex + - handle + reply: + attributes: &ns-attrs + - parent + - handle + - metric + - bw-min + - bw-max + - burst + - priority + - weight + + dump: + request: + attributes: + - ifindex + reply: + attributes: *ns-attrs + - + name: set + doc: | + Create or configures the specified shaper. + On failures the extack is set accordingly. + Can't create @detached scope shaper, use + the @group operation instead. + attribute-set: net-shaper + flags: [ admin-perm ] + + do: + request: + attributes: + - ifindex + - shaper + + - + name: delete + doc: | + Clear (remove) the specified shaper. If after the removal + the parent shaper has no more children and the parent + shaper scope is @detached, even the parent is deleted, + recursively. + On failures the extack is set accordingly. + attribute-set: net-shaper + flags: [ admin-perm ] + + do: + request: + attributes: + - ifindex + - handle + + -
Documentation/netlink/specs/shaper.yaml line 246
Quoted 10 lines
Documentation/netlink/specs/shaper.yaml new file +10
-0+ name: group + doc: | + Group the specified input shapers under the specified + output shaper, eventually creating the latter, if needed. + Input shapers scope must be either @queue or @detached. + Output shaper scope must be either @detached or @netdev. + When using an output @detached scope shaper, if the + @handle @id is not specified, a new shaper of such scope + is created and, otherwise the specified output shaper + must be already existing.
I'm lost. Could this designt be described in details in the doc I asked in the cover letter? :/ Please.
Quoted 5 lines
Documentation/netlink/specs/shaper.yaml new file +5
-0+ The operation is atomic, on failures the extack is set + accordingly and no change is applied to the device + shaping configuration, otherwise the output shaper + handle is provided as reply. + attribute-set: net-shaper
[..]
Jakub Kicinski
maintainerRe: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
Quoted 13 lines · On Thu, 1 Aug 2024 15:10:50 +0200 Jiri Pirko wrote:
Documentation/netlink/specs/shaper.yaml line 30
Quoted 12 lines
Documentation/netlink/specs/shaper.yaml new file +12
-0+ - + name: netdev + doc: The main shaper for the given network device. + - + name: queue + doc: The shaper is attached to the given device queue. + - + name: detached + doc: | + The shaper is not attached to any user-visible network + device component and allows nesting and grouping of + queues or others detached shapers.
Quoted 1 line
What is the purpose of the "detached" thing?
FWIW I also find the proposed model and naming confusing, but didn't want to object too hard in case it was just me. The model conflates attachment points with shapers themselves, and (which perhaps is more subjective) shapers with mux nodes.
This is already visible in the first example of the cover letter:
./tools/net/ynl/cli.py --spec Documentation/netlink/specs/shaper.yaml \
--do set --json '{"ifindex":'$IFINDEX',
"shaper": {"handle":
{"scope": "queue", "id":'$QUEUEID' },
"bw-max": 2000000 }}'We are "set"ting a shaper on a queue, not "add"ing it, because all attachment points implicitly have shapers(?) In my mind attachment points is where traffic comes from or goes to, shapers must be created to exist. And _every_ shaper has an ingress and egress, not just the ones in the middle (i.e. which aren't directly next to an attachment point) :(
Paolo Abeni
maintainerRe: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
In reply to Jiri PirkoQuoted 12 lines · Jiri Pirko
Documentation/netlink/specs/shaper.yaml line 18
Quoted 10 lines · Tue, Jul 30, 2024 at 10:39:45PM CEST, [email protected] wrote:
Documentation/netlink/specs/shaper.yaml new file +10
-0+ type: enum + name: scope + doc: the different scopes where a shaper can be attached + render-max: true + entries: + - name: unspec + doc: The scope is not specified + - + name: port + doc: The root for the whole H/W
Quoted 1 line
What is this "port"?
~ a wire plug.
Quoted 13 lines
Documentation/netlink/specs/shaper.yaml line 30
Quoted 12 lines
Documentation/netlink/specs/shaper.yaml new file +12
-0+ - + name: netdev + doc: The main shaper for the given network device. + - + name: queue + doc: The shaper is attached to the given device queue. + - + name: detached + doc: | + The shaper is not attached to any user-visible network + device component and allows nesting and grouping of + queues or others detached shapers.
Quoted 1 line
What is the purpose of the "detached" thing?
I fear I can't escape reusing most of the wording above. 'detached' nodes goal is to create groups of other shapers. i.e. queue groups, allowing multiple levels nesting, i.e. to implement this kind of hierarchy:
q1 ----- \
q2 - \SP / RR ------
q3 - / \
q4 - \ SP -> (netdev)
q5 - / /
/
q6 - \ RR
q7 - /where q1..q7 are queue-level shapers and all the SP/RR are 'detached' one. The conf. does not necessary make any functional sense, just to describe the things.
Quoted 12 lines
Documentation/netlink/specs/shaper.yaml line 246
Quoted 11 lines
Documentation/netlink/specs/shaper.yaml new file +11
-0+ - + name: group + doc: | + Group the specified input shapers under the specified + output shaper, eventually creating the latter, if needed. + Input shapers scope must be either @queue or @detached. + Output shaper scope must be either @detached or @netdev. + When using an output @detached scope shaper, if the + @handle @id is not specified, a new shaper of such scope + is created and, otherwise the specified output shaper + must be already existing.
Quoted 2 lines
I'm lost. Could this designt be described in details in the doc I asked in the cover letter? :/ Please.
I'm unsure if the context information here and in the previous replies helped somehow.
The group operation creates and configure a scheduling group, i.e. this
q1 ----- \
q2 - \SP / RR ------
q3 - / \
q4 - \ SP -> (netdev)
q5 - / /
/
q6 - \ RR
q7 - /can be create with:
group(inputs:[q6, q7], output:[detached,parent:netdev]) group(inputs:[q4, q5], output:[detached,parent:netdev]) group(inputs:[q1], output:[detached,parent:netdev]) group(inputs:[q2,q3], output:[detached,parent:<the detached shaper create above>])
I'm unsure if this the kind of info you are looking for?
Thanks,
Paolo
Re: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
Quoted 13 lines · Thu, Aug 01, 2024 at 05:12:01PM CEST, [email protected] wrote:
Quoted 12 lines · Jiri Pirko
Quoted 10 lines · Tue, Jul 30, 2024 at 10:39:45PM CEST, [email protected] wrote:
Documentation/netlink/specs/shaper.yaml new file +10
-0+ type: enum + name: scope + doc: the different scopes where a shaper can be attached + render-max: true + entries: + - name: unspec + doc: The scope is not specified + - + name: port + doc: The root for the whole H/W
Quoted 3 lines
Quoted 1 line
What is this "port"?
~ a wire plug.
What's "wire plug"? What of existing kernel objects this relates to? Is it a devlink port?
Quoted 29 lines
Quoted 14 lines
Documentation/netlink/specs/shaper.yaml line 30
Quoted 13 lines
Documentation/netlink/specs/shaper.yaml new file +12
-0+ - + name: netdev + doc: The main shaper for the given network device. + - + name: queue + doc: The shaper is attached to the given device queue. + - + name: detached + doc: | + The shaper is not attached to any user-visible network + device component and allows nesting and grouping of + queues or others detached shapers.Quoted 1 line
What is the purpose of the "detached" thing?
I fear I can't escape reusing most of the wording above. 'detached' nodes goal is to create groups of other shapers. i.e. queue groups, allowing multiple levels nesting, i.e. to implement this kind of hierarchy:
q1 ----- \
q2 - \SP / RR ------q3 - / \ q4 - \ SP -> (netdev) q5 - / / / q6 - \ RR q7 - /
Quoted 3 lines
where q1..q7 are queue-level shapers and all the SP/RR are 'detached' one. The conf. does not necessary make any functional sense, just to describe the things.
Can you "attach" the "detached" ones? They are "detached" from what?
Quoted 30 lines
Quoted 13 lines
Documentation/netlink/specs/shaper.yaml line 246
Quoted 12 lines
Documentation/netlink/specs/shaper.yaml new file +11
-0+ - + name: group + doc: | + Group the specified input shapers under the specified + output shaper, eventually creating the latter, if needed. + Input shapers scope must be either @queue or @detached. + Output shaper scope must be either @detached or @netdev. + When using an output @detached scope shaper, if the + @handle @id is not specified, a new shaper of such scope + is created and, otherwise the specified output shaper + must be already existing.Quoted 2 lines
I'm lost. Could this designt be described in details in the doc I asked in the cover letter? :/ Please.
I'm unsure if the context information here and in the previous replies helped somehow.
The group operation creates and configure a scheduling group, i.e. this
q1 ----- \
q2 - \SP / RR ------q3 - / \ q4 - \ SP -> (netdev) q5 - / / / q6 - \ RR q7 - /
Quoted 7 lines
can be create with:
group(inputs:[q6, q7], output:[detached,parent:netdev])group(inputs:[q4, q5], output:[detached,parent:netdev])group(inputs:[q1], output:[detached,parent:netdev])group(inputs:[q2,q3], output:[detached,parent:<the detached shaper create above>])
So by "inputs" and "output" you are basically building a tree. In devlink rate, we have leaf and node, which is in sync with standard tree terminology.
If what you are building is tree, why don't you use the same terminology? If you are building tree, you just need to have the link to upper noded (output in your terminology). Why you have "inputs"? Isn't that redundant?
If this is not tree, what's that? Can for example q6 be input of 2 different groups? How is that supposed to work?
Quoted 2 lines
I'm unsure if this the kind of info you are looking for?
I'm trying to understand the design. Have to say I'm just confused :/
Quoted 5 lines
Thanks,
Paolo
Paolo Abeni
maintainerRe: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
Hi all,
(same remark of my previous email). My replies this week will be delayed, please allow for some extra latency.
Quoted 14 lines · Jiri Pirko
Quoted 13 lines · Thu, Aug 01, 2024 at 05:12:01PM CEST, [email protected] wrote:
Quoted 12 lines · Jiri Pirko
Quoted 10 lines · Tue, Jul 30, 2024 at 10:39:45PM CEST, [email protected] wrote:
Documentation/netlink/specs/shaper.yaml new file +10
-0+ type: enum + name: scope + doc: the different scopes where a shaper can be attached + render-max: true + entries: + - name: unspec + doc: The scope is not specified + - + name: port + doc: The root for the whole H/W
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
What is this "port"?
~ a wire plug.
What's "wire plug"? What of existing kernel objects this relates to? Is it a devlink port?
I'm sorry, my hasty translation of my native language was really inaccurate. Let me re-phrase from scratch: that is actually the root of the whole scheduling tree (yes, it's a tree) for a given network device.
One source of confusion is that in a previous iteration we intended to allow configuring even objects 'above' the network device level, but such feature has been dropped.
We could probably drop this scope entirely.
Quoted 28 lines
Quoted 28 lines
Quoted 13 lines
Documentation/netlink/specs/shaper.yaml line 30
Quoted 12 lines
Documentation/netlink/specs/shaper.yaml new file +12
-0+ - + name: netdev + doc: The main shaper for the given network device. + - + name: queue + doc: The shaper is attached to the given device queue. + - + name: detached + doc: | + The shaper is not attached to any user-visible network + device component and allows nesting and grouping of + queues or others detached shapers.Quoted 1 line
What is the purpose of the "detached" thing?
I fear I can't escape reusing most of the wording above. 'detached' nodes goal is to create groups of other shapers. i.e. queue groups, allowing multiple levels nesting, i.e. to implement this kind of hierarchy:
q1 ----- \
q2 - \SP / RR ------q3 - / \ q4 - \ SP -> (netdev) q5 - / / / q6 - \ RR q7 - /
Quoted 5 lines
Quoted 3 lines
where q1..q7 are queue-level shapers and all the SP/RR are 'detached' one. The conf. does not necessary make any functional sense, just to describe the things.
Can you "attach" the "detached" ones? They are "detached" from what?
I see such name is very confusing. An alternative one could be 'group', but IIRC it was explicitly discarded while discussing a previous iteration.
The 'detached' name comes from the fact the such shapers are not a direct representation of some well-known kernel object (queues, devices),
Quoted 37 lines
Quoted 29 lines
Quoted 12 lines
Documentation/netlink/specs/shaper.yaml line 246
Quoted 11 lines
Documentation/netlink/specs/shaper.yaml new file +11
-0+ - + name: group + doc: | + Group the specified input shapers under the specified + output shaper, eventually creating the latter, if needed. + Input shapers scope must be either @queue or @detached. + Output shaper scope must be either @detached or @netdev. + When using an output @detached scope shaper, if the + @handle @id is not specified, a new shaper of such scope + is created and, otherwise the specified output shaper + must be already existing.Quoted 2 lines
I'm lost. Could this designt be described in details in the doc I asked in the cover letter? :/ Please.
I'm unsure if the context information here and in the previous replies helped somehow.
The group operation creates and configure a scheduling group, i.e. this
q1 ----- \
q2 - \SP / RR ------q3 - / \ q4 - \ SP -> (netdev) q5 - / / / q6 - \ RR q7 - /Quoted 7 lines
can be create with:
group(inputs:[q6, q7], output:[detached,parent:netdev])group(inputs:[q4, q5], output:[detached,parent:netdev])group(inputs:[q1], output:[detached,parent:netdev])group(inputs:[q2,q3], output:[detached,parent:<the detached shaper create above>])
Quoted 8 lines
So by "inputs" and "output" you are basically building a tree. In devlink rate, we have leaf and node, which is in sync with standard tree terminology.
If what you are building is tree, why don't you use the same terminology? If you are building tree, you just need to have the link to upper noded (output in your terminology). Why you have "inputs"? Isn't that redundant?
The idea behind the inputs/outputs naming is to represent the data flow towards the wire.
I'm fine with the parent/children naming, but IIRC Jakub was not happy with it. Is there any intermediate ground that could satisfy both of you?
Thanks,
Paolo
Re: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
Quoted 32 lines · Mon, Aug 05, 2024 at 05:11:09PM CEST, [email protected] wrote:
Hi all,
(same remark of my previous email). My replies this week will be delayed, please allow for some extra latency.
Quoted 14 lines · Jiri Pirko
Quoted 13 lines · Thu, Aug 01, 2024 at 05:12:01PM CEST, [email protected] wrote:
Quoted 12 lines · Jiri Pirko
Quoted 10 lines · Tue, Jul 30, 2024 at 10:39:45PM CEST, [email protected] wrote:
Documentation/netlink/specs/shaper.yaml new file +10
-0+ type: enum + name: scope + doc: the different scopes where a shaper can be attached + render-max: true + entries: + - name: unspec + doc: The scope is not specified + - + name: port + doc: The root for the whole H/WQuoted 6 lines
Quoted 3 lines
Quoted 1 line
What is this "port"?
~ a wire plug.
What's "wire plug"? What of existing kernel objects this relates to? Is it a devlink port?
I'm sorry, my hasty translation of my native language was really inaccurate. Let me re-phrase from scratch: that is actually the root of the whole scheduling tree (yes, it's a tree) for a given network device.
Quoted 5 lines
One source of confusion is that in a previous iteration we intended to allow configuring even objects 'above' the network device level, but such feature has been dropped.
We could probably drop this scope entirely.
Drop for now, correct? I agree that your patchset now only works on top of netdev. But all infra should be ready to work on top of something else, devlink seems like good candidate. I mean, for devlink port function rate, we will definitelly need something like that.
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines
Quoted 14 lines
Documentation/netlink/specs/shaper.yaml line 30
Quoted 13 lines
Documentation/netlink/specs/shaper.yaml new file +12
-0+ - + name: netdev + doc: The main shaper for the given network device. + - + name: queue + doc: The shaper is attached to the given device queue. + - + name: detached + doc: | + The shaper is not attached to any user-visible network + device component and allows nesting and grouping of + queues or others detached shapers.Quoted 1 line
What is the purpose of the "detached" thing?
I fear I can't escape reusing most of the wording above. 'detached' nodes goal is to create groups of other shapers. i.e. queue groups, allowing multiple levels nesting, i.e. to implement this kind of hierarchy:
q1 ----- \
q2 - \SP / RR ------q3 - / \ q4 - \ SP -> (netdev) q5 - / / / q6 - \ RR q7 - /where q1..q7 are queue-level shapers and all the SP/RR are 'detached' one. The conf. does not necessary make any functional sense, just to describe the things.
Quoted 7 lines
Quoted 1 line
Can you "attach" the "detached" ones? They are "detached" from what?
I see such name is very confusing. An alternative one could be 'group', but IIRC it was explicitly discarded while discussing a previous iteration.
The 'detached' name comes from the fact the such shapers are not a direct representation of some well-known kernel object (queues, devices),
Understand now. Maybe "node" would make more sense? Leaves are queues and root is the device? Aligns with the tree terminology...
Quoted 47 lines
Quoted 38 lines
Quoted 30 lines
Quoted 13 lines
Documentation/netlink/specs/shaper.yaml line 246
Quoted 12 lines
Documentation/netlink/specs/shaper.yaml new file +11
-0+ - + name: group + doc: | + Group the specified input shapers under the specified + output shaper, eventually creating the latter, if needed. + Input shapers scope must be either @queue or @detached. + Output shaper scope must be either @detached or @netdev. + When using an output @detached scope shaper, if the + @handle @id is not specified, a new shaper of such scope + is created and, otherwise the specified output shaper + must be already existing.Quoted 2 lines
I'm lost. Could this designt be described in details in the doc I asked in the cover letter? :/ Please.
I'm unsure if the context information here and in the previous replies helped somehow.
The group operation creates and configure a scheduling group, i.e. this
q1 ----- \
q2 - \SP / RR ------q3 - / \ q4 - \ SP -> (netdev) q5 - / / / q6 - \ RR q7 - /Quoted 7 lines
can be create with:
group(inputs:[q6, q7], output:[detached,parent:netdev])group(inputs:[q4, q5], output:[detached,parent:netdev])group(inputs:[q1], output:[detached,parent:netdev])group(inputs:[q2,q3], output:[detached,parent:<the detached shaper create above>])Quoted 8 lines
So by "inputs" and "output" you are basically building a tree. In devlink rate, we have leaf and node, which is in sync with standard tree terminology.
If what you are building is tree, why don't you use the same terminology? If you are building tree, you just need to have the link to upper noded (output in your terminology). Why you have "inputs"? Isn't that redundant?
Quoted 4 lines
The idea behind the inputs/outputs naming is to represent the data flow towards the wire.
I'm fine with the parent/children naming, but IIRC Jakub was not happy with it. Is there any intermediate ground that could satisfy both of you?
It's a tree, so perhaps just stick with tree terminology, everyone is used to that. Makes sense? One way or another, this needs to be properly described in docs, all terminology. That would make things more clear, I believe.
Quoted 5 lines
Thanks,
Paolo
Paolo Abeni
maintainerRe: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
Quoted 141 lines · Jiri Pirko
Quoted 32 lines · Mon, Aug 05, 2024 at 05:11:09PM CEST, [email protected] wrote:
Hi all,
(same remark of my previous email). My replies this week will be delayed, please allow for some extra latency.
Quoted 14 lines · Jiri Pirko
Quoted 13 lines · Thu, Aug 01, 2024 at 05:12:01PM CEST, [email protected] wrote:
Quoted 12 lines · Jiri Pirko
Quoted 10 lines · Tue, Jul 30, 2024 at 10:39:45PM CEST, [email protected] wrote:
Documentation/netlink/specs/shaper.yaml new file +10
-0+ type: enum + name: scope + doc: the different scopes where a shaper can be attached + render-max: true + entries: + - name: unspec + doc: The scope is not specified + - + name: port + doc: The root for the whole H/WQuoted 6 lines
Quoted 3 lines
Quoted 1 line
What is this "port"?
~ a wire plug.
What's "wire plug"? What of existing kernel objects this relates to? Is it a devlink port?
I'm sorry, my hasty translation of my native language was really inaccurate. Let me re-phrase from scratch: that is actually the root of the whole scheduling tree (yes, it's a tree) for a given network device.
Quoted 5 lines
One source of confusion is that in a previous iteration we intended to allow configuring even objects 'above' the network device level, but such feature has been dropped.
We could probably drop this scope entirely.
Drop for now, correct? I agree that your patchset now only works on top of netdev. But all infra should be ready to work on top of something else, devlink seems like good candidate. I mean, for devlink port function rate, we will definitelly need something like that.
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines
Quoted 14 lines
Documentation/netlink/specs/shaper.yaml line 30
Quoted 13 lines
Documentation/netlink/specs/shaper.yaml new file +12
-0+ - + name: netdev + doc: The main shaper for the given network device. + - + name: queue + doc: The shaper is attached to the given device queue. + - + name: detached + doc: | + The shaper is not attached to any user-visible network + device component and allows nesting and grouping of + queues or others detached shapers.Quoted 1 line
What is the purpose of the "detached" thing?
I fear I can't escape reusing most of the wording above. 'detached' nodes goal is to create groups of other shapers. i.e. queue groups, allowing multiple levels nesting, i.e. to implement this kind of hierarchy:
q1 ----- \
q2 - \SP / RR ------q3 - / \ q4 - \ SP -> (netdev) q5 - / / / q6 - \ RR q7 - /where q1..q7 are queue-level shapers and all the SP/RR are 'detached' one. The conf. does not necessary make any functional sense, just to describe the things.
Quoted 7 lines
Quoted 1 line
Can you "attach" the "detached" ones? They are "detached" from what?
I see such name is very confusing. An alternative one could be 'group', but IIRC it was explicitly discarded while discussing a previous iteration.
The 'detached' name comes from the fact the such shapers are not a direct representation of some well-known kernel object (queues, devices),
Understand now. Maybe "node" would make more sense? Leaves are queues and root is the device? Aligns with the tree terminology...
Quoted 47 lines
Quoted 38 lines
Quoted 30 lines
Quoted 13 lines
Documentation/netlink/specs/shaper.yaml line 246
Quoted 12 lines
Documentation/netlink/specs/shaper.yaml new file +11
-0+ - + name: group + doc: | + Group the specified input shapers under the specified + output shaper, eventually creating the latter, if needed. + Input shapers scope must be either @queue or @detached. + Output shaper scope must be either @detached or @netdev. + When using an output @detached scope shaper, if the + @handle @id is not specified, a new shaper of such scope + is created and, otherwise the specified output shaper + must be already existing.Quoted 2 lines
I'm lost. Could this designt be described in details in the doc I asked in the cover letter? :/ Please.
I'm unsure if the context information here and in the previous replies helped somehow.
The group operation creates and configure a scheduling group, i.e. this
q1 ----- \
q2 - \SP / RR ------q3 - / \ q4 - \ SP -> (netdev) q5 - / / / q6 - \ RR q7 - /Quoted 7 lines
can be create with:
group(inputs:[q6, q7], output:[detached,parent:netdev])group(inputs:[q4, q5], output:[detached,parent:netdev])group(inputs:[q1], output:[detached,parent:netdev])group(inputs:[q2,q3], output:[detached,parent:<the detached shaper create above>])Quoted 8 lines
So by "inputs" and "output" you are basically building a tree. In devlink rate, we have leaf and node, which is in sync with standard tree terminology.
If what you are building is tree, why don't you use the same terminology? If you are building tree, you just need to have the link to upper noded (output in your terminology). Why you have "inputs"? Isn't that redundant?
Quoted 4 lines
The idea behind the inputs/outputs naming is to represent the data flow towards the wire.
I'm fine with the parent/children naming, but IIRC Jakub was not happy with it. Is there any intermediate ground that could satisfy both of you?
Quoted 4 lines
It's a tree, so perhaps just stick with tree terminology, everyone is used to that. Makes sense? One way or another, this needs to be properly described in docs, all terminology. That would make things more clear, I believe.
@Jakub, would you be ok with:
'inputs' -> 'leaves'
'output' -> 'node'
?
Also while at it, I think renaming the 'group()' operation as 'node_set()' could be clearer (or at least less unclear), WDYT?
Note: I think it's would be more user-friendly to keep a single delete/get/dump operation for 'nodes' and leaves.
Thanks,
Paolo
Jakub Kicinski
maintainerRe: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
Quoted 10 lines · On Mon, 12 Aug 2024 16:58:33 +0200 Paolo Abeni wrote:
Quoted 4 lines
It's a tree, so perhaps just stick with tree terminology, everyone is used to that. Makes sense? One way or another, this needs to be properly described in docs, all terminology. That would make things more clear, I believe.
@Jakub, would you be ok with:
'inputs' -> 'leaves'
'output' -> 'node'
?
I think the confusion is primarily about the parent / child. input and output should be very clear, IMO.
Quoted 2 lines
Also while at it, I think renaming the '
group()' operation as 'node_set()' could be clearer (or at least less unclear), WDYT?
No idea how we arrived at node_set(), and how it can possibly represent a grouping operation.
The operations is grouping inputs and creating a scheduler node.
Quoted 2 lines
Note: I think it's would be more user-friendly to keep a single delete/get/dump operation for 'nodes' and leaves.
Are you implying that nodes and leaves are different types of objects? Aren't leaves nodes without any inputs?
Re: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
Quoted 6 lines · Mon, Aug 12, 2024 at 05:25:44PM CEST, [email protected] wrote:
Quoted 5 lines · On Mon, 12 Aug 2024 16:58:33 +0200 Paolo Abeni wrote:
Quoted 4 lines
It's a tree, so perhaps just stick with tree terminology, everyone is used to that. Makes sense? One way or another, this needs to be properly described in docs, all terminology. That would make things more clear, I believe.
Quoted 8 lines
Quoted 5 lines
@Jakub, would you be ok with:
'inputs' -> 'leaves'
'output' -> 'node'
?I think the confusion is primarily about the parent / child. input and output should be very clear, IMO.
For me, "inputs" and "output" in this context sounds very odd. It should be children and parent, isn't it. Confused...
Quoted 5 lines
Quoted 3 lines
Also while at it, I think renaming the '
group()' operation as 'node_set()' could be clearer (or at least less unclear), WDYT?No idea how we arrived at
node_set(), and how it can possibly
subtree_set() ?
Quoted 8 lines
represent a grouping operation.
The operations is grouping inputs and creating a scheduler node.Quoted 2 lines
Note: I think it's would be more user-friendly to keep a single delete/get/dump operation for 'nodes' and leaves.
Are you implying that nodes and leaves are different types of objects? Aren't leaves nodes without any inputs?
Agree. Same op would be nice for both.
Jakub Kicinski
maintainerRe: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
Quoted 6 lines · On Mon, 12 Aug 2024 18:50:06 +0200 Jiri Pirko wrote:
Quoted 2 lines · Mon, Aug 12, 2024 at 05:25:44PM CEST, [email protected] wrote:
I think the confusion is primarily about the parent / child. input and output should be very clear, IMO.
For me, "inputs" and "output" in this context sounds very odd. It should be children and parent, isn't it. Confused...
Parent / child is completely confusing. Let's not.
User will classify traffic based on 'leaf' attributes. Therefore in my mind traffic enters the tree at the "leaves", and travels towards the root (whether or not that's how HW evaluates the hierarchy).
This is opposite to how trees as an data structure are normally traversed. Hence I find the tree analogy to be imperfect. But yes, root and leaf are definitely better than parent / child.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Also while at it, I think renaming the '
group()' operation as 'node_set()' could be clearer (or at least less unclear), WDYT?No idea how we arrived at
node_set(), and how it can possibly
subtree_set()?
The operation is grouping inputs and creating a scheduler node.
Quoted 10 lines
Quoted 8 lines
represent a grouping operation.
The operations is grouping inputs and creating a scheduler node.Quoted 2 lines
Note: I think it's would be more user-friendly to keep a single delete/get/dump operation for 'nodes' and leaves.
Are you implying that nodes and leaves are different types of objects? Aren't leaves nodes without any inputs?
Agree. Same op would be nice for both.
Re: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
Quoted 10 lines · Mon, Aug 12, 2024 at 07:42:21PM CEST, [email protected] wrote:
Quoted 6 lines · On Mon, 12 Aug 2024 18:50:06 +0200 Jiri Pirko wrote:
Quoted 2 lines · Mon, Aug 12, 2024 at 05:25:44PM CEST, [email protected] wrote:
I think the confusion is primarily about the parent / child. input and output should be very clear, IMO.
For me, "inputs" and "output" in this context sounds very odd. It should be children and parent, isn't it. Confused...
Parent / child is completely confusing. Let's not.
Quoted 7 lines
User will classify traffic based on 'leaf' attributes. Therefore in my mind traffic enters the tree at the "leaves", and travels towards the root (whether or not that's how HW evaluates the hierarchy).
This is opposite to how trees as an data structure are normally traversed. Hence I find the tree analogy to be imperfect.
Normally? Tree as a datastructure could be traversed freely, why it can't? In this case, it is traversed from leaf to root. It's still a tree. Why the tree analogy is imperfect. From what I see, it fits 100%.
Quoted 1 line
But yes, root and leaf are definitely better than parent / child.
Node has 0-n children and 0-1 parents. In case it has 0 children, it's a leaf, in case it has 0 parents, it's a root.
This is the common tree terminology, isn't it?
Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Also while at it, I think renaming the '
group()' operation as 'node_set()' could be clearer (or at least less unclear), WDYT?No idea how we arrived at
node_set(), and how it can possibly
subtree_set()?The operation is grouping inputs and creating a scheduler node.
Creating a node inside a tree, isn't it? Therefore subtree.
But it could be unified to node_set() as Paolo suggested. That would work for any node, including leaf, tree, non-existent internal node.
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
represent a grouping operation.
The operations is grouping inputs and creating a scheduler node.Quoted 2 lines
Note: I think it's would be more user-friendly to keep a single delete/get/dump operation for 'nodes' and leaves.
Are you implying that nodes and leaves are different types of objects? Aren't leaves nodes without any inputs?
Agree. Same op would be nice for both.
Jakub Kicinski
maintainerRe: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
Quoted 11 lines · On Tue, 13 Aug 2024 07:38:46 +0200 Jiri Pirko wrote:
Quoted 9 lines
Parent / child is completely confusing. Let's not.
User will classify traffic based on 'leaf' attributes. Therefore in my mind traffic enters the tree at the "leaves", and travels towards the root (whether or not that's how HW evaluates the hierarchy).
This is opposite to how trees as an data structure are normally traversed. Hence I find the tree analogy to be imperfect.
Normally?
Yes, normally, in sort and/or lookup algorithms the owner of the tree has a pointer to root, and walks from root.
Quoted 2 lines
Tree as a datastructure could be traversed freely, why it can't?
I didn't say it can't.
Quoted 8 lines
In this case, it is traversed from leaf to root. It's still a tree. Why the tree analogy is imperfect. From what I see, it fits 100%.
Quoted 1 line
But yes, root and leaf are definitely better than parent / child.
Node has 0-n children and 0-1 parents. In case it has 0 children, it's a leaf, in case it has 0 parents, it's a root.
This is the common tree terminology, isn't it?
You're using tree terminology and then you're asking if it's the tree terminology. What are you trying to prove?
To me using input / output is more intuitive, as it matches direction of traffic flow. I'm fine with root / leaf tho, as I said.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
subtree_set()?The operation is grouping inputs and creating a scheduler node.
Creating a node inside a tree, isn't it? Therefore subtree.
All nodes are inside the tree.
Quoted 2 lines
But it could be unified to
node_set()as Paolo suggested. That would work for any node, including leaf, tree, non-existent internal node.
A "set" operation which creates a node.
Paolo Abeni
maintainerRe: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
Quoted 2 lines · Jakub Kicinski
To me using input / output is more intuitive, as it matches direction of traffic flow. I'm fine with root / leaf tho, as I said.
Can we converge on root / leaf ?
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
subtree_set()?The operation is grouping inputs and creating a scheduler node.
Quoted 8 lines
Quoted 1 line
Creating a node inside a tree, isn't it? Therefore subtree.
All nodes are inside the tree.
Quoted 2 lines
But it could be unified to
node_set()as Paolo suggested. That would work for any node, including leaf, tree, non-existent internal node.A "set" operation which creates a node.
Here the outcome is unclear to me. My understanding is that group() does not fit Jiri nor Donald and and node_set() or subtree_set() do not fit Jakub.
Did I misread something? As a trade-off, what about, group_set()?
Thanks,
Paolo
Jakub Kicinski
maintainerRe: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
Quoted 7 lines · On Tue, 13 Aug 2024 16:47:34 +0200 Paolo Abeni wrote:
Quoted 7 lines
Quoted 1 line
Creating a node inside a tree, isn't it? Therefore subtree.
All nodes are inside the tree.
Quoted 2 lines
But it could be unified to
node_set()as Paolo suggested. That would work for any node, including leaf, tree, non-existent internal node.
Quoted 7 lines
Quoted 1 line
A "set" operation which creates a node.
Here the outcome is unclear to me. My understanding is that
group()does not fit Jiri nor Donald and andnode_set()orsubtree_set()do not fit Jakub.Did I misread something? As a trade-off, what about,
group_set()?
"set" is not a sensible verb for creating something. "group" in the original was the verb.
Why are both saying "set" and not "create"? What am I missing?
Paolo Abeni
maintainerRe: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
Quoted 14 lines · Jakub Kicinski
Quoted 13 lines · On Tue, 13 Aug 2024 16:47:34 +0200 Paolo Abeni wrote:
Quoted 8 lines
Quoted 1 line
Creating a node inside a tree, isn't it? Therefore subtree.
All nodes are inside the tree.
Quoted 2 lines
But it could be unified to
node_set()as Paolo suggested. That would work for any node, including leaf, tree, non-existent internal node.A "set" operation which creates a node.
Here the outcome is unclear to me. My understanding is that
group()does not fit Jiri nor Donald and andnode_set()orsubtree_set()do not fit Jakub.
Quoted 5 lines
Quoted 1 line
Did I misread something? As a trade-off, what about,
group_set()?"set" is not a sensible verb for creating something. "group" in the original was the verb.
Why are both saying "set" and not "create"? What am I missing?
Please, don't read too much in my limited English skills! I'm fine with group_create() - or create_group()
Still WRT naming, I almost forgot about the much blamed 'detached' scope. Would 'node' or 'group' be a better name? (the latter only if we rename the homonymous operation)
Thanks,
Paolo
Jakub Kicinski
maintainerRe: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
Quoted 6 lines · On Tue, 13 Aug 2024 17:31:17 +0200 Paolo Abeni wrote:
Quoted 3 lines
"set" is not a sensible verb for creating something. "group" in the original was the verb.
Why are both saying "set" and not "create"? What am I missing?Please, don't read too much in my limited English skills! I'm fine with
group_create()- orcreate_group()
Again, group was a verb :)
I don't think anyone suggested group as a noun / object.
Quoted 3 lines
Still WRT naming, I almost forgot about the much blamed 'detached' scope. Would 'node' or 'group' be a better name? (the latter only if we rename the homonymous operation)
I vote 'node', given the above.
Donald Hunter
maintainerRe: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
In reply to Paolo AbeniQuoted 11 lines · Paolo Abeni
Quoted 2 lines · Jakub Kicinski
To me using input / output is more intuitive, as it matches direction of traffic flow. I'm fine with root / leaf tho, as I said.
Can we converge on root / leaf ?
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
subtree_set()?The operation is grouping inputs and creating a scheduler node.
Creating a node inside a tree, isn't it? Therefore subtree.
Quoted 8 lines
Quoted 5 lines
All nodes are inside the tree.
Quoted 2 lines
But it could be unified to
node_set()as Paolo suggested. That would work for any node, including leaf, tree, non-existent internal node.A "set" operation which creates a node.
Here the outcome is unclear to me. My understanding is that
group()does not fit Jiri nor Donald and andnode_set()orsubtree_set()do not fit Jakub.
I found group() confusing because it does not imply creation. So create-group() would be fine. But it seems like creating a group is a step towards creating a scheduler node?
Donald Hunter
maintainerRe: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
In reply to Jakub KicinskiQuoted 6 lines · Jakub Kicinski
Quoted 5 lines · On Mon, 12 Aug 2024 16:58:33 +0200 Paolo Abeni wrote:
Quoted 4 lines
It's a tree, so perhaps just stick with tree terminology, everyone is used to that. Makes sense? One way or another, this needs to be properly described in docs, all terminology. That would make things more clear, I believe.
Quoted 8 lines
Quoted 5 lines
@Jakub, would you be ok with:
'inputs' -> 'leaves'
'output' -> 'node'
?I think the confusion is primarily about the parent / child. input and output should be very clear, IMO.
input / output seems the most intuitive of the different terms that have been suggested.
Paolo Abeni
maintainerRe: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
Quoted 14 lines · Donald Hunter
Quoted 12 lines · Jakub Kicinski
Quoted 10 lines · On Mon, 12 Aug 2024 16:58:33 +0200 Paolo Abeni wrote:
Quoted 4 lines
It's a tree, so perhaps just stick with tree terminology, everyone is used to that. Makes sense? One way or another, this needs to be properly described in docs, all terminology. That would make things more clear, I believe.
@Jakub, would you be ok with:
'inputs' -> 'leaves'
'output' -> 'node'
?
Quoted 5 lines
Quoted 2 lines
I think the confusion is primarily about th parent / child. input and output should be very clear, IMO.
input / output seems the most intuitive of the different terms that have been suggested.
Since a sort of agreement was reached about using root / leaf instead, and (quoting someone smarter then me) a good compromise makes every party equally unhappy, would you consider such other option?
Thanks,
Paolo
Donald Hunter
maintainerRe: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
Quoted 15 lines · Paolo Abeni
Quoted 14 lines · Donald Hunter
Quoted 12 lines · Jakub Kicinski
Quoted 10 lines · On Mon, 12 Aug 2024 16:58:33 +0200 Paolo Abeni wrote:
Quoted 4 lines
It's a tree, so perhaps just stick with tree terminology, everyone is used to that. Makes sense? One way or another, this needs to be properly described in docs, all terminology. That would make things more clear, I believe.
@Jakub, would you be ok with:
'inputs' -> 'leaves'
'output' -> 'node'
?
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
I think the confusion is primarily about th parent / child. input and output should be very clear, IMO.
input / output seems the most intuitive of the different terms that have been suggested.
Since a sort of agreement was reached about using root / leaf instead, and (quoting someone smarter then me) a good compromise makes every party equally unhappy, would you consider such other option?
Sure, if that is the general consensus. Though I do find it confusing because there are not any tree-like ops. Does that mean you are shifting away from using 'inputs' and 'output' for the group op?
Re: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
In reply to Paolo AbeniTue, Jul 30, 2024 at 10:39:45PM CEST, [email protected] wrote:
[...]
Documentation/netlink/specs/shaper.yaml line 108
Quoted 5 lines
Documentation/netlink/specs/shaper.yaml new file +5
-0+ - + name: inputs + type: nest + multi-attr: true + nested-attributes: ns-info
Hmm, you sometimes use this "ns-" prefix. Why? Does it mean "net-shaper"?
This results to:net_shaper_ns_info_nl_policy
Wouldn't it be better to name it just "info":net_shaper_info_nl_policy
And for ns-output-info, just "output-info":net_shaper_output_info_nl_policy
?
Quoted 64 lines
Documentation/netlink/specs/shaper.yaml new file +64
-0+ doc: | + Describes a set of inputs shapers for a @group operation + - + name: output + type: nest + nested-attributes: ns-output-info + doc: | + Describes the output shaper for a @group operation + Differently from @inputs and @shaper allow specifying + the shaper parent handle, too. + + - + name: shaper + type: nest + nested-attributes: ns-info + doc: | + Describes a single shaper for a @set operation + - + name: handle + subset-of: net-shaper + attributes: + - + name: scope + - + name: id + - + name: ns-info + subset-of: net-shaper + attributes: + - + name: handle + - + name: metric + - + name: bw-min + - + name: bw-max + - + name: burst + - + name: priority + - + name: weight + - + name: ns-output-info + subset-of: net-shaper + attributes: + - + name: parent + - + name: handle + - + name: metric + - + name: bw-min + - + name: bw-max + - + name: burst + - + name: priority + - + name: weight +
[...]
Re: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
In reply to Paolo AbeniTue, Jul 30, 2024 at 10:39:45PM CEST, [email protected] wrote:
[...]
Quoted 9 lines
net/shaper/shaper_nl_gen.c new file +9
-0+const struct nla_policy net_shaper_ns_info_nl_policy[NET_SHAPER_A_WEIGHT +1 ] = { + [NET_SHAPER_A_HANDLE ] =NLA_POLICY_NESTED (net_shaper_handle_nl_policy), + [NET_SHAPER_A_METRIC ] =NLA_POLICY_MAX (NLA_U32 ,1 ), + [NET_SHAPER_A_BW_MIN ] = { .type =NLA_UINT , }, + [NET_SHAPER_A_BW_MAX ] = { .type =NLA_UINT , }, + [NET_SHAPER_A_BURST ] = { .type =NLA_UINT , }, + [NET_SHAPER_A_PRIORITY ] = { .type =NLA_U32 , }, + [NET_SHAPER_A_WEIGHT ] = { .type =NLA_U32 , }, +};
net/shaper/shaper_nl_gen.c line 37
Quoted 10 lines
net/shaper/shaper_nl_gen.c new file +10
-0+ +const struct nla_policy net_shaper_ns_output_info_nl_policy[NET_SHAPER_A_PARENT +1 ] = { + [NET_SHAPER_A_PARENT ] =NLA_POLICY_NESTED (net_shaper_handle_nl_policy), + [NET_SHAPER_A_HANDLE ] =NLA_POLICY_NESTED (net_shaper_handle_nl_policy), + [NET_SHAPER_A_METRIC ] =NLA_POLICY_MAX (NLA_U32 ,1 ), + [NET_SHAPER_A_BW_MIN ] = { .type =NLA_UINT , }, + [NET_SHAPER_A_BW_MAX ] = { .type =NLA_UINT , }, + [NET_SHAPER_A_BURST ] = { .type =NLA_UINT , }, + [NET_SHAPER_A_PRIORITY ] = { .type =NLA_U32 , }, + [NET_SHAPER_A_WEIGHT ] = { .type =NLA_U32 , },
Since this is the same set as above only extended by parent, wouldn't it be better to nest it and have it only once?
[...]
Re: [PATCH v3 02/12] netlink: spec: add shaper YAML spec
In reply to Paolo AbeniTue, Jul 30, 2024 at 10:39:45PM CEST, [email protected] wrote:
[..]
Quoted 1 line
+ name: handle
I already commented (scope,id) passing to drivers. But in the uapi, why this has to be a single u32 as well? Why this can't be 2 attributes?
[..]
Paolo Abeni
maintainerPATCH v3 3/12 net-shapers: implement NL get operation
In reply to Paolo AbeniIntroduce the basic infrastructure to implement the net-shaper core functionality. Each network devices carries a net-shaper cache, the NL get() operation fetches the data from such cache.
The cache is initially empty, will be fill by the set()/group() operation implemented later and is destroyed at device cleanup time.
---
RFC v2 -> RFC v3:
- dev_put() -> netdev_put()
--- Documentation/networking/kapi.rst | 3 + include/linux/netdevice.h | 17 ++ include/net/net_shaper.h | 158 +++++++++++++++++++ net/core/dev.c | 2 + net/core/dev.h | 6 + net/shaper/shaper.c | 251 +++++++++++++++++++++++++++++- 6 files changed, 435 insertions(+), 2 deletions(-) create mode 100644 include/net/net_shaper.h
Documentation/networking/kapi.rst +3 -0
@@ -104,6 +104,9 @@ Driver Support .. kernel-doc:: include/linux/netdevice.h :internal: +.. kernel-doc:: include/net/net_shaper.h + :internal: + PHY Support -----------
include/linux/netdevice.h +17 -0
@@ -81,6 +81,8 @@ struct xdp_frame;struct xdp_metadata_ops ;struct xdp_md ;struct ethtool_netdev_state ; +struct net_shaper_ops ; +struct net_shaper_data ;typedef u32 xdp_features_t ;
@@ -1598,6 +1600,14 @@ struct net_device_ops {int (*ndo_hwtstamp_set)(struct net_device *dev,struct kernel_hwtstamp_config *kernel_config,struct netlink_ext_ack *extack); + +#if IS_ENABLED (CONFIG_NET_SHAPER ) +/** +* @net_shaper_ops: Device shaping offload operations +* see include/net/net_shapers.h +*/ +const struct net_shaper_ops *net_shaper_ops; +#endif };/**
@@ -2408,6 +2418,13 @@ struct net_device {/** @irq_moder: dim parameters used if IS_ENABLED(CONFIG_DIMLIB). */ struct dim_irq_moder *irq_moder; +#if IS_ENABLED (CONFIG_NET_SHAPER ) +/** +* @net_shaper_data: data tracking the current shaper status +* see include/net/net_shapers.h +*/ +struct net_shaper_data *net_shaper_data; +#endif u8 priv[] ____cacheline_aligned__counted_by (priv_len ); }____cacheline_aligned ;
include/net/net_shaper.h new file +158 -0
158 lines not on this page · raw message
net/core/dev.c +2 -0
@@ -11169,6 +11169,8 @@ void free_netdev(struct net_device *dev)/* Flush device addresses */ dev_addr_flush (dev); +dev_shaper_flush (dev); +list_for_each_entry_safe (p, n, &dev->napi_list, dev_list)netif_napi_del (p);
net/core/dev.h +6 -0
@@ -35,6 +35,12 @@ void dev_addr_flush(struct net_device *dev);int dev_addr_init (struct net_device *dev);void dev_addr_check (struct net_device *dev); +#if IS_ENABLED (CONFIG_NET_SHAPER ) +void dev_shaper_flush (struct net_device *dev); +#else +static inline void dev_shaper_flush (struct net_device *dev) {} +#endif +/* sysctls not referred to from outside net/core/ */ extern int netdev_unregister_timeout_secs;extern int weight_p;
net/shaper/shaper.c +249 -2
274 lines not on this page · raw message
Signature · 1 line
2.45.2
Re: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 205 lines · Tue, Jul 30, 2024 at 10:39:46PM CEST, [email protected] wrote:
Introduce the basic infrastructure to implement the net-shaper core functionality. Each network devices carries a net-shaper cache, the NL
get()operation fetches the data from such cache.The cache is initially empty, will be fill by the set()/group() operation implemented later and is destroyed at device cleanup time.
Signed-off-by Paolo Abeni <[email protected]>---
RFC v2 -> RFC v3:
-dev_put()->netdev_put()
---Documentation/networking/kapi.rst | 3 + include/linux/netdevice.h | 17 ++ include/net/net_shaper.h | 158 +++++++++++++++++++ net/core/dev.c | 2 + net/core/dev.h | 6 + net/shaper/shaper.c | 251 +++++++++++++++++++++++++++++- 6 files changed, 435 insertions(+), 2 deletions(-)create mode 100644
include/net/net_shaper.hDocumentation/networking/kapi.rst +0
-0@@ -104,6 +104,9 @@ Driver Support.. kernel-doc::
include/linux/netdevice.h
:internal:+.. kernel-doc::
include/net/net_shaper.hDocumentation/networking/kapi.rst +2
-0+ :internal: +PHY Support
-----------include/linux/netdevice.h +17
-0@@ -81,6 +81,8 @@ struct xdp_frame;struct xdp_metadata_ops ;struct xdp_md ;struct ethtool_netdev_state ; +struct net_shaper_ops ; +struct net_shaper_data ;typedef u32 xdp_features_t ;@@ -1598,6 +1600,14 @@ struct net_device_ops {int (*ndo_hwtstamp_set)(struct net_device *dev,struct kernel_hwtstamp_config *kernel_config,struct netlink_ext_ack *extack); + +#if IS_ENABLED (CONFIG_NET_SHAPER ) +/** +* @net_shaper_ops: Device shaping offload operations +* see include/net/net_shapers.h +*/ +const struct net_shaper_ops *net_shaper_ops; +#endif };/** @@ -2408,6 +2418,13 @@ struct net_device {/** @irq_moder: dim parameters used if IS_ENABLED(CONFIG_DIMLIB). */ struct dim_irq_moder *irq_moder; +#if IS_ENABLED (CONFIG_NET_SHAPER ) +/** +* @net_shaper_data: data tracking the current shaper status +* see include/net/net_shapers.h +*/ +struct net_shaper_data *net_shaper_data; +#endif u8 priv[] ____cacheline_aligned__counted_by (priv_len ); }____cacheline_aligned ;include/net/net_shaper.h new file +122
-0@@ -0,0 +1,158 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef _NET_SHAPER_H_ +#define _NET_SHAPER_H_ + +#include <linux/types.h> +#include <linux/bits.h> +#include <linux/bitfield.h> +#include <linux/netdevice.h> +#include <linux/netlink.h> + +#include <uapi/linux/net_shaper.h> + +/** +* struct net_shaper_info - represents a shaping node on the NIC H/W +* zeroed field are considered not set. +* @handle: Unique identifier for the shaper, see @net_shaper_make_handle +* @parent: Unique identifier for the shaper parent, usually implied. Only +* NET_SHAPER_SCOPE_QUEUE, NET_SHAPER_SCOPE_NETDEV and NET_SHAPER_SCOPE_DETACHED +* can have the parent handle explicitly set, placing such shaper under +* the specified parent. +* @metric: Specify if the bw limits refers to PPS or BPS +* @bw_min: Minimum guaranteed rate for this shaper +* @bw_max: Maximum peak bw allowed for this shaper +* @burst: Maximum burst for the peek rate of this shaper +* @priority: Scheduling priority for this shaper +* @weight: Scheduling weight for this shaper +* @children: Number of nested shapers, accounted only for DETACHED scope +*/ +struct net_shaper_info { +u32 handle; +u32 parent; +enum net_shaper_metric metric; +u64 bw_min; +u64 bw_max; +u64 burst; +u32 priority; +u32 weight; +u32 children; +}; + +/** +* define NET_SHAPER_SCOPE_VF - Shaper scope +* +* This shaper scope is not exposed to user-space; the shaper is attached to +* the given virtual function. +*/ +#define NET_SHAPER_SCOPE_VF __NET_SHAPER_SCOPE_MAX + +/** +* struct net_shaper_ops - Operations on device H/W shapers +* +* The initial shaping configuration ad device initialization is empty/ +* a no-op/does not constraint the b/w in any way. +* The network core keeps track of the applied user-configuration in +* per device storage. +* +* Each shaper is uniquely identified within the device with an 'handle', +* dependent on the shaper scope and other data, see @shaper_make_handle() +*/ +struct net_shaper_ops { +/** +* @group: create the specified shapers group +* +* Nest the specified @inputs shapers under the given @output shaper +* on the network device @dev. The @input shaper array size is specified +* by @nr_input. +* Create either the @inputs and the @output shaper as needed, +* otherwise move them as needed. Can't create @inputs shapers with +* NET_SHAPER_SCOPE_DETACHED scope, a separate @group call with such +* shaper as @output is needed. +* +* Returns 0 on group successfully created, otherwise an negative +* error value and set @extack to describe the failure's reason. +*/ +int (*group)(struct net_device *dev,int nr_input, +const struct net_shaper_info *inputs, +const struct net_shaper_info *output, +struct netlink_ext_ack *extack); + +/** +* @set: Updates the specified shaper +* +* Updates or creates the specified @shaper on the given device +* @dev. Can't create NET_SHAPER_SCOPE_DETACHED shapers, use @group +* instead. +* +* Returns 0 on group successfully created, otherwise an negative +* error value and set @extack to describe the failure's reason. +*/ +int (*set)(struct net_device *dev, +const struct net_shaper_info *shaper, +struct netlink_ext_ack *extack); + +/** +* @delete: Removes the specified shaper from the NIC +* +* Removes the shaper configuration as identified by the given @handle +* on the specified device @dev, restoring the default behavior. +* +* Returns 0 on group successfully created, otherwise an negative +* error value and set @extack to describe the failure's reason. +*/ +int (*delete)(struct net_device *dev,u32 handle, +struct netlink_ext_ack *extack); +}; + +#define NET_SHAPER_SCOPE_SHIFT 26 +#define NET_SHAPER_ID_MASK GENMASK(NET_SHAPER_SCOPE_SHIFT - 1, 0) +#define NET_SHAPER_SCOPE_MASK GENMASK(31, NET_SHAPER_SCOPE_SHIFT) + +#define NET_SHAPER_ID_UNSPEC NET_SHAPER_ID_MASK + +/** +* net_shaper_make_handle - creates an unique shaper identifier +* @scope: the shaper scope +* @id: the shaper id number +* +* Return: an unique identifier for the shaper +* +* Combines the specified arguments to create an unique identifier for +* the shaper. The @id argument semantic depends on the
include/net/net_shaper.h line 132
Quoted 10 lines
include/net/net_shaper.h new file +10
-0+* specified scope. +* For @NET_SHAPER_SCOPE_QUEUE_GROUP, @id is the queue group id +* For @NET_SHAPER_SCOPE_QUEUE, @id is the queue number. +* For @NET_SHAPER_SCOPE_VF, @id is virtual function number. +*/ +static inline u32 net_shaper_make_handle (enum net_shaper_scope scope, +int id) +{ +return FIELD_PREP (NET_SHAPER_SCOPE_MASK , scope) | +FIELD_PREP (NET_SHAPER_ID_MASK , id);
Perhaps some scopes may find only part of u32 as limitting for id in the future? I find it elegant to have it in single u32 though. u64 may be nicer (I know, xarray) :)
Quoted 66 lines
include/net/net_shaper.h new file +26
-0+} + +/** +* net_shaper_handle_scope - extract the scope from the given handle +* @handle: the shaper handle +* +* Return: the corresponding scope +*/ +static inline enum net_shaper_scope net_shaper_handle_scope (u32 handle) +{ +return FIELD_GET (NET_SHAPER_SCOPE_MASK , handle); +} + +/** +* net_shaper_handle_id - extract the id number from the given handle +* @handle: the shaper handle +* +* Return: the corresponding id number +*/ +static inline int net_shaper_handle_id (u32 handle) +{ +return FIELD_GET (NET_SHAPER_ID_MASK , handle); +} + +#endif +net/core/dev.c +2
-0@@ -11169,6 +11169,8 @@ void free_netdev(struct net_device *dev)/* Flush device addresses */ dev_addr_flush (dev); +dev_shaper_flush (dev); +list_for_each_entry_safe (p, n, &dev->napi_list, dev_list)netif_napi_del (p);net/core/dev.h +6
-0@@ -35,6 +35,12 @@ void dev_addr_flush(struct net_device *dev);int dev_addr_init (struct net_device *dev);void dev_addr_check (struct net_device *dev); +#if IS_ENABLED (CONFIG_NET_SHAPER ) +void dev_shaper_flush (struct net_device *dev); +#else +static inline void dev_shaper_flush (struct net_device *dev) {} +#endif +/* sysctls not referred to from outside net/core/ */ extern int netdev_unregister_timeout_secs;extern int weight_p;net/shaper/shaper.c +1
-0@@ -1,19 +1,242 @@// SPDX-License-Identifier: GPL-2.0-or-later #include <linux/kernel.h> +#include <linux/idr.h> #include <linux/skbuff.h>
net/shaper/shaper.c line 15
Quoted 10 lines
net/shaper/shaper.c +7
-0+#include <linux/xarray.h> +#include <net/net_shaper.h> #include "shaper_nl_gen.h" +#include "../core/dev.h" + +struct net_shaper_data { +struct xarray shapers; +struct idr detached_ids;
Hmm, I wonder what this will be used for :) Anyway, could you move to patch which is using it?
Quoted 141 lines
net/shaper/shaper.c +141
-0+}; + +struct net_shaper_nl_ctx { +u32 start_handle; +}; + +static int fill_handle (struct sk_buff *msg,u32 handle,u32 type, +const struct genl_info *info) +{ +struct nlattr *handle_attr; + +if (!handle) +return 0 ; + + handle_attr =nla_nest_start_noflag (msg, type); +if (!handle_attr) +return -EMSGSIZE ; + +if (nla_put_u32 (msg,NET_SHAPER_A_SCOPE , +net_shaper_handle_scope (handle)) || +nla_put_u32 (msg,NET_SHAPER_A_ID , +net_shaper_handle_id (handle))) + goto handle_nest_cancel; + +nla_nest_end (msg, handle_attr); +return 0 ; + +handle_nest_cancel: +nla_nest_cancel (msg, handle_attr); +return -EMSGSIZE ; +} + +static int +net_shaper_fill_one (struct sk_buff *msg,struct net_shaper_info *shaper, +const struct genl_info *info) +{ +void *hdr; + + hdr =genlmsg_iput (msg, info); +if (!hdr) +return -EMSGSIZE ; + +if (fill_handle (msg, shaper->parent,NET_SHAPER_A_PARENT , info) || +fill_handle (msg, shaper->handle,NET_SHAPER_A_HANDLE , info) || +nla_put_u32 (msg,NET_SHAPER_A_METRIC , shaper->metric) || +nla_put_uint (msg,NET_SHAPER_A_BW_MIN , shaper->bw_min) || +nla_put_uint (msg,NET_SHAPER_A_BW_MAX , shaper->bw_max) || +nla_put_uint (msg,NET_SHAPER_A_BURST , shaper->burst) || +nla_put_u32 (msg,NET_SHAPER_A_PRIORITY , shaper->priority) || +nla_put_u32 (msg,NET_SHAPER_A_WEIGHT , shaper->weight)) + goto nla_put_failure; + +genlmsg_end (msg, hdr); + +return 0 ; + +nla_put_failure: +genlmsg_cancel (msg, hdr); +return -EMSGSIZE ; +} + +/* On success sets pdev to the relevant device and acquires a reference +* to it +*/ +static int fetch_dev (const struct genl_info *info,struct net_device **pdev) +{ +struct net *ns =genl_info_net (info); +struct net_device *dev; +int ifindex; + +if (GENL_REQ_ATTR_CHECK (info,NET_SHAPER_A_IFINDEX )) +return -EINVAL ; + + ifindex =nla_get_u32 (info->attrs[NET_SHAPER_A_IFINDEX ]); + dev =dev_get_by_index (ns, ifindex); +if (!dev) { +GENL_SET_ERR_MSG_FMT (info,"device %d not found" , ifindex); +return -EINVAL ; + } + +if (!dev->netdev_ops->net_shaper_ops) { +GENL_SET_ERR_MSG_FMT (info,"device %s does not support H/W shaper" , + dev->name); +netdev_put (dev,NULL ); +return -EOPNOTSUPP ; + } + + *pdev = dev; +return 0 ; +} + +static struct xarray *__sc_container (struct net_device *dev) +{ +return dev->net_shaper_data ? &dev->net_shaper_data->shapers :NULL ; +} + +/* lookup the given shaper inside the cache */ +static struct net_shaper_info *sc_lookup (struct net_device *dev,u32 handle) +{ +struct xarray *xa =__sc_container (dev); + +return xa ?xa_load (xa, handle) :NULL ; +} + +static int parse_handle (const struct nlattr *attr,const struct genl_info *info, +u32 *handle) +{ +struct nlattr *tb[NET_SHAPER_A_ID +1 ]; +struct nlattr *scope_attr, *id_attr; +enum net_shaper_scope scope; +u32 id =0 ; +int ret; + + ret =nla_parse_nested (tb,NET_SHAPER_A_ID , attr, + net_shaper_handle_nl_policy, info->extack); +if (ret <0 ) +return ret; + + scope_attr = tb[NET_SHAPER_A_SCOPE ]; +if (!scope_attr) { +GENL_SET_ERR_MSG (info,"Missing 'scope' attribute for handle" ); +return -EINVAL ; + } + + scope =nla_get_u32 (scope_attr); + +/* the default id for detached scope shapers is an invalid one +* to help the 'group' operation discriminate between new +* detached shaper creation (ID_UNSPEC) and reuse of existing +* shaper (any other value) +*/ + id_attr = tb[NET_SHAPER_A_ID ]; +if (id_attr) + id =nla_get_u32 (id_attr); +else if (scope ==NET_SHAPER_SCOPE_DETACHED ) + id =NET_SHAPER_ID_UNSPEC ; + + *handle =net_shaper_make_handle (scope, id); +return 0 ; +} +
net/shaper/shaper.c line 165
Quoted 10 lines
net/shaper/shaper.c +7
-1int net_shaper_nl_get_doit (struct sk_buff *skb,struct genl_info *info) { -return -EOPNOTSUPP ; +struct net_shaper_info *shaper; +struct net_device *dev; +struct sk_buff *msg; +u32 handle; +int ret; + + ret =fetch_dev (info, &dev);
This is quite net_device centric. Devlink rate shaper should be eventually visible throught this api as well, won't they? How do you imagine that?
Could we have various types of binding? Something like:
NET_SHAPER_A_BINDING nest
NET_SHAPER_A_BINDING_IFINDEX u32
or:NET_SHAPER_A_BINDING nest
NET_SHAPER_A_BINDING_DEVLINK_PORT nest
DEVLINK_ATTR_BUS_NAME string
DEVLINK_ATTR_DEV_NAME string
DEVLINK_ATTR_PORT_INDEX u32
?
Quoted 97 lines
net/shaper/shaper.c +84
-1+if (ret) +return ret; + +if (GENL_REQ_ATTR_CHECK (info,NET_SHAPER_A_HANDLE )) + goto put; + + ret =parse_handle (info->attrs[NET_SHAPER_A_HANDLE ], info, &handle); +if (ret <0 ) + goto put; + + shaper =sc_lookup (dev, handle); +if (!shaper) { +GENL_SET_ERR_MSG_FMT (info,"Can't find shaper for handle %x" , handle); + ret = -EINVAL ; + goto put; + } + + msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL ); +if (!msg) { + ret = -ENOMEM ; + goto put; + } + + ret =net_shaper_fill_one (msg, shaper, info); +if (ret) + goto free_msg; + + ret =genlmsg_reply (msg, info); +if (ret) + goto free_msg; + +put: +netdev_put (dev,NULL ); +return ret; + +free_msg: +nlmsg_free (msg); + goto put; }int net_shaper_nl_get_dumpit (struct sk_buff *skb,struct netlink_callback *cb) { -return -EOPNOTSUPP ; +struct net_shaper_nl_ctx *ctx = (struct net_shaper_nl_ctx *)cb->ctx; +const struct genl_info *info =genl_info_dump (cb); +struct net_shaper_info *shaper; +struct net_device *dev; +unsigned long handle; +int ret; + + ret =fetch_dev (info, &dev); +if (ret) +return ret; + +BUILD_BUG_ON (sizeof (struct net_shaper_nl_ctx ) >sizeof (cb->ctx)); + +/* don't error out dumps performed before any set operation */ +if (!dev->net_shaper_data) { + ret =0 ; + goto put; + } + +xa_for_each_range (&dev->net_shaper_data->shapers, handle, shaper, + ctx->start_handle,U32_MAX ) { + ret =net_shaper_fill_one (skb, shaper, info); +if (ret) + goto put; + + ctx->start_handle = handle; + } + +put: +netdev_put (dev,NULL ); +return ret; }int net_shaper_nl_set_doit (struct sk_buff *skb,struct genl_info *info)@@ -26,6 +249,30 @@ int net_shaper_nl_delete_doit(struct sk_buff *skb, struct genl_info *info)return -EOPNOTSUPP ; } +int net_shaper_nl_group_doit (struct sk_buff *skb,struct genl_info *info) +{ +return -EOPNOTSUPP ; +} + +void dev_shaper_flush (struct net_device *dev) +{ +struct xarray *xa =__sc_container (dev); +struct net_shaper_info *cur; +unsigned long index; + +if (!xa) +return ; + +xa_lock (xa);
net/shaper/shaper.c int net_shaper_nl_delete_doit(struct sk_buff *skb, struct genl_info *info) · line 276
Quoted 10 lines
net/shaper/shaper.c +9
-0+xa_for_each (xa, index, cur) { +__xa_erase (xa, index); +kfree (cur); + } +idr_destroy (&dev->net_shaper_data->detached_ids); +xa_unlock (xa); +kfree (xa); +} +static int __init shaper_init (void )
fetch_devfill_handleparse_handlesc_lookup__sc_containerdev_shaper_flushshaper_init
Could you perhaps maintain net_shaper_ prefix for all of there?
Quoted 5 lines
net/shaper/shaper.c +0
-0{return genl_register_family (&net_shaper_nl_family);Signature · 1 line
2.45.2
Paolo Abeni
maintainerRe: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 16 lines · Jiri Pirko
Quoted 15 lines · Tue, Jul 30, 2024 at 10:39:46PM CEST, [email protected] wrote:
include/net/net_shaper.h new file +15
-0+/** +* net_shaper_make_handle - creates an unique shaper identifier +* @scope: the shaper scope +* @id: the shaper id number +* +* Return: an unique identifier for the shaper +* +* Combines the specified arguments to create an unique identifier for +* the shaper. The @id argument semantic depends on the +* specified scope. +* For @NET_SHAPER_SCOPE_QUEUE_GROUP, @id is the queue group id +* For @NET_SHAPER_SCOPE_QUEUE, @id is the queue number. +* For @NET_SHAPER_SCOPE_VF, @id is virtual function number. +*/ +static inline u32 net_shaper_make_handle(enum net_shaper_scope scope,
Quoted 8 lines
include/net/net_shaper.h line 132
Quoted 4 lines
include/net/net_shaper.h new file +4
-0+ int id) +{ +return FIELD_PREP (NET_SHAPER_SCOPE_MASK , scope) | +FIELD_PREP (NET_SHAPER_ID_MASK , id);Perhaps some scopes may find only part of u32 as limitting for id in the future? I find it elegant to have it in single u32 though. u64 may be nicer (I know, xarray) :)
With this code the id limit is 2^26 for each scope. The most capable H/W I'm aware of supports at most 64K shapers, overall. Are you aware of any specific constraint we need to address?
[...]
Quoted 6 lines
Quoted 6 lines
int
net_shaper_nl_get_doit(struct sk_buff *skb, struct genl_info *info){net/shaper/shaper.c +3
-1-return -EOPNOTSUPP ; +struct net_shaper_info *shaper; +struct net_device *dev; +struct sk_buff *msg;
Quoted 8 lines
net/shaper/shaper.c line 165
Quoted 4 lines
net/shaper/shaper.c +4
-0+u32 handle; +int ret; + + ret =fetch_dev (info, &dev);This is quite
net_devicecentric. Devlink rate shaper should be eventually visible throught this api as well, won't they? How do you imagine that?
I'm unsure we are on the same page. Do you foresee this to replace and obsoleted the existing devlink rate API? It was not our so far.
Quoted 5 lines
Could we have various types of binding? Something like:
NET_SHAPER_A_BINDINGnest
NET_SHAPER_A_BINDING_IFINDEXu32
Quoted 8 lines
or:
NET_SHAPER_A_BINDINGnest
NET_SHAPER_A_BINDING_DEVLINK_PORTnest
DEVLINK_ATTR_BUS_NAMEstring
DEVLINK_ATTR_DEV_NAMEstring
DEVLINK_ATTR_PORT_INDEXu32?
Somewhat related, the current get()/dump() operations currently don't return the shaper ifindex. I guess we can include 'scope' and 'id' under NET_SHAPER_A_BINDING and replace the existing handle attribute with it.
It should cover eventual future devlink extensions and provide all the relevant info for get/dump sake.
Quoted 14 lines
Quoted 2 lines
+
static int__initshaper_init(void)
fetch_devfill_handleparse_handlesc_lookup__sc_containerdev_shaper_flushshaper_init
Quoted 1 line
Could you perhaps maintain
net_shaper_prefix for all of there?
Most of the helpers are static and should never be visible outside this compilation unit, so I did not bother with a prefix, I'll add it in the next revision.
Thanks,
Paolo
Re: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 26 lines · Tue, Aug 13, 2024 at 05:17:12PM CEST, [email protected] wrote:
Quoted 16 lines · Jiri Pirko
Quoted 15 lines · Tue, Jul 30, 2024 at 10:39:46PM CEST, [email protected] wrote:
include/net/net_shaper.h new file +15
-0+/** +* net_shaper_make_handle - creates an unique shaper identifier +* @scope: the shaper scope +* @id: the shaper id number +* +* Return: an unique identifier for the shaper +* +* Combines the specified arguments to create an unique identifier for +* the shaper. The @id argument semantic depends on the +* specified scope. +* For @NET_SHAPER_SCOPE_QUEUE_GROUP, @id is the queue group id +* For @NET_SHAPER_SCOPE_QUEUE, @id is the queue number. +* For @NET_SHAPER_SCOPE_VF, @id is virtual function number. +*/ +static inline u32 net_shaper_make_handle(enum net_shaper_scope scope,Quoted 8 lines
include/net/net_shaper.h line 132
Quoted 4 lines
include/net/net_shaper.h new file +4
-0+ int id) +{ +return FIELD_PREP (NET_SHAPER_SCOPE_MASK , scope) | +FIELD_PREP (NET_SHAPER_ID_MASK , id);Perhaps some scopes may find only part of u32 as limitting for id in the future? I find it elegant to have it in single u32 though. u64 may be nicer (I know, xarray) :)
Quoted 3 lines
With this code the id limit is 2^26 for each scope. The most capable H/W I'm aware of supports at most 64K shapers, overall. Are you aware of any specific constraint we need to address?
Nope. Just thinking out loud.
Quoted 17 lines
[...]
Quoted 6 lines
Quoted 6 lines
int
net_shaper_nl_get_doit(struct sk_buff *skb, struct genl_info *info){net/shaper/shaper.c +3
-1-return -EOPNOTSUPP ; +struct net_shaper_info *shaper; +struct net_device *dev; +struct sk_buff *msg;Quoted 8 lines
net/shaper/shaper.c line 165
Quoted 4 lines
net/shaper/shaper.c +4
-0+u32 handle; +int ret; + + ret =fetch_dev (info, &dev);This is quite
net_devicecentric. Devlink rate shaper should be eventually visible throught this api as well, won't they? How do you imagine that?
Quoted 2 lines
I'm unsure we are on the same page. Do you foresee this to replace and obsoleted the existing devlink rate API? It was not our so far.
Driver-api-wise, yes. I believe that was the goal, to have drivers to implement one rate api.
Quoted 13 lines
Quoted 13 lines
Could we have various types of binding? Something like:
NET_SHAPER_A_BINDINGnest
NET_SHAPER_A_BINDING_IFINDEXu32or:
NET_SHAPER_A_BINDINGnest
NET_SHAPER_A_BINDING_DEVLINK_PORTnest
DEVLINK_ATTR_BUS_NAMEstring
DEVLINK_ATTR_DEV_NAMEstring
DEVLINK_ATTR_PORT_INDEXu32
Quoted 8 lines
Quoted 1 line
?
Somewhat related, the current get()/dump() operations currently don't return the shaper ifindex. I guess we can include 'scope' and 'id' under
NET_SHAPER_A_BINDINGand replace the existing handle attribute with it.It should cover eventual future devlink extensions and provide all the relevant info for get/dump sake.
Sounds fine.
Quoted 15 lines
Quoted 15 lines
Quoted 3 lines
+
static int__initshaper_init(void)
fetch_devfill_handleparse_handlesc_lookup__sc_containerdev_shaper_flushshaper_init
Quoted 5 lines
Quoted 1 line
Could you perhaps maintain
net_shaper_prefix for all of there?Most of the helpers are static and should never be visible outside this compilation unit, so I did not bother with a prefix, I'll add it in the next revision.
Thanks.
Quoted 5 lines
Thanks,
Paolo
Paolo Abeni
maintainerRe: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 18 lines · Jiri Pirko
Quoted 17 lines · Tue, Aug 13, 2024 at 05:17:12PM CEST, [email protected] wrote:
On 8/1/24 15:42, Jiri Pirko wrote:
[...]Quoted 14 lines
net/shaper/shaper.c line 165
Quoted 10 lines
int
net_shaper_nl_get_doit(struct sk_buff *skb, struct genl_info *info){net/shaper/shaper.c +7
-1-return -EOPNOTSUPP ; +struct net_shaper_info *shaper; +struct net_device *dev; +struct sk_buff *msg; +u32 handle; +int ret; + + ret =fetch_dev (info, &dev);This is quite
net_devicecentric. Devlink rate shaper should be eventually visible throught this api as well, won't they? How do you imagine that?
Quoted 5 lines
Quoted 2 lines
I'm unsure we are on the same page. Do you foresee this to replace and obsoleted the existing devlink rate API? It was not our so far.
Driver-api-wise, yes. I believe that was the goal, to have drivers to implement one rate api.
I initially underlooked at this point, I'm sorry.
Re-reading this I think we are not on the same page.
The net_shaper_ops are per network device operations: they are aimed (also) at consolidating network device shaping related callbacks, but they can't operate on non-network device objects (devlink port).
Cheers,
Paolo
Re: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 25 lines · Fri, Aug 16, 2024 at 10:52:58AM CEST, [email protected] wrote:
Quoted 18 lines · Jiri Pirko
Quoted 17 lines · Tue, Aug 13, 2024 at 05:17:12PM CEST, [email protected] wrote:
On 8/1/24 15:42, Jiri Pirko wrote:
[...]Quoted 14 lines
net/shaper/shaper.c line 165
Quoted 10 lines
int
net_shaper_nl_get_doit(struct sk_buff *skb, struct genl_info *info){net/shaper/shaper.c +7
-1-return -EOPNOTSUPP ; +struct net_shaper_info *shaper; +struct net_device *dev; +struct sk_buff *msg; +u32 handle; +int ret; + + ret =fetch_dev (info, &dev);This is quite
net_devicecentric. Devlink rate shaper should be eventually visible throught this api as well, won't they? How do you imagine that?Quoted 5 lines
Quoted 2 lines
I'm unsure we are on the same page. Do you foresee this to replace and obsoleted the existing devlink rate API? It was not our so far.
Driver-api-wise, yes. I believe that was the goal, to have drivers to implement one rate api.
Quoted 7 lines
I initially underlooked at this point, I'm sorry.
Re-reading this I think we are not on the same page.
The
net_shaper_opsare per network device operations: they are aimed (also) at consolidating network device shaping related callbacks, but they can't operate on non-network device objects (devlink port).
Why not?
Quoted 5 lines
Cheers,
Paolo
Paolo Abeni
maintainerRe: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 28 lines · Jiri Pirko
Quoted 27 lines · Fri, Aug 16, 2024 at 10:52:58AM CEST, [email protected] wrote:
Quoted 18 lines · Jiri Pirko
Quoted 17 lines · Tue, Aug 13, 2024 at 05:17:12PM CEST, [email protected] wrote:
On 8/1/24 15:42, Jiri Pirko wrote:
[...]Quoted 14 lines
net/shaper/shaper.c line 165
Quoted 10 lines
int
net_shaper_nl_get_doit(struct sk_buff *skb, struct genl_info *info){net/shaper/shaper.c +7
-1-return -EOPNOTSUPP ; +struct net_shaper_info *shaper; +struct net_device *dev; +struct sk_buff *msg; +u32 handle; +int ret; + + ret =fetch_dev (info, &dev);This is quite
net_devicecentric. Devlink rate shaper should be eventually visible throught this api as well, won't they? How do you imagine that?Quoted 5 lines
Quoted 2 lines
I'm unsure we are on the same page. Do you foresee this to replace and obsoleted the existing devlink rate API? It was not our so far.
Driver-api-wise, yes. I believe that was the goal, to have drivers to implement one rate api.
I initially underlooked at this point, I'm sorry.
Quoted 7 lines
Quoted 5 lines
Re-reading this I think we are not on the same page.
The
net_shaper_opsare per network device operations: they are aimed (also) at consolidating network device shaping related callbacks, but they can't operate on non-network device objects (devlink port).Why not?
Isn't the whole point of devlink to configure objects that are directly related to any network device? Would be somewhat awkward accessing devlink port going through some net_device?
Side note: I experimented adding the 'binging' abstraction to this API and gives a quite significant uglification to the user syntax (due to the additional nesting required) and the code.
Still, if there is a very strong need for controlling devlink rate via this API _and_ we can assume that each net_device "relates" (/references/is connected to) at most a single devlink object (out of sheer ignorance on my side I'm unsure about this point, but skimming over the existing implementations it looks so), the current API definition would be IMHO sufficient and clean enough to reach for both devlink port rate objects and devlink node rate objects.
We could define additional scopes for each of such objects and use the id to discriminate the specific port or node within the relevant devlink.
I think such scopes definition should come with related implementation, e.g. not with this series.
Thanks,
Paolo
Re: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 33 lines · Mon, Aug 19, 2024 at 11:33:28AM CEST, [email protected] wrote:
Quoted 30 lines · Jiri Pirko
Quoted 29 lines · Fri, Aug 16, 2024 at 10:52:58AM CEST, [email protected] wrote:
Quoted 18 lines · Jiri Pirko
Quoted 17 lines · Tue, Aug 13, 2024 at 05:17:12PM CEST, [email protected] wrote:
On 8/1/24 15:42, Jiri Pirko wrote:
[...]Quoted 14 lines
Review
Quoted 10 lines
int
net_shaper_nl_get_doit(struct sk_buff *skb, struct genl_info *info){(quoted diff) +7
-1- return -EOPNOTSUPP; + struct net_shaper_info *shaper; + struct net_device *dev; + struct sk_buff *msg; + u32 handle; + int ret; + + ret = fetch_dev(info, &dev);This is quite
net_devicecentric. Devlink rate shaper should be eventually visible throught this api as well, won't they? How do you imagine that?Quoted 5 lines
Quoted 2 lines
I'm unsure we are on the same page. Do you foresee this to replace and obsoleted the existing devlink rate API? It was not our so far.
Driver-api-wise, yes. I believe that was the goal, to have drivers to implement one rate api.
I initially underlooked at this point, I'm sorry.
Re-reading this I think we are not on the same page.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
The
net_shaper_opsare per network device operations: they are aimed (also) at consolidating network device shaping related callbacks, but they can't operate on non-network device objects (devlink port).Why not?
Isn't the whole point of devlink to configure objects that are directly related to any network device? Would be somewhat awkward accessing devlink
Yeah, not even network. Just "a device".
Quoted 1 line
port going through some
net_device?
I'm not sure why you are asking that. I didn't suggest anything like that. On contrary, as your API is netdev centric, I suggested to disconnect from netdev to the shapers could be used not only with them. This is what I understood was a plan from very beginning. I may be wrong though....
Quoted 5 lines
Side note: I experimented adding the 'binging' abstraction to this API and gives a quite significant uglification to the user syntax (due to the additional nesting required) and the code.
Quoted 7 lines
Still, if there is a very strong need for controlling devlink rate via this API _and_ we can assume that each
net_device"relates" (/references/is connected to) at most a single devlink object (out of sheer ignorance on my side I'm unsure about this point, but skimming over the existing implementations it looks so), the current API definition would be IMHO sufficient and clean enough to reach for both devlink port rate objects and devlink node rate objects.
Don't assume this. Not always true.
Quoted 3 lines
We could define additional scopes for each of such objects and use the id to discriminate the specific port or node within the relevant devlink.
But you still want to use some netdevice as a handle IIUC, is that right?
Quoted 8 lines
I think such scopes definition should come with related implementation, e.g. not with this series.
Thanks,
Paolo
Paolo Abeni
maintainerRe: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 8 lines · Jiri Pirko
Quoted 3 lines · Mon, Aug 19, 2024 at 11:33:28AM CEST, [email protected] wrote:
Isn't the whole point of devlink to configure objects that are directly related to any network device? Would be somewhat awkward accessing devlink port going through some
net_device?I'm not sure why you are asking that. I didn't suggest anything like that. On contrary, as your API is netdev centric, I suggested to disconnect from netdev to the shapers could be used not only with them.
ndo_shaper_ops are basically net_device ndo. Any implementation of them will operate 'trough some net_device'.
I'm still not sure which one of the following you mean:
1) the shaper NL interface must be able to manage devlink (rate) objects. The core will lookup the devlink obj and use devlink_ops to do the change.
2) the shaper NL interface must be able to manage devlink (rate) objects, the core will use ndo_shaper_ops to do the actual change.
3) something else?
In my previous reply, I assumed you wanted option 2). If so, which kind of object should implement the ndo_shaper_ops callbacks? net_device? devlink? other?
Quoted 1 line
This is what I understood was a plan from very beginning.
Originally the scope was much more limited than what defined here. Jakub asked to implement an interface capable to unify the network device shaping/rate related callbacks.
In a previous revision, I stretched that to cover objects "above" the network device level (e.g. PF/VF/SFs groups), but then I left them out because:
- it caused several inconsistencies (among other thing we can't use the 'shaper cache' there and Jakub wants the cache in place).
- we already have devlink for that.
Quoted 5 lines
Quoted 2 lines
We could define additional scopes for each of such objects and use the id to discriminate the specific port or node within the relevant devlink.
But you still want to use some netdevice as a handle IIUC, is that right?
The revision of the series that I hope to share soon still used net_device ndos. Shapers are identified within the network device by an handle.
Cheers,
Paolo
Re: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 6 lines · Mon, Aug 19, 2024 at 06:52:22PM CEST, [email protected] wrote:
Quoted 5 lines · Jiri Pirko
Quoted 3 lines · Mon, Aug 19, 2024 at 11:33:28AM CEST, [email protected] wrote:
Isn't the whole point of devlink to configure objects that are directly related to any network device? Would be somewhat awkward accessing devlink port going through some
net_device?
Quoted 6 lines
Quoted 3 lines
I'm not sure why you are asking that. I didn't suggest anything like that. On contrary, as your API is netdev centric, I suggested to disconnect from netdev to the shapers could be used not only with them.
ndo_shaper_opsare basicallynet_devicendo. Any implementation of them will operate 'trough somenet_device'.
I know, I see that in the code. But the question is, does it have to be like that?
Quoted 10 lines
I'm still not sure which one of the following you mean:
1) the shaper NL interface must be able to manage devlink (rate) objects. The core will lookup the devlink obj and use
devlink_opsto do the change.2) the shaper NL interface must be able to manage devlink (rate) objects, the core will use
ndo_shaper_opsto do the actual change.3) something else?
I don't care about the shaper NL in case of devlink rate objects. I care more about in-kernel api. I see shaper NL as one of the UAPIs to consume the shaper infrastructure. The devlink rate is another one. If the devlink rate shapers are visible over shaper NL, IDK. They may be RO perhaps.
Quoted 4 lines
In my previous reply, I assumed you wanted option 2). If so, which kind of object should implement the
ndo_shaper_opscallbacks?net_device? devlink? other?
Whoever implements the shaper in driver. If that is net_device tight shaper, driver should work with net_device. If that is devlink port related shaper, driver should work on top of devlink port based api.
Quoted 6 lines
Quoted 2 lines
This is what I understood was a plan from very beginning.
Originally the scope was much more limited than what defined here. Jakub asked to implement an interface capable to unify the network device shaping/rate related callbacks.
I'm not saying this is deal breaker for me. I just think that if the api is designed to be independent of the object shaper is bound to (netdev/devlink_port/etc), it would be much much easier to extend in the future. If you do everything netdev-centric from start, I'm sure no shaper consolidation will ever happen. And that I thought was one of the goals.
Perhaps Jakub has opinion.
Quoted 21 lines
In a previous revision, I stretched that to cover objects "above" the network device level (e.g. PF/VF/SFs groups), but then I left them out because:
- it caused several inconsistencies (among other thing we can't use the 'shaper cache' there and Jakub wants the cache in place).
- we already have devlink for that.Quoted 5 lines
Quoted 2 lines
We could define additional scopes for each of such objects and use the id to discriminate the specific port or node within the relevant devlink.
But you still want to use some netdevice as a handle IIUC, is that right?
The revision of the series that I hope to share soon still used
net_devicendos. Shapers are identified within the network device by an handle.Cheers,
Paolo
Jakub Kicinski
maintainerRe: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 6 lines · On Thu, 22 Aug 2024 14:02:54 +0200 Jiri Pirko wrote:
Quoted 5 lines
Quoted 1 line
This is what I understood was a plan from very beginning.
Originally the scope was much more limited than what defined here. Jakub asked to implement an interface capable to unify the network device shaping/rate related callbacks.
Quoted 8 lines
I'm not saying this is deal breaker for me. I just think that if the api is designed to be independent of the object shaper is bound to (netdev/devlink_port/etc), it would be much much easier to extend in the future. If you do everything netdev-centric from start, I'm sure no shaper consolidation will ever happen. And that I thought was one of the goals.
Perhaps Jakub has opinion.
I think you and I are on the same page :) Other than the "reference object" (netdev / devlink port) the driver facing API should be identical. Making it possible for the same driver code to handle translating the parameters into HW config / FW requests, whether they shape at the device (devlink) or port (netdev) level.
Shaper NL for netdevs is separate from internal representation and driver API in my mind. My initial ask was to create the internal representation first, make sure it can express devlink and handful of exiting netdev APIs, and only once that's merged worry about exposing it via a new NL.
I'm not opposed to showing devlink shapers in netdev NL (RO as you say) but talking about it now strikes me as cart before the horse.
Paolo Abeni
maintainerRe: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 22 lines · Jakub Kicinski
Quoted 6 lines · On Thu, 22 Aug 2024 14:02:54 +0200 Jiri Pirko wrote:
Quoted 5 lines
Quoted 1 line
This is what I understood was a plan from very beginning.
Originally the scope was much more limited than what defined here. Jakub asked to implement an interface capable to unify the network device shaping/rate related callbacks.
Quoted 8 lines
I'm not saying this is deal breaker for me. I just think that if the api is designed to be independent of the object shaper is bound to (netdev/devlink_port/etc), it would be much much easier to extend in the future. If you do everything netdev-centric from start, I'm sure no shaper consolidation will ever happen. And that I thought was one of the goals.
Perhaps Jakub has opinion.
I think you and I are on the same page :) Other than the "reference object" (netdev / devlink port) the driver facing API should be identical. Making it possible for the same driver code to handle translating the parameters into HW config / FW requests, whether they shape at the device (devlink) or port (netdev) level.
Quoted 8 lines
Shaper NL for netdevs is separate from internal representation and driver API in my mind. My initial ask was to create the internal representation first, make sure it can express devlink and handful of exiting netdev APIs, and only once that's merged worry about exposing it via a new NL.
I'm not opposed to showing devlink shapers in netdev NL (RO as you say) but talking about it now strikes me as cart before the horse.
FTR, I don't see both of you on the same page ?!?
I read the above as Jiri's preference is a single ndo set to control both devlink and device shapers, while I read Jakub's preference as for different sets of operations that will use the same arguments to specify the shaper informations.
Or to phrase the above differently, Jiri is focusing on the shaper
"binding" (how to locate/access it) while Jakub is focusing on the shaper "info" (content/definition/attributes). Please correct me If I misread something.
Still for the record, I interpret the current proposal as not clashing
with Jakub's preference, and being tolerated from Jiri, again please correct me if I read too far.
Thanks,
Paolo
Jakub Kicinski
maintainerRe: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 24 lines · On Thu, 22 Aug 2024 22:30:35 +0200 Paolo Abeni wrote:
Quoted 15 lines
Quoted 8 lines
I'm not saying this is deal breaker for me. I just think that if the api is designed to be independent of the object shaper is bound to (netdev/devlink_port/etc), it would be much much easier to extend in the future. If you do everything netdev-centric from start, I'm sure no shaper consolidation will ever happen. And that I thought was one of the goals.
Perhaps Jakub has opinion.
I think you and I are on the same page :) Other than the "reference object" (netdev / devlink port) the driver facing API should be identical. Making it possible for the same driver code to handle translating the parameters into HW config / FW requests, whether they shape at the device (devlink) or port (netdev) level.
Quoted 8 lines
Shaper NL for netdevs is separate from internal representation and driver API in my mind. My initial ask was to create the internal representation first, make sure it can express devlink and handful of exiting netdev APIs, and only once that's merged worry about exposing it via a new NL.
I'm not opposed to showing devlink shapers in netdev NL (RO as you say) but talking about it now strikes me as cart before the horse.
Quoted 6 lines
FTR, I don't see both of you on the same page ?!?
I read the above as Jiri's preference is a single ndo set to control both devlink and device shapers, while I read Jakub's preference as for different sets of operations that will use the same arguments to specify the shaper informations.
Jiri replied:
Quoted 1 line
which kind of object should implement the
ndo_shaper_opscallbacks?
Whoever implements the shaper in driver. If that is net_device tight shaper, driver should work with net_device. If that is devlink port related shaper, driver should work on top of devlink port based api.
I interpret this as having two almost identical versions of shaper ops, the only difference is that one takes netdev and the other devlink port. We could simplify it slightly, and call the ndo for getting devlink port from netdev, and always pass devlink port in?
I _think_ (but I'm not 100% sure) that Jiri does _not_ mean that we would be able to render the internal shaper tree as ops for the existing devlink rate API. Because that may cause scope creep, inconsistencies and duplication.
Quoted 8 lines
Or to phrase the above differently, Jiri is focusing on the shaper "binding" (how to locate/access it) while Jakub is focusing on the shaper "info" (content/definition/attributes). Please correct me If I misread something.
Still for the record, I interpret the current proposal as not clashing with Jakub's preference, and being tolerated from Jiri, again please correct me if I read too far.
One more thing, Jiri said:
If you do everything netdev-centric from start, I'm sure no shaper consolidation will ever happen. And that I thought was one of the goals.
Consolidation was indeed one of the goals, and I share Jiri's concern :(
Re: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 22 lines · Fri, Aug 23, 2024 at 12:56:08AM CEST, [email protected] wrote:
Quoted 21 lines · On Thu, 22 Aug 2024 22:30:35 +0200 Paolo Abeni wrote:
Quoted 21 lines
Quoted 8 lines
I'm not saying this is deal breaker for me. I just think that if the api is designed to be independent of the object shaper is bound to (netdev/devlink_port/etc), it would be much much easier to extend in the future. If you do everything netdev-centric from start, I'm sure no shaper consolidation will ever happen. And that I thought was one of the goals.
Perhaps Jakub has opinion.
I think you and I are on the same page :) Other than the "reference object" (netdev / devlink port) the driver facing API should be identical. Making it possible for the same driver code to handle translating the parameters into HW config / FW requests, whether they shape at the device (devlink) or port (netdev) level.
Shaper NL for netdevs is separate from internal representation and driver API in my mind. My initial ask was to create the internal representation first, make sure it can express devlink and handful of exiting netdev APIs, and only once that's merged worry about exposing it via a new NL.
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
I'm not opposed to showing devlink shapers in netdev NL (RO as you say) but talking about it now strikes me as cart before the horse.
FTR, I don't see both of you on the same page ?!?
I read the above as Jiri's preference is a single ndo set to control
"Ndo" stands for netdev op and they are all tightly coupled with netdevices. So, "single ndo set to control both devlink and netdev shapers" sounds like nonsense to me.
Quoted 6 lines
Quoted 3 lines
both devlink and device shapers, while I read Jakub's preference as for different sets of operations that will use the same arguments to specify the shaper informations.
Jiri replied:
Quoted 8 lines
Quoted 1 line
which kind of object should implement the
ndo_shaper_opscallbacks?Whoever implements the shaper in driver. If that is
net_devicetight shaper, driver should work withnet_device. If that is devlink port related shaper, driver should work on top of devlink port based api.I interpret this as having two almost identical versions of shaper ops, the only difference is that one takes netdev and the other devlink port.
Could be done like that. But see more below.
Quoted 2 lines
We could simplify it slightly, and call the ndo for getting devlink port from netdev, and always pass devlink port in?
No please. Keep that separate. You can't always rely on devlink port having netdev paired with it. Plus, it would be odd callpath from devlink port code to netdev op. Not to mention locking :)
Quoted 5 lines
I _think_ (but I'm not 100% sure) that Jiri does _not_ mean that we would be able to render the internal shaper tree as ops for the existing devlink rate API. Because that may cause scope creep, inconsistencies and duplication.
Not sure what you mean by this. Devlink rate UAPI will stay the same. Only the backend will use new driver API instead of the existing one.
Quoted 5 lines
Quoted 5 lines
Or to phrase the above differently, Jiri is focusing on the shaper "binding" (how to locate/access it) while Jakub is focusing on the shaper "info" (content/definition/attributes). Please correct me If I misread something.
Two(or more) similar ops structs looks odd to me. I think that the ops should should be shared and just the "binding point" should be somehow abstracted out. Code speaks, let me draft how it could be done:
enum net_shaper_binding_type {
NET_SHAPER_BINDING_TYPE_NETDEV,
NET_SHAPER_BINDING_TYPE_DEVLINK_PORT,
};
struct net_shaper_binding {
enum net_shaper_binding_type type;
union {
struct net_device *netdev;
struct devlink_port *devlink_port;
};
};struct net_shaper_ops {
+ /**
+ * @group: create the specified shapers scheduling group + * + * Nest the @leaves shapers identified by @leaves_handles under the + * @root shaper identified by @root_handle. All the shapers belong + * to the network device @dev. The @leaves and @leaves_handles shaper + * arrays size is specified by @leaves_count. + * Create either the @leaves and the @root shaper; or if they already + * exists, links them together in the desired way. + * @leaves scope must be NET_SHAPER_SCOPE_QUEUE. + * + * Returns 0 on group successfully created, otherwise an negative + * error value and set @extack to describe the failure's reason. + */ + int (*group)(const struct net_shaper_binding *binding, int leaves_count, + const struct net_shaper_handle *leaves_handles, + const struct net_shaper_info *leaves, + const struct net_shaper_handle *root_handle, + const struct net_shaper_info *root, + struct netlink_ext_ack *extack); + + /** + * @set: Updates the specified shaper + * + * Updates or creates the @shaper identified by the provided @handle + * on the given device @dev. + * + * Returns 0 on success, otherwise an negative + * error value and set @extack to describe the failure's reason. + */ + int (*set)(const struct net_shaper_binding *binding, + const struct net_shaper_handle *handle, + const struct net_shaper_info *shaper, + struct netlink_ext_ack *extack); + + /** + * @delete: Removes the specified shaper from the NIC + * + * Removes the shaper configuration as identified by the given @handle + * on the specified device @dev, restoring the default behavior. + * + * Returns 0 on success, otherwise an negative + * error value and set @extack to describe the failure's reason. + */
+ int (*delete)(const struct net_shaper_binding *binding,
+ const struct net_shaper_handle *handle,
+ struct netlink_ext_ack *extack);
+};
static inline struct net_device * net_shaper_binding_netdev(struct net_shaper_binding *binding)
{
WARN_ON(binding->type != NET_SHAPER_BINDING_TYPE_NETDEV)
return binding->netdev;
}static inline struct devlink_port * net_shaper_binding_devlink_port(struct net_shaper_binding *binding)
{
WARN_ON(binding->type != NET_SHAPER_BINDING_TYPE_DEVLINK_PORT)
return binding->devlink_port;
}Then whoever calls the op fills-up the binding structure accordingly.
drivers can implement ops, for netdev-bound shaper like this:
static int driverx_shaper_set(const struct net_shaper_binding *binding,
const struct net_shaper_handle *handle, const struct net_shaper_info *shaper, struct netlink_ext_ack *extack);
{
struct net_device *netdev = net_shaper_binding_netdev(binding);
......
}struct net_shaper_ops driverx_shaper_ops {
.set = driverx_shaper_set;
......
};static const struct net_device_ops driverx_netdev_ops = {
.net_shaper_ops = &driverx_shaper_ops,
......
};
drivers can implement ops, for devlink_port-bound shaper like this:
static int drivery_shaper_set(const struct net_shaper_binding *binding,
const struct net_shaper_handle *handle, const struct net_shaper_info *shaper, struct netlink_ext_ack *extack);
{
struct devlink_port *devlink_port = net_shaper_binding_devlink_port(binding);
......
}struct net_shaper_ops drivery_shaper_ops {
.set = drivery_shaper_set;
......
};static const struct devlink_port_ops drivery_devlink_port_ops = {
.port_shaper_ops = &drivery_shaper_ops,
};
Some driver can even have one ops implementation for both, and distinguish just by looking at binding->type.
Quoted 11 lines
Quoted 4 lines
Still for the record, I interpret the current proposal as not clashing with Jakub's preference, and being tolerated from Jiri, again please correct me if I read too far.
One more thing, Jiri said:
If you do everything netdev-centric from start, I'm sure no shaper consolidation will ever happen. And that I thought was one of the goals.
Consolidation was indeed one of the goals, and I share Jiri's concern :(
Good.
Paolo Abeni
maintainerRe: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 26 lines · Jiri Pirko
Quoted 25 lines · Fri, Aug 23, 2024 at 12:56:08AM CEST, [email protected] wrote:
Quoted 24 lines · On Thu, 22 Aug 2024 22:30:35 +0200 Paolo Abeni wrote:
Quoted 23 lines
Quoted 8 lines
I'm not saying this is deal breaker for me. I just think that if the api is designed to be independent of the object shaper is bound to (netdev/devlink_port/etc), it would be much much easier to extend in the future. If you do everything netdev-centric from start, I'm sure no shaper consolidation will ever happen. And that I thought was one of the goals.
Perhaps Jakub has opinion.
I think you and I are on the same page :) Other than the "reference object" (netdev / devlink port) the driver facing API should be identical. Making it possible for the same driver code to handle translating the parameters into HW config / FW requests, whether they shape at the device (devlink) or port (netdev) level.
Shaper NL for netdevs is separate from internal representation and driver API in my mind. My initial ask was to create the internal representation first, make sure it can express devlink and handful of exiting netdev APIs, and only once that's merged worry about exposing it via a new NL.
I'm not opposed to showing devlink shapers in netdev NL (RO as you say) but talking about it now strikes me as cart before the horse.
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
FTR, I don't see both of you on the same page ?!?
I read the above as Jiri's preference is a single ndo set to control
"Ndo" stands for netdev op and they are all tightly coupled with netdevices. So, "single ndo set to control both devlink and netdev shapers" sounds like nonsense to me.
In this context, "NDOs" == set of function pointers operating on the same object.
Quoted 106 lines
Quoted 4 lines
Quoted 4 lines
Or to phrase the above differently, Jiri is focusing on the shaper "binding" (how to locate/access it) while Jakub is focusing on the shaper "info" (content/definition/attributes). Please correct me If I misread something.
Two(or more) similar ops structs looks odd to me. I think that the ops should should be shared and just the "binding point" should be somehow abstracted out. Code speaks, let me draft how it could be done:
enum
net_shaper_binding_type{
NET_SHAPER_BINDING_TYPE_NETDEV,
NET_SHAPER_BINDING_TYPE_DEVLINK_PORT,
};struct net_shaper_binding { enum net_shaper_binding_type type; union { struct net_device *netdev; struct devlink_port *devlink_port; }; };struct
net_shaper_ops{(quoted diff) +48
-0+ /** + * @group: create the specified shapers scheduling group + * + * Nest the @leaves shapers identified by @leaves_handles under the + * @root shaper identified by @root_handle. All the shapers belong + * to the network device @dev. The @leaves and @leaves_handles shaper + * arrays size is specified by @leaves_count. + * Create either the @leaves and the @root shaper; or if they already + * exists, links them together in the desired way. + * @leaves scope must be NET_SHAPER_SCOPE_QUEUE. + * + * Returns 0 on group successfully created, otherwise an negative + * error value and set @extack to describe the failure's reason. + */ + int (*group)(const struct net_shaper_binding *binding, int leaves_count, + const struct net_shaper_handle *leaves_handles, + const struct net_shaper_info *leaves, + const struct net_shaper_handle *root_handle, + const struct net_shaper_info *root, + struct netlink_ext_ack *extack); + + /** + * @set: Updates the specified shaper + * + * Updates or creates the @shaper identified by the provided @handle + * on the given device @dev. + * + * Returns 0 on success, otherwise an negative + * error value and set @extack to describe the failure's reason. + */ + int (*set)(const struct net_shaper_binding *binding, + const struct net_shaper_handle *handle, + const struct net_shaper_info *shaper, + struct netlink_ext_ack *extack); + + /** + * @delete: Removes the specified shaper from the NIC + * + * Removes the shaper configuration as identified by the given @handle + * on the specified device @dev, restoring the default behavior. + * + * Returns 0 on success, otherwise an negative + * error value and set @extack to describe the failure's reason. + */ + int (*delete)(const struct net_shaper_binding *binding, + const struct net_shaper_handle *handle, + struct netlink_ext_ack *extack); +};static inline struct
net_device*net_shaper_binding_netdev(struct net_shaper_binding *binding){ WARN_ON(binding->type != NET_SHAPER_BINDING_TYPE_NETDEV) return binding->netdev; }static inline struct
devlink_port*net_shaper_binding_devlink_port(struct net_shaper_binding *binding){ WARN_ON(binding->type != NET_SHAPER_BINDING_TYPE_DEVLINK_PORT) return binding->devlink_port; }Then whoever calls the op fills-up the binding structure accordingly.
drivers can implement ops, for netdev-bound shaper like this:
static int driverx_shaper_set(const struct
net_shaper_binding*binding,
const structnet_shaper_handle*handle, const structnet_shaper_info*shaper, structnetlink_ext_ack*extack);{ struct net_device *netdev = net_shaper_binding_netdev(binding); ...... }struct net_shaper_ops driverx_shaper_ops { .set = driverx_shaper_set; ...... };
Quoted 4 lines
static const struct
net_device_opsdriverx_netdev_ops= {
.net_shaper_ops =&driverx_shaper_ops,
......
};
If I read correctly, the net_shaper_ops caller will have to discriminate between net_device and devlink, do the object-type-specific lookup to get the relevant net_device (or devlink) object and then pass to such net_device (or devlink) a "generic" binding. Did I misread something? If so I must admit I really dislike such interface.
I personally think it would be much cleaner to have 2 separate set of operations, with exactly the same semantic and argument list, except for the first argument (struct net_device or struct devlink).
The driver implementation could still de-duplicate a lot of code, as far as the shaper-related arguments are the same.
Side note, if the intention is to allow the user to touch/modify the queue-level and queue-group-level shapers via the devlink object? if that is the intention, we will need to drop the shaper cache and (re-)introduce a get() callback, as the same shaper could be reached via multiple binding/handle pairs and the core will not know all of such pairs for a given shaper.
Thanks,
Paolo
Re: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 144 lines · Fri, Aug 23, 2024 at 02:58:27PM CEST, [email protected] wrote:
Quoted 26 lines · Jiri Pirko
Quoted 25 lines · Fri, Aug 23, 2024 at 12:56:08AM CEST, [email protected] wrote:
Quoted 24 lines · On Thu, 22 Aug 2024 22:30:35 +0200 Paolo Abeni wrote:
Quoted 23 lines
Quoted 8 lines
I'm not saying this is deal breaker for me. I just think that if the api is designed to be independent of the object shaper is bound to (netdev/devlink_port/etc), it would be much much easier to extend in the future. If you do everything netdev-centric from start, I'm sure no shaper consolidation will ever happen. And that I thought was one of the goals.
Perhaps Jakub has opinion.
I think you and I are on the same page :) Other than the "reference object" (netdev / devlink port) the driver facing API should be identical. Making it possible for the same driver code to handle translating the parameters into HW config / FW requests, whether they shape at the device (devlink) or port (netdev) level.
Shaper NL for netdevs is separate from internal representation and driver API in my mind. My initial ask was to create the internal representation first, make sure it can express devlink and handful of exiting netdev APIs, and only once that's merged worry about exposing it via a new NL.
I'm not opposed to showing devlink shapers in netdev NL (RO as you say) but talking about it now strikes me as cart before the horse.
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
FTR, I don't see both of you on the same page ?!?
I read the above as Jiri's preference is a single ndo set to control
"Ndo" stands for netdev op and they are all tightly coupled with netdevices. So, "single ndo set to control both devlink and netdev shapers" sounds like nonsense to me.
In this context, "NDOs" == set of function pointers operating on the same object.
Quoted 106 lines
Quoted 4 lines
Quoted 4 lines
Or to phrase the above differently, Jiri is focusing on the shaper "binding" (how to locate/access it) while Jakub is focusing on the shaper "info" (content/definition/attributes). Please correct me If I misread something.
Two(or more) similar ops structs looks odd to me. I think that the ops should should be shared and just the "binding point" should be somehow abstracted out. Code speaks, let me draft how it could be done:
enum
net_shaper_binding_type{
NET_SHAPER_BINDING_TYPE_NETDEV,
NET_SHAPER_BINDING_TYPE_DEVLINK_PORT,
};struct net_shaper_binding { enum net_shaper_binding_type type; union { struct net_device *netdev; struct devlink_port *devlink_port; }; };struct
net_shaper_ops{(quoted diff) +48
-0+ /** + * @group: create the specified shapers scheduling group + * + * Nest the @leaves shapers identified by @leaves_handles under the + * @root shaper identified by @root_handle. All the shapers belong + * to the network device @dev. The @leaves and @leaves_handles shaper + * arrays size is specified by @leaves_count. + * Create either the @leaves and the @root shaper; or if they already + * exists, links them together in the desired way. + * @leaves scope must be NET_SHAPER_SCOPE_QUEUE. + * + * Returns 0 on group successfully created, otherwise an negative + * error value and set @extack to describe the failure's reason. + */ + int (*group)(const struct net_shaper_binding *binding, int leaves_count, + const struct net_shaper_handle *leaves_handles, + const struct net_shaper_info *leaves, + const struct net_shaper_handle *root_handle, + const struct net_shaper_info *root, + struct netlink_ext_ack *extack); + + /** + * @set: Updates the specified shaper + * + * Updates or creates the @shaper identified by the provided @handle + * on the given device @dev. + * + * Returns 0 on success, otherwise an negative + * error value and set @extack to describe the failure's reason. + */ + int (*set)(const struct net_shaper_binding *binding, + const struct net_shaper_handle *handle, + const struct net_shaper_info *shaper, + struct netlink_ext_ack *extack); + + /** + * @delete: Removes the specified shaper from the NIC + * + * Removes the shaper configuration as identified by the given @handle + * on the specified device @dev, restoring the default behavior. + * + * Returns 0 on success, otherwise an negative + * error value and set @extack to describe the failure's reason. + */ + int (*delete)(const struct net_shaper_binding *binding, + const struct net_shaper_handle *handle, + struct netlink_ext_ack *extack); +};static inline struct
net_device*net_shaper_binding_netdev(struct net_shaper_binding *binding){ WARN_ON(binding->type != NET_SHAPER_BINDING_TYPE_NETDEV) return binding->netdev; }static inline struct
devlink_port*net_shaper_binding_devlink_port(struct net_shaper_binding *binding){ WARN_ON(binding->type != NET_SHAPER_BINDING_TYPE_DEVLINK_PORT) return binding->devlink_port; }Then whoever calls the op fills-up the binding structure accordingly.
drivers can implement ops, for netdev-bound shaper like this:
static int driverx_shaper_set(const struct
net_shaper_binding*binding,
const structnet_shaper_handle*handle, const structnet_shaper_info*shaper, structnetlink_ext_ack*extack);{ struct net_device *netdev = net_shaper_binding_netdev(binding); ...... }struct net_shaper_ops driverx_shaper_ops { .set = driverx_shaper_set; ...... };
Quoted 10 lines
Quoted 4 lines
static const struct
net_device_opsdriverx_netdev_ops= {
.net_shaper_ops =&driverx_shaper_ops,
......
};If I read correctly, the
net_shaper_opscaller will have to discriminate betweennet_deviceand devlink, do the object-type-specific lookup to get the relevantnet_device(or devlink) object and then pass to suchnet_device(or devlink) a "generic" binding. Did I misread something? If so I must admit I really dislike such interface.
You are right. For example devlink rate set command handler will call the op with devlink_port binding set.
Quoted 4 lines
I personally think it would be much cleaner to have 2 separate set of operations, with exactly the same semantic and argument list, except for the first argument (struct
net_deviceor struct devlink).
I think it is totally subjective. You like something, I like something else. Both works. The amount of duplicity and need to change same things on multiple places in case of bugfixes and extensions is what I dislike on the 2 separate sets. Plus, there might be another binding in the future, will you copy the ops struct again then?
Quoted 10 lines
The driver implementation could still de-duplicate a lot of code, as far as the shaper-related arguments are the same.
Side note, if the intention is to allow the user to touch/modify the queue-level and queue-group-level shapers via the devlink object? if that is the intention, we will need to drop the shaper cache and (re-)introduce a
get()callback, as the same shaper could be reached via multiple binding/handle pairs and the core will not know all of such pairs for a given shaper.
That is a good question, I don't know. But gut feeling is "no".
Quoted 5 lines
Thanks,
Paolo
Paolo Abeni
maintainerRe: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 9 lines · Jiri Pirko
Quoted 3 lines · Fri, Aug 23, 2024 at 02:58:27PM CEST, [email protected] wrote:
I personally think it would be much cleaner to have 2 separate set of operations, with exactly the same semantic and argument list, except for the first argument (struct
net_deviceor struct devlink).I think it is totally subjective. You like something, I like something else. Both works. The amount of duplicity and need to change same things on multiple places in case of bugfixes and extensions is what I dislike on the 2 separate sets.
My guestimate is that the amount of deltas caused by bugfixes and extensions will be much different in practice with the two approaches.
I guess that even with the net_shaper_ops between devlink and net_device, there will be different callbacks implementation for devlink and net_device, right?
If so, the differentiated operation list between devlink and net_device will trade a:
{
struct {net_device, netlink} =
net_shaper_binding_{netdevice_netlink}(binding);
preamble in every callback of every driver for a single additional operations set definition.
It will at least scale better with the number of driver implementing the interface.
Quoted 2 lines
Plus, there might be another binding in
the future, will you copy the ops struct again then?
Yes. Same reasons of the above.
Quoted 11 lines
Quoted 9 lines
The driver implementation could still de-duplicate a lot of code, as far as the shaper-related arguments are the same.
Side note, if the intention is to allow the user to touch/modify the queue-level and queue-group-level shapers via the devlink object? if that is the intention, we will need to drop the shaper cache and (re-)introduce a
get()callback, as the same shaper could be reached via multiple binding/handle pairs and the core will not know all of such pairs for a given shaper.That is a good question, I don't know. But gut feeling is "no".
Well, at least that is not in the direction of unlimited amount of additional time and pain ;)
Thanks,
Paolo
Re: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 21 lines · Fri, Aug 23, 2024 at 04:23:30PM CEST, [email protected] wrote:
Quoted 9 lines · Jiri Pirko
Quoted 3 lines · Fri, Aug 23, 2024 at 02:58:27PM CEST, [email protected] wrote:
I personally think it would be much cleaner to have 2 separate set of operations, with exactly the same semantic and argument list, except for the first argument (struct
net_deviceor struct devlink).I think it is totally subjective. You like something, I like something else. Both works. The amount of duplicity and need to change same things on multiple places in case of bugfixes and extensions is what I dislike on the 2 separate sets.
My guestimate is that the amount of deltas caused by bugfixes and extensions will be much different in practice with the two approaches.
I guess that even with the
net_shaper_opsbetween devlink andnet_device, there will be different callbacks implementation for devlink andnet_device, right?If so, the differentiated operation list between devlink and
net_devicewill trade a:
Quoted 6 lines
{
struct {net_device, netlink} =
net_shaper_binding_{netdevice_netlink}(binding);preamble in every callback of every driver for a single additional operations set definition.
So?
Quoted 8 lines
It will at least scale better with the number of driver implementing the interface.
Quoted 2 lines
Plus, there might be another binding in
the future, will you copy the ops struct again then?Yes. Same reasons of the above.
What's stopping anyone from diverging these 2-n sets? I mean, the whole purpose it unification and finding common ground. Once you have ops duplicated, sooner then later someone does change in A but ignore B. Having the "preamble" in every callback seems like very good tradeoff to prevent this scenario.
Quoted 20 lines
Quoted 4 lines
Quoted 4 lines
The driver implementation could still de-duplicate a lot of code, as far as the shaper-related arguments are the same.
Quoted 8 lines
Quoted 6 lines
Side note, if the intention is to allow the user to touch/modify the queue-level and queue-group-level shapers via the devlink object? if that is the intention, we will need to drop the shaper cache and (re-)introduce a
get()callback, as the same shaper could be reached via multiple binding/handle pairs and the core will not know all of such pairs for a given shaper.That is a good question, I don't know. But gut feeling is "no".
Well, at least that is not in the direction of unlimited amount of additional time and pain ;)
Thanks,
Paolo
Paolo Abeni
maintainerRe: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 22 lines · Jiri Pirko
Quoted 21 lines · Fri, Aug 23, 2024 at 04:23:30PM CEST, [email protected] wrote:
Quoted 9 lines · Jiri Pirko
Quoted 3 lines · Fri, Aug 23, 2024 at 02:58:27PM CEST, [email protected] wrote:
I personally think it would be much cleaner to have 2 separate set of operations, with exactly the same semantic and argument list, except for the first argument (struct
net_deviceor struct devlink).I think it is totally subjective. You like something, I like something else. Both works. The amount of duplicity and need to change same things on multiple places in case of bugfixes and extensions is what I dislike on the 2 separate sets.
My guestimate is that the amount of deltas caused by bugfixes and extensions will be much different in practice with the two approaches.
I guess that even with the
net_shaper_opsbetween devlink andnet_device, there will be different callbacks implementation for devlink andnet_device, right?If so, the differentiated operation list between devlink and
net_devicewill trade a:
Quoted 8 lines
Quoted 6 lines
{
struct {net_device, netlink} =
net_shaper_binding_{netdevice_netlink}(binding);preamble in every callback of every driver for a single additional operations set definition.
So?
The amount of code we would need to change in case of core changes would probably be similar with either the differentiated operations list or not.
Quoted 6 lines
Quoted 6 lines
It will at least scale better with the number of driver implementing the interface.
Quoted 2 lines
Plus, there might be another binding in
the future, will you copy the ops struct again then?
Quoted 7 lines
Quoted 1 line
Yes. Same reasons of the above.
What's stopping anyone from diverging these 2-n sets? I mean, the whole purpose it unification and finding common ground. Once you have ops duplicated, sooner then later someone does change in A but ignore B. Having the "preamble" in every callback seems like very good tradeoff to prevent this scenario.
The main fact is that we do not agree on the above point - unify the shaper_ops between struct net_device and struct devlink.
I think a 3rd party opinion could help moving forward. @Jakub could you please share your view here?
Thanks,
Paolo
Jakub Kicinski
maintainerRe: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 11 lines · On Tue, 27 Aug 2024 16:37:38 +0200 Paolo Abeni wrote:
Quoted 5 lines
What's stopping anyone from diverging these 2-n sets? I mean, the whole purpose it unification and finding common ground. Once you have ops duplicated, sooner then later someone does change in A but ignore B. Having the "preamble" in every callback seems like very good tradeoff to prevent this scenario.
The main fact is that we do not agree on the above point - unify the
shaper_opsbetween structnet_deviceand struct devlink.I think a 3rd party opinion could help moving forward. @Jakub could you please share your view here?
I don't mind Jiri's suggestion. Driver can declare its own helper:
static struct drv_port *drv_shaper_binding_to_prot(const struct net_shaper_binding *binding)
{
if (binding->type == NET_SHAPER_BINDING_TYPE_NETDEV)
return /* netdev_priv() ? */;
if (binding->type == NET_SHAPER_BINDING_TYPE_DEVLINK_PORT)
return /* container_of() ? */;
WARN_ONCE();
return NULL;
}And call that instead of netdev_priv()?
Paolo Abeni
maintainerRe: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 26 lines · Jakub Kicinski
Quoted 11 lines · On Tue, 27 Aug 2024 16:37:38 +0200 Paolo Abeni wrote:
Quoted 5 lines
What's stopping anyone from diverging these 2-n sets? I mean, the whole purpose it unification and finding common ground. Once you have ops duplicated, sooner then later someone does change in A but ignore B. Having the "preamble" in every callback seems like very good tradeoff to prevent this scenario.
The main fact is that we do not agree on the above point - unify the
shaper_opsbetween structnet_deviceand struct devlink.I think a 3rd party opinion could help moving forward. @Jakub could you please share your view here?
I don't mind Jiri's suggestion. Driver can declare its own helper:
static struct
drv_port*drv_shaper_binding_to_prot(const struct net_shaper_binding *binding){ if (binding->type == NET_SHAPER_BINDING_TYPE_NETDEV) return /* netdev_priv() ? */; if (binding->type == NET_SHAPER_BINDING_TYPE_DEVLINK_PORT) return /* container_of() ? */; WARN_ONCE(); return NULL; }
Quoted 1 line
And call that instead of
netdev_priv()?
As I wrote this does not look like something that would help de-deuplicate any code, but since you both seem to agree...
Double checking before I rewrote a significant amount of the core code:
In the NL API, I will replace ifindex with binding, the latter will include nested attributes ifindex, bus_name
and dev_name.
Note that 'struct net_shaper_binding' must include a ‘struct devlink *’ as opposed to a
‘struct devlink_port *’, as mentioned in the code snippet so far, or we will have to drop the
shaper cache and re-introduce a get() operation.
The ops will try to fetch the net_device or devlink according to the provided attributes.
At the moment the ops will error out with ENOTSUP for netlink object. Most core helpers
will be re-factored to accept a 'binding *' argument in place of a 'struct net_device *'.
Full netlink support (for the brave that will implement it later) will likely require at least an
additional scope (devlink_port), include the net_shaper_ops and net_shaper_data inside
struct devlink, and likely code adaptation inside the core.
/P
Jakub Kicinski
maintainerRe: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 19 lines · On Tue, 27 Aug 2024 22:43:09 +0200 Paolo Abeni wrote:
Quoted 19 lines
Quoted 5 lines
The main fact is that we do not agree on the above point - unify the
shaper_opsbetween structnet_deviceand struct devlink.I think a 3rd party opinion could help moving forward. @Jakub could you please share your view here?
I don't mind Jiri's suggestion. Driver can declare its own helper:
static struct
drv_port*drv_shaper_binding_to_port(const struct net_shaper_binding *binding){ if (binding->type == NET_SHAPER_BINDING_TYPE_NETDEV) return /* netdev_priv() ? */; if (binding->type == NET_SHAPER_BINDING_TYPE_DEVLINK_PORT) return /* container_of() ? */; WARN_ONCE(); return NULL; }
Quoted 4 lines
Quoted 1 line
And call that instead of
netdev_priv()?As I wrote this does not look like something that would help de-deuplicate any code, but since you both seem to agree...
To be clear. Given the helper above you can replace:
struct iavf_adapter *adapter = netdev_priv(dev);
with:
struct iavf_adapter *adapter = iavf_from_shaper_handle(handle);
In all the callbacks, and callbacks can now take devlink or other "handles".
Quoted 5 lines
Double checking before I rewrote a significant amount of the core code:
In the NL API, I will replace ifindex with binding, the latter will include nested attributes ifindex,
bus_name
anddev_name.
Any mention of the netlink API makes me worried that the "internal representation should be separate from the uAPI" point is not agreed on or at least not understood :( The NL API does not need other object types. And there's currently no uAPI gap for devlink, AFAIK. So the conversation about "handles" if quite forward-looking.
Quoted 9 lines
Note that 'struct
net_shaper_binding' must include a ‘struct devlink *’ as opposed to a
‘structdevlink_port*’, as mentioned in the code snippet so far, or we will have to drop the
shaper cache and re-introduce aget()operation.The ops will try to fetch the
net_deviceor devlink according to the provided attributes.
At the moment the ops will error out with ENOTSUP for netlink object.
No need to error out. Driver must not receive calls with object types they don't support (we can add capabilities for this, later on, and core should check, or do what Jiri suggests and just hook the ops into different structs).
Quoted 9 lines
Most core helpers
will be re-factored to accept a 'binding *' argument in place of a 'structnet_device*'.Full netlink support (for the brave that will implement it later) will likely require at least an
additional scope (devlink_port), include thenet_shaper_opsandnet_shaper_datainside
struct devlink, and likely code adaptation inside the core.
Back to uAPI worries. FWIW I think that how we pass the handle to drivers is of relatively little importance. It's small amount of mechanical work to change it later. But you asked me about the proposal so I answered. To me representing the other shaper APIs in terms of the new driver facing API *within netdev* is more important.
Literally the only change I would have expected based on this branch of the conversation is slight adjustment to the parameters to ops. Nothing else. No netlink changes. Only core change would be to wrap the ops.
Paolo Abeni
maintainerRe: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 3 lines · Jakub Kicinski
Literally the only change I would have expected based on this branch of the conversation is slight adjustment to the parameters to ops. Nothing else. No netlink changes. Only core change would be to wrap the ops.
FTR, the above is quite the opposite of my understanding of the whole conversation so far. If the whole delta under discussion is just that, we could make such a change at any given time (and I would strongly support the idea to make it only when the devlink bits will be ready) and its presence (or absence) will not block the net_device/devlink shaper callback consolidation in any way.
I thought Jiri intended the whole core bits to be adapted to handle 'binding' instead of net_device, to allow a more seamless plug of devlink.
@Jiri: did I misread your words?
Thanks,
Paolo
Re: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 12 lines · Tue, Aug 27, 2024 at 11:54:48PM CEST, [email protected] wrote:
Quoted 3 lines · Jakub Kicinski
Literally the only change I would have expected based on this branch of the conversation is slight adjustment to the parameters to ops. Nothing else. No netlink changes. Only core change would be to wrap the ops.
FTR, the above is quite the opposite of my understanding of the whole conversation so far. If the whole delta under discussion is just that, we could make such a change at any given time (and I would strongly support the idea to make it only when the devlink bits will be ready) and its presence (or absence) will not block the net_device/devlink shaper callback consolidation in any way.
Quoted 4 lines
I thought Jiri intended the whole core bits to be adapted to handle 'binding' instead of
net_device, to allow a more seamless plug of devlink.
@Jiri: did I misread your words?
Yep that is correct. But you don't need the UAPI extension for that, as UAPI for devlink rate already exists.
Regarding your shaper UAPI. I think that you just need to make sure it is easily extendable by another binding in the future. The current ifindex binding is fine for your shaper UAPI. Just have it in nest and allow to extend by another attr later on.
Code speaks:
enum net_shaper_a_binding {
NET_SHAPER_A_BINDING_IFINDEX = 1;
};enum {
NET_SHAPER_A_BINDING = 1, /*nested enum net_shaper_a_binding*/
NET_SHAPER_A_.....
..................
..................
};Later on we can easily extend the UAPI by:
enum net_shaper_a_binding {
NET_SHAPER_A_BINDING_IFINDEX = 1;
NET_SHAPER_A_BINDING_DEVLINK_PORT;
}Makes sense?
Quoted 5 lines
Thanks,
Paolo
Paolo Abeni
maintainerRe: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 1 line · Jiri Pirko
Makes sense?
Almost! Tacking aside the (very significant) differences between your proposition and Jakub’s, we can't use devlink port here, just devlink, or we will have to drop the cache too[1]. Specific devlink port shapers will be reached via different handles (scope/id).
Additionally, I think we don't need strictly the ‘binding’ nested attribute to extend the NL API with different binding objects (devlink), we could append the new attributes needed to support (identify) devlink at the end of the net shaper attributes list. I agree that would be likely less ‘nice’.
What about:
- Refactor the core and the driver api to support the ‘binding’ thing
- Update the NL definition to nest the ‘ifindex’ attribute under the ‘binding’ one. No mention/reference to devlink yet, so most of the documentation will be unchanged.
- devlink support will not be included, but there should be enough ground paved for it.
?
Thanks,
Paolo
[1] the cache container belongs to the ‘entry point’ inside the shaper hierarchy - i.e. currently, the struct net_device. If we add a devlink_port ‘entry point’, the cache there will have to manage even the shaper for devlink ports group. When accessing a group containing multiple ports, we will get multiple inconsistent cache values.
Re: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 7 lines · Wed, Aug 28, 2024 at 12:55:31PM CEST, [email protected] wrote:
Quoted 1 line · Jiri Pirko
Makes sense?
Almost! Tacking aside the (very significant) differences between your proposition and Jakub’s, we can't use devlink port here, just devlink, or we will have to drop the cache too[1]. Specific devlink port shapers will be reached via different handles (scope/id).
Ok, I guess. Need to see the code.
Quoted 5 lines
Additionally, I think we don't need strictly the ‘binding’ nested attribute to extend the NL API with different binding objects (devlink), we could append the new attributes needed to support (identify) devlink at the end of the net shaper attributes list. I agree that would be likely less ‘nice’.
True and true.
Quoted 3 lines
What about:
- Refactor the core and the driver api to support the ‘binding’ thing
Ack.
Quoted 3 lines
- Update the NL definition to nest the ‘ifindex’ attribute under the ‘binding’ one. No mention/reference to devlink yet, so most of the documentation will be unchanged.
Ack.
Quoted 2 lines
- devlink support will not be included, but there should be enough ground paved for it.
Ack.
Quoted 2 lines
?
Thanks!
Quoted 11 lines
Thanks,
Paolo
[1] the cache container belongs to the ‘entry point’ inside the shaper hierarchy - i.e. currently, the struct
net_device. If we add adevlink_port‘entry point’, the cache there will have to manage even the shaper for devlink ports group. When accessing a group containing multiple ports, we will get multiple inconsistent cache values.
Jakub Kicinski
maintainerRe: [PATCH v3 03/12] net-shapers: implement NL get operation
In reply to Paolo AbeniQuoted 3 lines · On Wed, 28 Aug 2024 12:55:31 +0200 Paolo Abeni wrote:
- Update the NL definition to nest the ‘ifindex’ attribute under the ‘binding’ one. No mention/reference to devlink yet, so most of the documentation will be unchanged.
Sorry but I think that's a bad idea. Nesting attributes in netlink with no semantic implications, just to "organize" attributes which are somehow related just complicates the code and wastes space. Netlink is not JSON.
Especially in this case, where we would do it for future uAPI extension which I really hope we won't need, since (1) devlink already has one,
(2) the point of this API is to reduce the uAPI surface, not extend it,
(3) user requirements for devlink and netdev config are different.
Paolo Abeni
maintainerRe: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 10 lines · Jakub Kicinski
Quoted 3 lines · On Wed, 28 Aug 2024 12:55:31 +0200 Paolo Abeni wrote:
- Update the NL definition to nest the ‘ifindex’ attribute under the ‘binding’ one. No mention/reference to devlink yet, so most of the documentation will be unchanged.
Sorry but I think that's a bad idea. Nesting attributes in netlink with no semantic implications, just to "organize" attributes which are somehow related just complicates the code and wastes space. Netlink is not JSON.
Quoted 4 lines
Especially in this case, where we would do it for future uAPI extension which I really hope we won't need, since (1) devlink already has one,
(2) the point of this API is to reduce the uAPI surface, not extend it,
(3) user requirements for devlink and netdev config are different.
FTR I was no more than 60" from posting the new revision including that when I read that. I hope Jiri would agree...
Well, I guess I have to roll-back a lot of changes... Not sure if I'll be able to post tomorrow evening my time...
/P
Re: [PATCH v3 03/12] net-shapers: implement NL get operation
Quoted 13 lines · Wed, Aug 28, 2024 at 11:13:04PM CEST, [email protected] wrote:
Quoted 10 lines · Jakub Kicinski
Quoted 3 lines · On Wed, 28 Aug 2024 12:55:31 +0200 Paolo Abeni wrote:
- Update the NL definition to nest the ‘ifindex’ attribute under the ‘binding’ one. No mention/reference to devlink yet, so most of the documentation will be unchanged.
Sorry but I think that's a bad idea. Nesting attributes in netlink with no semantic implications, just to "organize" attributes which are somehow related just complicates the code and wastes space. Netlink is not JSON.
Quoted 7 lines
Quoted 4 lines
Especially in this case, where we would do it for future uAPI extension which I really hope we won't need, since (1) devlink already has one,
(2) the point of this API is to reduce the uAPI surface, not extend it,
(3) user requirements for devlink and netdev config are different.FTR I was no more than 60" from posting the new revision including that when I read that. I hope Jiri would agree...
Sure.
Quoted 7 lines
Well, I guess I have to roll-back a lot of changes... Not sure if I'll be able to post tomorrow evening my time...
/P
Jakub Kicinski
maintainerRe: [PATCH v3 03/12] net-shapers: implement NL get operation
In reply to Paolo Abeniinclude/net/net_shaper.h line 10
Quoted 5 lines · On Tue, 30 Jul 2024 22:39:46 +0200 Paolo Abeni wrote:
include/net/net_shaper.h new file +5
-0+#include <linux/types.h> +#include <linux/bits.h> +#include <linux/bitfield.h> +#include <linux/netdevice.h> +#include <linux/netlink.h>
most of these could be replaced by forward declaration of types
Quoted 38 lines
include/net/net_shaper.h new file +38
-0+#include <uapi/linux/net_shaper.h> + +/** +* struct net_shaper_info - represents a shaping node on the NIC H/W +* zeroed field are considered not set. +* @handle: Unique identifier for the shaper, see @net_shaper_make_handle +* @parent: Unique identifier for the shaper parent, usually implied. Only +* NET_SHAPER_SCOPE_QUEUE, NET_SHAPER_SCOPE_NETDEV and NET_SHAPER_SCOPE_DETACHED +* can have the parent handle explicitly set, placing such shaper under +* the specified parent. +* @metric: Specify if the bw limits refers to PPS or BPS +* @bw_min: Minimum guaranteed rate for this shaper +* @bw_max: Maximum peak bw allowed for this shaper +* @burst: Maximum burst for the peek rate of this shaper +* @priority: Scheduling priority for this shaper +* @weight: Scheduling weight for this shaper +* @children: Number of nested shapers, accounted only for DETACHED scope +*/ +struct net_shaper_info { +u32 handle; +u32 parent; +enum net_shaper_metric metric; +u64 bw_min; +u64 bw_max; +u64 burst; +u32 priority; +u32 weight; +u32 children; +}; + +/** +* define NET_SHAPER_SCOPE_VF - Shaper scope +* +* This shaper scope is not exposed to user-space; the shaper is attached to +* the given virtual function. +*/ +#define NET_SHAPER_SCOPE_VF __NET_SHAPER_SCOPE_MAX +
include/net/net_shaper.h line 59
Quoted 10 lines
include/net/net_shaper.h new file +10
-0+/** +* struct net_shaper_ops - Operations on device H/W shapers +* +* The initial shaping configuration ad device initialization is empty/ +* a no-op/does not constraint the b/w in any way. +* The network core keeps track of the applied user-configuration in +* per device storage. +* +* Each shaper is uniquely identified within the device with an 'handle', +* dependent on the shaper scope and other data, see @shaper_make_handle()
we need to document locking, seems like the locking is.. missing? Or at least I don't see what prevents two deletes from racing.
Quoted 20 lines
+ */
include/net/net_shaper.h new file +19
-0+struct net_shaper_ops { +/** +* @group: create the specified shapers group +* +* Nest the specified @inputs shapers under the given @output shaper +* on the network device @dev. The @input shaper array size is specified +* by @nr_input. +* Create either the @inputs and the @output shaper as needed, +* otherwise move them as needed. Can't create @inputs shapers with +* NET_SHAPER_SCOPE_DETACHED scope, a separate @group call with such +* shaper as @output is needed. +* +* Returns 0 on group successfully created, otherwise an negative +* error value and set @extack to describe the failure's reason. +*/ +int (*group)(struct net_device *dev,int nr_input, +const struct net_shaper_info *inputs, +const struct net_shaper_info *output, +struct netlink_ext_ack *extack);
include/net/net_shaper.h
Quoted 10 lines
include/net/net_shaper.h new file +9
-0+ +/* the default id for detached scope shapers is an invalid one +* to help the 'group' operation discriminate between new +* detached shaper creation (ID_UNSPEC) and reuse of existing +* shaper (any other value) +*/ + id_attr = tb[NET_SHAPER_A_ID ]; +if (id_attr) + id =nla_get_u32 (id_attr);
double space
Re: [PATCH v3 03/12] net-shapers: implement NL get operation
In reply to Paolo AbeniTue, Jul 30, 2024 at 10:39:46PM CEST, [email protected] wrote:
[...]
include/net/net_shaper.h line 24
Quoted 12 lines
include/net/net_shaper.h new file +12
-0+ +/** +* struct net_shaper_info - represents a shaping node on the NIC H/W +* zeroed field are considered not set. +* @handle: Unique identifier for the shaper, see @net_shaper_make_handle +* @parent: Unique identifier for the shaper parent, usually implied. Only +* NET_SHAPER_SCOPE_QUEUE, NET_SHAPER_SCOPE_NETDEV and NET_SHAPER_SCOPE_DETACHED +* can have the parent handle explicitly set, placing such shaper under +* the specified parent. +* @metric: Specify if the bw limits refers to PPS or BPS +* @bw_min: Minimum guaranteed rate for this shaper +* @bw_max: Maximum peak bw allowed for this shaper
"rate" to be consitent with the text one line above?
Quoted 4 lines
+ * @burst: Maximum burst for the peek rate of this shaper
+ * @priority: Scheduling priority for this shaper
+ * @weight: Scheduling weight for this shaper
+ * @children: Number of nested shapers, accounted only for DETACHED scope
"children" are "inputs"? Or "nested shapers". I'm lost in the terminology, again.
include/net/net_shaper.h line 31
Quoted 3 lines
+ */
include/net/net_shaper.h new file +2
-0+struct net_shaper_info { +u32 handle;
I wonder if the handle should be part of this structure. The structure describes the shaper attributes. The handle is identification. In the ops below, you sometimes pass the handle as a part of net_shaper_info structure (group, set), yet for delete op you pass handle directly. Wouldn't it be nicer to pass the same handle attr every time so it is clear what it is?
Quoted 7 lines
include/net/net_shaper.h new file +7
-0+u32 parent; +enum net_shaper_metric metric; +u64 bw_min; +u64 bw_max; +u64 burst; +u32 priority; +u32 weight;
include/net/net_shaper.h line 48
Quoted 10 lines
include/net/net_shaper.h new file +10
-0+u32 children; +}; + +/** +* define NET_SHAPER_SCOPE_VF - Shaper scope +* +* This shaper scope is not exposed to user-space; the shaper is attached to +* the given virtual function. +*/ +#define NET_SHAPER_SCOPE_VF __NET_SHAPER_SCOPE_MAX
This is unused, why do you introduce it here?
include/net/net_shaper.h line 53
Quoted 5 lines
include/net/net_shaper.h new file +5
-0+ +/** +* struct net_shaper_ops - Operations on device H/W shapers +* +* The initial shaping configuration ad device initialization is empty/
s/as/and ?
Quoted 1 line
+ * a no-op/does not constraint the b/w in any way.
"bw","b/w","rate". Better to be consistent, I suppose.
Quoted 2 lines
+ * The network core keeps track of the applied user-configuration in
+ * per device storage.
"per device storage" reads weird. "net_device structure"? IDK.
Quoted 3 lines
+ *
+ * Each shaper is uniquely identified within the device with an 'handle',
+ * dependent on the shaper scope and other data, see @shaper_make_handle()
The name of the function is net_shaper_make_handle(). You refer to "other data". What is that? I see no such thing in the code.
include/net/net_shaper.h
Quoted 10 lines
+ */
include/net/net_shaper.h new file +9
-0+struct net_shaper_ops { +/** +* @group: create the specified shapers group +* +* Nest the specified @inputs shapers under the given @output shaper +* on the network device @dev. The @input shaper array size is specified +* by @nr_input. +* Create either the @inputs and the @output shaper as needed, +* otherwise move them as needed.
I don't understand the sentense. So this creates either passed inputs and output shaper, or if they already exist, it links them together in desired way? Or what do you mean by "move"?
include/net/net_shaper.h line 71
Quoted 3 lines
include/net/net_shaper.h new file +3
-0+ Can't create @inputs shapers with + * NET_SHAPER_SCOPE_DETACHED scope, a separate @group call with such + * shaper as @output is needed.
I don't understand meaning of the sentence. The caller should make sure that NET_SHAPER_SCOPE_DETACHED is not in the inputs, so drivers do not have to sanitize it one by one. Then this sentence is not needed here, is it?
include/net/net_shaper.h line 76
Quoted 5 lines
include/net/net_shaper.h new file +5
-0+* +* Returns 0 on group successfully created, otherwise an negative +* error value and set @extack to describe the failure's reason. +*/ + int (*group)(struct net_device *dev, int nr_input,
Perhaps better name would be "nr_inputs" or "inputs_count"?
include/net/net_shaper.h line 86
Quoted 10 lines
include/net/net_shaper.h new file +10
-0+const struct net_shaper_info *inputs, + const struct net_shaper_info *output, + struct netlink_ext_ack *extack); + +/** +* @set: Updates the specified shaper +* +* Updates or creates the specified @shaper on the given device +* @dev. Can't create NET_SHAPER_SCOPE_DETACHED shapers, use @group +* instead.
Again, similar to the NET_SHAPER_SCOPE_DETACHED comment above, the caller should sanitize this. Why is this needed here then?
Review
Quoted 2 lines
(quoted diff) +2
-0+ * + * Returns 0 on group successfully created, otherwise an negative
Which group? C&P mistake I suppose?
include/net/net_shaper.h line 101
Quoted 13 lines
include/net/net_shaper.h new file +13
-0+* error value and set @extack to describe the failure's reason. +*/ +int (*set)(struct net_device *dev, +const struct net_shaper_info *shaper, +struct netlink_ext_ack *extack); + +/** +* @delete: Removes the specified shaper from the NIC +* +* Removes the shaper configuration as identified by the given @handle +* on the specified device @dev, restoring the default behavior. +* +* Returns 0 on group successfully created, otherwise an negative
Which group? C&P mistake I suppose?
Quoted 17 lines
include/net/net_shaper.h new file +17
-0+* error value and set @extack to describe the failure's reason. +*/ +int (*delete)(struct net_device *dev,u32 handle, +struct netlink_ext_ack *extack); +}; + +#define NET_SHAPER_SCOPE_SHIFT 26 +#define NET_SHAPER_ID_MASK GENMASK(NET_SHAPER_SCOPE_SHIFT - 1, 0) +#define NET_SHAPER_SCOPE_MASK GENMASK(31, NET_SHAPER_SCOPE_SHIFT) + +#define NET_SHAPER_ID_UNSPEC NET_SHAPER_ID_MASK + +/** +* net_shaper_make_handle - creates an unique shaper identifier +* @scope: the shaper scope +* @id: the shaper id number +*
include/net/net_shaper.h line 128
Quoted 10 lines
include/net/net_shaper.h new file +10
-0+* Return: an unique identifier for the shaper +* +* Combines the specified arguments to create an unique identifier for +* the shaper. The @id argument semantic depends on the +* specified scope. +* For @NET_SHAPER_SCOPE_QUEUE_GROUP, @id is the queue group id +* For @NET_SHAPER_SCOPE_QUEUE, @id is the queue number. +* For @NET_SHAPER_SCOPE_VF, @id is virtual function number. +*/ +static inline u32 net_shaper_make_handle(enum net_shaper_scope scope,
Why is this in the header? It is used only in shaper.c. Should be private to it.
Quoted 14 lines
include/net/net_shaper.h new file +14
-0+ int id) +{ +return FIELD_PREP (NET_SHAPER_SCOPE_MASK , scope) | +FIELD_PREP (NET_SHAPER_ID_MASK , id); +} + +/** +* net_shaper_handle_scope - extract the scope from the given handle +* @handle: the shaper handle +* +* Return: the corresponding scope +*/ +static inline enum net_shaper_scope net_shaper_handle_scope (u32 handle) +{
include/net/net_shaper.h line 152
Quoted 10 lines
include/net/net_shaper.h new file +10
-0+return FIELD_GET (NET_SHAPER_SCOPE_MASK , handle); +} + +/** +* net_shaper_handle_id - extract the id number from the given handle +* @handle: the shaper handle +* +* Return: the corresponding id number +*/ +static inline int net_shaper_handle_id (u32 handle)
I undertand that you use the handle for uapi and xaarray index purposes as consolidated u32. But, for the driver ops, would it be better to pass scope and id trough the ops to drivers? Driver then don't need to call these helpers and they can all stay private to shaper.c
Quoted 6 lines
include/net/net_shaper.h new file +6
-0+{ +return FIELD_GET (NET_SHAPER_ID_MASK , handle); +} + +#endif +
[...]
Paolo Abeni
maintainerPATCH v3 4/12 net-shapers: implement NL set and delete operations
In reply to Paolo AbeniBoth NL operations directly map on the homonymous device shaper callbacks and update accordingly the shapers cache. Implement the cache modification helpers to additionally deal with DETACHED scope shaper. That will be needed by the group() operation implemented in the next patch.
---
RFC v2 -> RFC v3:
- dev_put() -> netdev_put()
--- net/shaper/shaper.c | 324 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 322 insertions(+), 2 deletions(-)
net/shaper/shaper.c +322 -2
@@ -19,6 +19,35 @@ struct net_shaper_nl_ctx {u32 start_handle; }; +static u32 default_parent (u32 handle) +{ +enum net_shaper_scope parent, scope =net_shaper_handle_scope (handle); + +switch (scope) { +case NET_SHAPER_SCOPE_PORT : +case NET_SHAPER_SCOPE_UNSPEC : + parent =NET_SHAPER_SCOPE_UNSPEC ; +break ; + +case NET_SHAPER_SCOPE_QUEUE : +case NET_SHAPER_SCOPE_DETACHED : + parent =NET_SHAPER_SCOPE_NETDEV ; +break ; + +case NET_SHAPER_SCOPE_NETDEV : +case NET_SHAPER_SCOPE_VF : + parent =NET_SHAPER_SCOPE_PORT ; +break ; + } + +return net_shaper_make_handle (parent,0 ); +} + +static bool is_detached (u32 handle) +{ +return net_shaper_handle_scope (handle) ==NET_SHAPER_SCOPE_DETACHED ; +} +static int fill_handle (struct sk_buff *msg,u32 handle,u32 type,const struct genl_info *info) {
@@ -117,6 +146,115 @@ static struct net_shaper_info *sc_lookup(struct net_device *dev, u32 handle)return xa ?xa_load (xa, handle) :NULL ; } +/* allocate on demand the per device shaper's cache */ +static struct xarray *__sc_init (struct net_device *dev, +struct netlink_ext_ack *extack) +{ +if (!dev->net_shaper_data) { + dev->net_shaper_data =kmalloc (sizeof (*dev->net_shaper_data), +GFP_KERNEL ); +if (!dev->net_shaper_data) { +NL_SET_ERR_MSG (extack,"Can't allocate memory for shaper data" ); +return NULL ; + } + +xa_init (&dev->net_shaper_data->shapers); +idr_init (&dev->net_shaper_data->detached_ids); + } +return &dev->net_shaper_data->shapers; +} + +/* prepare the cache to actually insert the given shaper, doing +* in advance the needed allocations +*/ +static int sc_prepare_insert (struct net_device *dev,u32 *handle, +struct netlink_ext_ack *extack) +{ +enum net_shaper_scope scope =net_shaper_handle_scope (*handle); +struct xarray *xa =__sc_init (dev, extack); +struct net_shaper_info *prev, *cur; +bool id_allocated = false; +int ret, id; + +if (!xa) +return -ENOMEM ; + + cur =xa_load (xa, *handle); +if (cur) +return 0 ; + +/* allocated a new id, if needed */ +if (scope ==NET_SHAPER_SCOPE_DETACHED && +net_shaper_handle_id (*handle) ==NET_SHAPER_ID_UNSPEC ) { +xa_lock (xa); + id =idr_alloc (&dev->net_shaper_data->detached_ids,NULL , +0 ,NET_SHAPER_ID_UNSPEC ,GFP_ATOMIC ); +xa_unlock (xa); + +if (id <0 ) { +NL_SET_ERR_MSG (extack,"Can't allocate new id for detached shaper" ); +return id; + } + + *handle =net_shaper_make_handle (scope, id); + id_allocated = true; + } + + cur =kmalloc (sizeof (*cur),GFP_KERNEL | __GFP_ZERO); +if (!cur) { +NL_SET_ERR_MSG (extack,"Can't allocate memory for cached shaper" ); + ret = -ENOMEM ; + goto free_id; + } + +/* mark 'tentative' shaper inside the cache */ +xa_lock (xa); + prev =__xa_store (xa, *handle, cur,GFP_KERNEL ); +__xa_set_mark (xa, *handle,XA_MARK_0 ); +xa_unlock (xa); +if (xa_err (prev)) { +NL_SET_ERR_MSG (extack,"Can't insert shaper into cache" ); +kfree (cur); + ret =xa_err (prev); + goto free_id; + } +return 0 ; + +free_id: +if (id_allocated) { +xa_lock (xa); +idr_remove (&dev->net_shaper_data->detached_ids, +net_shaper_handle_id (*handle)); +xa_unlock (xa); + } +return ret; +} + +/* commit the tentative insert with the actual values. +* Must be called only after a successful sc_prepare_insert() +*/ +static void sc_commit (struct net_device *dev,int nr_shapers, +const struct net_shaper_info *shapers) +{ +struct xarray *xa =__sc_container (dev); +struct net_shaper_info *cur; +int i; + +xa_lock (xa); +for (i =0 ; i < nr_shapers; ++i) { + cur =xa_load (xa, shapers[i].handle); +if (WARN_ON_ONCE (!cur)) +continue ; + +/* successful update: drop the tentative mark +* and update the cache +*/ +__xa_clear_mark (xa, shapers[i].handle,XA_MARK_0 ); + *cur = shapers[i]; + } +xa_unlock (xa); +} +static int parse_handle (const struct nlattr *attr,const struct genl_info *info,u32 *handle) {
@@ -154,6 +292,68 @@ static int parse_handle(const struct nlattr *attr, const struct genl_info *info,return 0 ; } +static int __parse_shaper (struct net_device *dev,struct nlattr **tb, +const struct genl_info *info, +struct net_shaper_info *shaper) +{ +struct net_shaper_info *old; +int ret; + +/* the shaper handle is the only mandatory attribute */ +if (NL_REQ_ATTR_CHECK (info->extack,NULL , tb,NET_SHAPER_A_HANDLE )) +return -EINVAL ; + + ret =parse_handle (tb[NET_SHAPER_A_HANDLE ], info, &shaper->handle); +if (ret) +return ret; + +/* fetch existing data, if any, so that user provide info will +* incrementally update the existing shaper configuration +*/ + old =sc_lookup (dev, shaper->handle); +if (old) + *shaper = *old; +else + shaper->parent =default_parent (shaper->handle); + +if (tb[NET_SHAPER_A_METRIC ]) + shaper->metric =nla_get_u32 (tb[NET_SHAPER_A_METRIC ]); + +if (tb[NET_SHAPER_A_BW_MIN ]) + shaper->bw_min =nla_get_uint (tb[NET_SHAPER_A_BW_MIN ]); + +if (tb[NET_SHAPER_A_BW_MAX ]) + shaper->bw_max =nla_get_uint (tb[NET_SHAPER_A_BW_MAX ]); + +if (tb[NET_SHAPER_A_BURST ]) + shaper->burst =nla_get_uint (tb[NET_SHAPER_A_BURST ]); + +if (tb[NET_SHAPER_A_PRIORITY ]) + shaper->priority =nla_get_u32 (tb[NET_SHAPER_A_PRIORITY ]); + +if (tb[NET_SHAPER_A_WEIGHT ]) + shaper->weight =nla_get_u32 (tb[NET_SHAPER_A_WEIGHT ]); +return 0 ; +} + +/* fetch the cached shaper info and update them with the user-provided +* attributes +*/ +static int parse_shaper (struct net_device *dev,const struct nlattr *attr, +const struct genl_info *info, +struct net_shaper_info *shaper) +{ +struct nlattr *tb[NET_SHAPER_A_WEIGHT +1 ]; +int ret; + + ret =nla_parse_nested (tb,NET_SHAPER_A_WEIGHT , attr, + net_shaper_ns_info_nl_policy, info->extack); +if (ret <0 ) +return ret; + +return __parse_shaper (dev, tb, info, shaper); +} +int net_shaper_nl_get_doit (struct sk_buff *skb,struct genl_info *info) {struct net_shaper_info *shaper;
@@ -239,14 +439,134 @@ int net_shaper_nl_get_dumpit(struct sk_buff *skb,return ret; } +/* Update the H/W and on success update the local cache, too */ +static int net_shaper_set (struct net_device *dev, +const struct net_shaper_info *shaper, +struct netlink_ext_ack *extack) +{ +enum net_shaper_scope scope; +u32 handle = shaper->handle; +int ret; + + scope =net_shaper_handle_scope (handle); +if (scope ==NET_SHAPER_SCOPE_PORT || + scope ==NET_SHAPER_SCOPE_UNSPEC ) { +NL_SET_ERR_MSG_FMT (extack,"Can't set shaper %x with scope %d" , + handle, scope); +return -EINVAL ; + } +if (scope ==NET_SHAPER_SCOPE_DETACHED && !sc_lookup (dev, handle)) { +NL_SET_ERR_MSG_FMT (extack,"Shaper %x with detached scope does not exist" , + handle); +return -EINVAL ; + } + + ret =sc_prepare_insert (dev, &handle, extack); +if (ret) +return ret; + + ret = dev->netdev_ops->net_shaper_ops->set (dev, shaper, extack); +sc_commit (dev,1 , shaper); +return ret; +} +int net_shaper_nl_set_doit (struct sk_buff *skb,struct genl_info *info) { -return -EOPNOTSUPP ; +struct net_shaper_info shaper; +struct net_device *dev; +struct nlattr *attr; +int ret; + +if (GENL_REQ_ATTR_CHECK (info,NET_SHAPER_A_SHAPER )) +return -EINVAL ; + + ret =fetch_dev (info, &dev); +if (ret) +return ret; + + attr = info->attrs[NET_SHAPER_A_SHAPER ]; + ret =parse_shaper (dev, attr, info, &shaper); +if (ret) + goto put; + + ret =net_shaper_set (dev, &shaper, info->extack); + +put: +netdev_put (dev,NULL ); +return ret; +} + +static int net_shaper_delete (struct net_device *dev,u32 handle, +struct netlink_ext_ack *extack) +{ +struct net_shaper_info *parent, *shaper =sc_lookup (dev, handle); +struct xarray *xa =__sc_container (dev); +enum net_shaper_scope pscope; +u32 parent_handle; +int ret; + +if (!xa || !shaper) { +NL_SET_ERR_MSG_FMT (extack,"Shaper %x not found" , handle); +return -EINVAL ; + } + +if (is_detached (handle) && shaper->children >0 ) { +NL_SET_ERR_MSG_FMT (extack,"Can't delete detached shaper %d with %d child nodes" , + handle, shaper->children); +return -EINVAL ; + } + +while (shaper) { + parent_handle = shaper->parent; + pscope =net_shaper_handle_scope (parent_handle); + + ret = dev->netdev_ops->net_shaper_ops->delete (dev, handle, + extack); +if (ret <0 ) +return ret; + +xa_lock (xa); +__xa_erase (xa, handle); +if (is_detached (handle)) +idr_remove (&dev->net_shaper_data->detached_ids, +net_shaper_handle_id (handle)); +xa_unlock (xa); +kfree (shaper); + shaper =NULL ; + +if (pscope ==NET_SHAPER_SCOPE_DETACHED ) { + parent =sc_lookup (dev, parent_handle); +if (parent && !--parent->children) { + shaper = parent; + handle = parent_handle; + } + } + } +return 0 ; }int net_shaper_nl_delete_doit (struct sk_buff *skb,struct genl_info *info) { -return -EOPNOTSUPP ; +struct net_device *dev; +u32 handle; +int ret; + +if (GENL_REQ_ATTR_CHECK (info,NET_SHAPER_A_HANDLE )) +return -EINVAL ; + + ret =fetch_dev (info, &dev); +if (ret) +return ret; + + ret =parse_handle (info->attrs[NET_SHAPER_A_HANDLE ], info, &handle); +if (ret) + goto put; + + ret =net_shaper_delete (dev, handle, info->extack); + +put: +netdev_put (dev,NULL ); +return ret; }int net_shaper_nl_group_doit (struct sk_buff *skb,struct genl_info *info)
Signature · 1 line
2.45.2
Jakub Kicinski
maintainerRe: [PATCH v3 04/12] net-shapers: implement NL set and delete operations
net/shaper/shaper.c int net_shaper_nl_get_dumpit(struct sk_buff *skb, · line 509
Quoted 11 lines · On Tue, 30 Jul 2024 22:39:47 +0200 Paolo Abeni wrote:
net/shaper/shaper.c +11
-0+static int net_shaper_delete (struct net_device *dev,u32 handle, +struct netlink_ext_ack *extack) +{ +struct net_shaper_info *parent, *shaper =sc_lookup (dev, handle); +struct xarray *xa =__sc_container (dev); +enum net_shaper_scope pscope; +u32 parent_handle; +int ret; + +if (!xa || !shaper) { +NL_SET_ERR_MSG_FMT (extack,"Shaper %x not found" , handle);
below the print format for shaper id is %d
also just point at the attribute with NL_SET_BAD_ATTR(), we shouldn't bloat the kernel with strings for trivial errors
Review
Quoted 1 line
(quoted diff) +1
-0+ return -EINVAL;
ENOENT
net/shaper/shaper.c int net_shaper_nl_get_dumpit(struct sk_buff *skb, · line 516
Quoted 6 lines
net/shaper/shaper.c +6
-0+ } + +if (is_detached (handle) && shaper->children >0 ) { +NL_SET_ERR_MSG_FMT (extack,"Can't delete detached shaper %d with %d child nodes" , + handle, shaper->children); +return -EINVAL ;
I'd say EBUSY
Quoted 9 lines
net/shaper/shaper.c +9
-0+ } + +while (shaper) { + parent_handle = shaper->parent; + pscope =net_shaper_handle_scope (parent_handle); + + ret = dev->netdev_ops->net_shaper_ops->delete (dev, handle, + extack); +if (ret <0 )
net/shaper/shaper.c int net_shaper_nl_get_dumpit(struct sk_buff *skb, · line 535
Quoted 10 lines
net/shaper/shaper.c +10
-0+return ret; + +xa_lock (xa); +__xa_erase (xa, handle); +if (is_detached (handle)) +idr_remove (&dev->net_shaper_data->detached_ids, +net_shaper_handle_id (handle)); +xa_unlock (xa); +kfree (shaper); + shaper =NULL ;
IIUC child is the input / ingress node? (The parentage terminology is a bit ambiguous in this case, although I must admit I keep catching myself trying to use it, too).
Does "deleting a queue" return it to the "implicit mux" at the global level? If we look at the delegation use case - when queue is "deleted" from a container-controlled mux it should go back to the group created by the orchestrator, not "escpate" to global scope, right?
Quoted 14 lines
net/shaper/shaper.c +9
-1+if (pscope ==NET_SHAPER_SCOPE_DETACHED ) { + parent =sc_lookup (dev, parent_handle); +if (parent && !--parent->children) { + shaper = parent; + handle = parent_handle; + } + } + } +return 0 ; }int net_shaper_nl_delete_doit (struct sk_buff *skb,struct genl_info *info) { -return -EOPNOTSUPP ;
net/shaper/shaper.c int net_shaper_nl_get_dumpit(struct sk_buff *skb, · line 559
Quoted 10 lines
net/shaper/shaper.c +10
-0+struct net_device *dev; +u32 handle; +int ret; + +if (GENL_REQ_ATTR_CHECK (info,NET_SHAPER_A_HANDLE )) +return -EINVAL ; + + ret =fetch_dev (info, &dev); +if (ret) +return ret;
Possibly a candidate for a "pre" handler, since multiple ops call it?
Paolo Abeni
maintainerRe: [PATCH v3 04/12] net-shapers: implement NL set and delete operations
Quoted 12 lines · Jakub Kicinski
Quoted 11 lines · On Tue, 30 Jul 2024 22:39:47 +0200 Paolo Abeni wrote:
net/shaper/shaper.c +11
-0+while (shaper) { + parent_handle = shaper->parent; + pscope =net_shaper_handle_scope (parent_handle); + + ret = dev->netdev_ops->net_shaper_ops->delete (dev, handle, + extack); +if (ret <0 ) +return ret; + +xa_lock (xa); +__xa_erase (xa, handle);
Quoted 8 lines
net/shaper/shaper.c int net_shaper_nl_get_dumpit(struct sk_buff *skb, · line 535
Quoted 6 lines
net/shaper/shaper.c +6
-0+if (is_detached (handle)) +idr_remove (&dev->net_shaper_data->detached_ids, +net_shaper_handle_id (handle)); +xa_unlock (xa); +kfree (shaper); + shaper =NULL ;IIUC child is the input / ingress node?
Yes.
Quoted 2 lines
Does "deleting a queue" return it to the "implicit mux" at the global level?
Yes
Quoted 4 lines
If we look at the delegation use case - when queue
is "deleted" from a container-controlled mux it should go back to the group created by the orchestrator, not "escpate" to global scope, right?
When deleting a queue-level shaper, the orchestrator is "returning" the ownership of the queue from the container to the host. If the container wants to move the queue around e.g. from:
q1 ----- \
q2 - \SP1/ RR1
q3 - / \
q4 - \ RR2 -> RR(root)
q5 - / /
q6 - \ RR3
q7 - /to:
q1 ----- \
q2 ----- RR1
q3 ---- / \
q4 - \ RR2 -> RR(root)
q5 - / /
q6 - \ RR3
q7 - /It can do it with a group() operation:
group(inputs:[q2,q3],output:[RR1])
That will implicitly also delete SP1.
Side note, I just noticed that the current code is bugged WRT this last operation and will not delete SP1.
Cheers,
Paolo
Jakub Kicinski
maintainerRe: [PATCH v3 04/12] net-shapers: implement NL set and delete operations
Quoted 22 lines · On Thu, 1 Aug 2024 17:25:50 +0200 Paolo Abeni wrote:
When deleting a queue-level shaper, the orchestrator is "returning" the ownership of the queue from the container to the host. If the container wants to move the queue around e.g. from:
q1 ----- \
q2 - \SP1/ RR1q3 - / \ q4 - \ RR2 -> RR(root) q5 - / / q6 - \ RR3 q7 - /to:
q1 ----- \
q2 ----- RR1q3 ---- / \ q4 - \ RR2 -> RR(root) q5 - / / q6 - \ RR3 q7 - /
Quoted 3 lines
It can do it with a
group()operation:
group(inputs:[q2,q3],output:[RR1])
Isn't that a bit odd? The container was not supposed to know / care about RR1's existence. We achieve this with group() by implicitly inheriting the egress node if all grouped entities shared one.
Delete IMO should act here like a "ungroup" operation, meaning that:
1) we're deleting SP1, not q1, q2
2) inputs go "downstream" instead getting ejected into global level
Also, in the first example from the cover letter we "set" a shaper on the queue, it feels a little ambiguous whether "delete queue" is purely clearing such per-queue shaping, or also has implications for the hierarchy.
Coincidentally, others may disagree, but I'd point to tests in patch 8 for examples of how the thing works, instead the cover letter samples.
Quoted 1 line
That will implicitly also delete SP1.
Re: [PATCH v3 04/12] net-shapers: implement NL set and delete operations
Quoted 3 lines · Thu, Aug 01, 2024 at 05:39:24PM CEST, [email protected] wrote:
Quoted 2 lines · On Thu, 1 Aug 2024 17:25:50 +0200 Paolo Abeni wrote:
When deleting a queue-level shaper, the orchestrator is "returning" the ownership of the queue from the container to the host. If the container
What do you meam by "orchestrator" and "container" here? I'm missing these from the picture.
Quoted 4 lines
Quoted 4 lines
wants to move the queue around e.g. from:
q1 ----- \
q2 - \SP1/ RR1
What "sp" and "rr" stand for. What are the "scopes" of these?
Quoted 18 lines
Quoted 18 lines
q3 - / \ q4 - \ RR2 -> RR(root) q5 - / / q6 - \ RR3 q7 - /to:
q1 ----- \
q2 ----- RR1q3 ---- / \ q4 - \ RR2 -> RR(root) q5 - / / q6 - \ RR3 q7 - /It can do it with a
group()operation:
Quoted 8 lines
Quoted 1 line
group(inputs:[q2,q3],output:[RR1])Isn't that a bit odd? The container was not supposed to know / care about RR1's existence. We achieve this with
group()by implicitly inheriting the egress node if all grouped entities shared one.Delete IMO should act here like a "ungroup" operation, meaning that:
1) we're deleting SP1, not q1, q2
Does current code support removing SP1? I mean, if the scope is detached, I don't think so.
Quoted 9 lines
2) inputs go "downstream" instead getting ejected into global level
Also, in the first example from the cover letter we "set" a shaper on the queue, it feels a little ambiguous whether "delete queue" is purely clearing such per-queue shaping, or also has implications for the hierarchy.
Coincidentally, others may disagree, but I'd point to tests in patch 8 for examples of how the thing works, instead the cover letter samples.
Examples in cover letter are generally beneficial. Don't remove them :)
Quoted 2 lines
Quoted 2 lines
That will implicitly also delete SP1.
Jakub Kicinski
maintainerRe: [PATCH v3 04/12] net-shapers: implement NL set and delete operations
Quoted 7 lines · On Fri, 2 Aug 2024 18:15:32 +0200 Jiri Pirko wrote:
Quoted 3 lines · Thu, Aug 01, 2024 at 05:39:24PM CEST, [email protected] wrote:
Quoted 2 lines · On Thu, 1 Aug 2024 17:25:50 +0200 Paolo Abeni wrote:
When deleting a queue-level shaper, the orchestrator is "returning" the ownership of the queue from the container to the host. If the container
What do you meam by "orchestrator" and "container" here? I'm missing these from the picture.
Container (as in docker) and orchestrator.
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
wants to move the queue around e.g. from:
q1 ----- \
q2 - \SP1/ RR1What "sp" and "rr" stand for. What are the "scopes" of these?
"scopes" I agree are confusing, but:
sp = strict priority
rr = round robin
Quoted 24 lines
Quoted 24 lines
Quoted 16 lines
q3 - / \ q4 - \ RR2 -> RR(root) q5 - / / q6 - \ RR3 q7 - /to:
q1 ----- \
q2 ----- RR1q3 ---- / \ q4 - \ RR2 -> RR(root) q5 - / / q6 - \ RR3 q7 - /Quoted 3 lines
It can do it with a
group()operation:
group(inputs:[q2,q3],output:[RR1])Isn't that a bit odd? The container was not supposed to know / care about RR1's existence. We achieve this with
group()by implicitly inheriting the egress node if all grouped entities shared one.
Quoted 5 lines
Quoted 2 lines
Delete IMO should act here like a "ungroup" operation, meaning that:
1) we're deleting SP1, not q1, q2Does current code support removing SP1? I mean, if the scope is detached, I don't think so.
that's my reading too, fwiw
Quoted 11 lines
Quoted 9 lines
2) inputs go "downstream" instead getting ejected into global level
Also, in the first example from the cover letter we "set" a shaper on the queue, it feels a little ambiguous whether "delete queue" is purely clearing such per-queue shaping, or also has implications for the hierarchy.
Coincidentally, others may disagree, but I'd point to tests in patch 8 for examples of how the thing works, instead the cover letter samples.
Examples in cover letter are generally beneficial. Don't remove them :)
They are beneficial, but if I was to order the following three forms of documentation by priority:
- ReST under Documentation/
- clear selftests with comments
- cover letter
I'm uncertain which will be first, but cover letter is definitely last :(
With the examples in the cover letter its unclear what the expected start and end state are. And where the values come from. I feel like selftest would make it clearer.
But I don't feel strongly. Such newfangled ideas will take a while to take root :)
Paolo Abeni
maintainerRe: [PATCH v3 04/12] net-shapers: implement NL set and delete operations
In reply to Jiri PirkoQuoted 9 lines · Jiri Pirko
Quoted 3 lines · Thu, Aug 01, 2024 at 05:39:24PM CEST, [email protected] wrote:
Quoted 2 lines · On Thu, 1 Aug 2024 17:25:50 +0200 Paolo Abeni wrote:
When deleting a queue-level shaper, the orchestrator is "returning" the ownership of the queue from the container to the host. If the container
What do you meam by "orchestrator" and "container" here? I'm missing these from the picture.
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
wants to move the queue around e.g. from:
q1 ----- \
q2 - \SP1/ RR1What "sp" and "rr" stand for. What are the "scopes" of these?
The scope is 'detached'
Quoted 24 lines
Quoted 24 lines
Quoted 16 lines
q3 - / \ q4 - \ RR2 -> RR(root) q5 - / / q6 - \ RR3 q7 - /to:
q1 ----- \
q2 ----- RR1q3 ---- / \ q4 - \ RR2 -> RR(root) q5 - / / q6 - \ RR3 q7 - /Quoted 3 lines
It can do it with a
group()operation:
group(inputs:[q2,q3],output:[RR1])Isn't that a bit odd? The container was not supposed to know / care about RR1's existence. We achieve this with
group()by implicitly inheriting the egress node if all grouped entities shared one.
Quoted 5 lines
Quoted 2 lines
Delete IMO should act here like a "ungroup" operation, meaning that:
1) we're deleting SP1, not q1, q2Does current code support removing SP1? I mean, if the scope is detached, I don't think so.
The current code explicitly prevents the above. We can change such behavior, if there is agreement.
My understanding is that Donald is against such option.
Quoted 11 lines
Quoted 9 lines
2) inputs go "downstream" instead getting ejected into global level
Also, in the first example from the cover letter we "set" a shaper on the queue, it feels a little ambiguous whether "delete queue" is purely clearing such per-queue shaping, or also has implications for the hierarchy.
Coincidentally, others may disagree, but I'd point to tests in patch 8 for examples of how the thing works, instead the cover letter samples.
Examples in cover letter are generally beneficial. Don't remove them :)
No problem to keep both examples and self-tests.
Thanks,
Paolo
Paolo Abeni
maintainerPATCH v3 5/12 net-shapers: implement NL group operation
In reply to Paolo AbeniAllow grouping multiple inputs shaper under the given output's one.
Try hard to pre-allocated the needed resources, to avoid non trivial H/W configuration rollbacks in case of any failure.
---
RFC v2 -> RFC v3:
- dev_put() -> netdev_put()
--- net/shaper/shaper.c | 265 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 264 insertions(+), 1 deletion(-)
net/shaper/shaper.c +264 -1
@@ -48,6 +48,18 @@ static bool is_detached(u32 handle)return net_shaper_handle_scope (handle) ==NET_SHAPER_SCOPE_DETACHED ; } +/* count the number of [multi] attributes of the given type */ +static int attr_list_len (struct genl_info *info,int type) +{ +struct nlattr *attr; +int rem, cnt =0 ; + +nla_for_each_attr_type (attr, type,genlmsg_data (info->genlhdr), +genlmsg_len (info->genlhdr), rem) + cnt++; +return cnt; +} +static int fill_handle (struct sk_buff *msg,u32 handle,u32 type,const struct genl_info *info) {
@@ -255,6 +267,27 @@ static void sc_commit(struct net_device *dev, int nr_shapers,xa_unlock (xa); } +/* rollback all the tentative inserts from the shaper cache */ +static void sc_rollback (struct net_device *dev) +{ +struct xarray *xa =__sc_container (dev); +struct net_shaper_info *cur; +unsigned long index; + +if (!xa) +return ; + +xa_lock (xa); +xa_for_each_marked (xa, index, cur,XA_MARK_0 ) { +if (is_detached (index)) +idr_remove (&dev->net_shaper_data->detached_ids, +net_shaper_handle_id (index)); +__xa_erase (xa, index); +kfree (cur); + } +xa_unlock (xa); +} +static int parse_handle (const struct nlattr *attr,const struct genl_info *info,u32 *handle) {
@@ -354,6 +387,36 @@ static int parse_shaper(struct net_device *dev, const struct nlattr *attr,return __parse_shaper (dev, tb, info, shaper); } +/* alike parse_shaper(), but additionally allow the user specifying +* the shaper's parent handle +*/ +static int parse_output_shaper (struct net_device *dev, +const struct nlattr *attr, +const struct genl_info *info, +struct net_shaper_info *shaper) +{ +struct nlattr *tb[NET_SHAPER_A_PARENT +1 ]; +int ret; + + ret =nla_parse_nested (tb,NET_SHAPER_A_PARENT , attr, + net_shaper_ns_output_info_nl_policy, + info->extack); +if (ret <0 ) +return ret; + + ret =__parse_shaper (dev, tb, info, shaper); +if (ret) +return ret; + +if (tb[NET_SHAPER_A_PARENT ]) { + ret =parse_handle (tb[NET_SHAPER_A_PARENT ], info, + &shaper->parent); +if (ret) +return ret; + } +return 0 ; +} +int net_shaper_nl_get_doit (struct sk_buff *skb,struct genl_info *info) {struct net_shaper_info *shaper;
@@ -569,9 +632,209 @@ int net_shaper_nl_delete_doit(struct sk_buff *skb, struct genl_info *info)return ret; } +/* Update the H/W and on success update the local cache, too */ +static int net_shaper_group (struct net_device *dev,int nr_inputs, +struct net_shaper_info *inputs, +struct net_shaper_info *output, +struct netlink_ext_ack *extack) +{ +enum net_shaper_scope scope, output_scope, output_pscope; +struct net_shaper_info *parent =NULL ; +int i, ret; + + output_scope =net_shaper_handle_scope (output->handle); +if (output_scope !=NET_SHAPER_SCOPE_DETACHED && + output_scope !=NET_SHAPER_SCOPE_NETDEV ) { +NL_SET_ERR_MSG_FMT (extack,"Invalid scope %d for output shaper %x" , + output_scope, output->handle); +return -EINVAL ; + } + + output_pscope =net_shaper_handle_scope (output->parent); +if (output_scope ==NET_SHAPER_SCOPE_DETACHED ) { +if (net_shaper_handle_id (output->handle) != +NET_SHAPER_ID_UNSPEC && !sc_lookup (dev, output->handle)) { +NL_SET_ERR_MSG_FMT (extack,"Output shaper %x does not exists" , + output->handle); +return -EINVAL ; + } +if (output_pscope !=NET_SHAPER_SCOPE_DETACHED && + output_pscope !=NET_SHAPER_SCOPE_NETDEV ) { +NL_SET_ERR_MSG_FMT (extack,"Invalid scope %d for output parent shaper %x" , + output_pscope, output->parent); +return -EINVAL ; + } + } + +if (output_pscope ==NET_SHAPER_SCOPE_DETACHED ) { + parent =sc_lookup (dev, output->parent); +if (!parent) { +NL_SET_ERR_MSG_FMT (extack,"Output parent shaper %x does not exists" , + output->parent); +return -EINVAL ; + } + } + +/* for newly created detached scope shaper, the following will update +* the handle, due to id allocation +*/ + ret =sc_prepare_insert (dev, &output->handle, extack); +if (ret) + goto rollback; + +for (i =0 ; i < nr_inputs; ++i) { + scope =net_shaper_handle_scope (inputs[i].handle); +if (scope !=NET_SHAPER_SCOPE_QUEUE && + scope !=NET_SHAPER_SCOPE_DETACHED ) { + ret = -EINVAL ; +NL_SET_ERR_MSG_FMT (extack,"Invalid scope %d for input shaper %d handle %x" , + scope, i, inputs[i].handle); + goto rollback; + } +if (scope ==NET_SHAPER_SCOPE_DETACHED && + !sc_lookup (dev, inputs[i].handle)) { + ret = -EINVAL ; +NL_SET_ERR_MSG_FMT (extack, +"Can't create detached shaper as input %d handle %x" , + i, inputs[i].handle); + goto rollback; + } + + ret =sc_prepare_insert (dev, &inputs[i].handle, extack); +if (ret) + goto rollback; + +/* the inputs shapers will be nested to the output */ +if (inputs[i].parent != output->handle) { + inputs[i].parent = output->handle; + output->children++; + } + } + + ret = dev->netdev_ops->net_shaper_ops->group (dev, nr_inputs, + inputs, output, + extack); +if (ret <0 ) + goto rollback; + +if (parent) + parent->children++; +sc_commit (dev,1 , output); +sc_commit (dev, nr_inputs, inputs); +return ret; + +rollback: +sc_rollback (dev); +return ret; +} + +static int nla_handle_total_size (void ) +{ +return nla_total_size (nla_total_size (sizeof (u32)) + +nla_total_size (sizeof (u32))); +} + +static int group_send_reply (struct genl_info *info,u32 handle,int id) +{ +struct nlattr *handle_attr; +struct sk_buff *msg; +int ret = -EMSGSIZE ; +void *hdr; + +/* prepare the msg reply in advance, to avoid device operation rollback */ + msg =genlmsg_new (nla_handle_total_size (),GFP_KERNEL ); +if (!msg) +return ret; + + hdr =genlmsg_iput (msg, info); +if (!hdr) + goto free_msg; + + handle_attr =nla_nest_start (msg,NET_SHAPER_A_HANDLE ); +if (!handle_attr) + goto free_msg; + +if (nla_put_u32 (msg,NET_SHAPER_A_SCOPE , +net_shaper_handle_scope (handle))) + goto free_msg; + +if (nla_put_u32 (msg,NET_SHAPER_A_ID , id)) + goto free_msg; + +nla_nest_end (msg, handle_attr); +genlmsg_end (msg, hdr); + + ret =genlmsg_reply (msg, info); +if (ret) + goto free_msg; + +return ret; + +free_msg: +nlmsg_free (msg); +return ret; +} +int net_shaper_nl_group_doit (struct sk_buff *skb,struct genl_info *info) { -return -EOPNOTSUPP ; +struct net_shaper_info *inputs, output; +int i, ret, rem, nr_inputs; +struct net_device *dev; +struct nlattr *attr; + +if (GENL_REQ_ATTR_CHECK (info,NET_SHAPER_A_INPUTS ) || +GENL_REQ_ATTR_CHECK (info,NET_SHAPER_A_OUTPUT )) +return -EINVAL ; + + ret =fetch_dev (info, &dev); +if (ret) +return ret; + + nr_inputs =attr_list_len (info,NET_SHAPER_A_INPUTS ); + inputs =kcalloc (nr_inputs,sizeof (struct net_shaper_info ),GFP_KERNEL ); +if (!inputs) { +GENL_SET_ERR_MSG_FMT (info,"Can't allocate memory for %d input shapers" , + nr_inputs); + ret = -ENOMEM ; + goto put; + } + + ret =parse_output_shaper (dev, info->attrs[NET_SHAPER_A_OUTPUT ], info, + &output); +if (ret) + goto free_shapers; + + i =0 ; +nla_for_each_attr_type (attr,NET_SHAPER_A_INPUTS , +genlmsg_data (info->genlhdr), +genlmsg_len (info->genlhdr), rem) { +if (WARN_ON_ONCE (i >= nr_inputs)) + goto free_shapers; + + ret =parse_shaper (dev, attr, info, &inputs[i++]); +if (ret) + goto free_shapers; + } + + ret =net_shaper_group (dev, nr_inputs, inputs, &output, info->extack); +if (ret <0 ) + goto free_shapers; + + ret =group_send_reply (info, output.handle, ret); +if (ret) { +/* Error on reply is not fatal to avoid rollback a successful +* configuration +*/ +GENL_SET_ERR_MSG_FMT (info,"Can't send reply %d" , ret); + ret =0 ; + } + +free_shapers: +kfree (inputs); + +put: +netdev_put (dev,NULL ); +return ret; }void dev_shaper_flush (struct net_device *dev)
Signature · 1 line
2.45.2
Paolo Abeni
maintainerPATCH v3 6/12 netlink: spec: add shaper introspection support
In reply to Paolo AbeniAllow the user-space to fine-grain query the shaping features supported by the NIC on each domain.
--- Documentation/netlink/specs/shaper.yaml | 75 +++++++++++++++++++++++++ include/uapi/linux/net_shaper.h | 17 ++++++ net/shaper/shaper.c | 11 ++++ net/shaper/shaper_nl_gen.c | 25 +++++++++ net/shaper/shaper_nl_gen.h | 3 + 5 files changed, 131 insertions(+)
Documentation/netlink/specs/shaper.yaml +75 -0
@@ -169,6 +169,52 @@ attribute-sets: name: priority - name: weight + - + name: capabilities + attributes: + - + name: ifindex + type: u32 + - + name: scope + type: u32 + enum: scope + doc: The scope to which the queried capabilities apply + - + name: support-metric-bps + type: flag + doc: the device accepts 'bps' metric for bw-min, bw-max and burst + - + name: support-metric-pps + type: flag + doc: the device accepts 'pps' metric for bw-min, bw-max and burst + - + name: support-nesting + type: flag + doc: | + the device supports nesting shaper belonging to this scope + below 'detached' scoped shapers. Only 'queue' and 'detached' + scope and flag 'support-nesting'. + - + name: support-bw-min + type: flag + doc: the device supports a minimum guaranteed bw + - + name: support-bw-max + type: flag + doc: the device supports maximum bw shaping + - + name: support-burst + type: flag + doc: the device supports a maximum burst size + - + name: support-priority + type: flag + doc: the device supports priority scheduling + - + name: support-weight + type: flag + doc: the device supports weighted round robin scheduling operations: list:
@@ -260,3 +306,32 @@ operations: reply: attributes: - handle + + - + name: cap-get + doc: | + Get / Dump the shaper capabilities supported by the given device + attribute-set: capabilities + + do: + request: + attributes: + - ifindex + - scope + reply: + attributes: &cap-attrs + - support-metric-bps + - support-metric-pps + - support-nesting + - support-bw-min + - support-bw-max + - support-burst + - support-priority + - support-weight + + dump: + request: + attributes: + - ifindex + reply: + attributes: *cap-attrs
include/uapi/linux/net_shaper.h +17 -0
@@ -61,11 +61,28 @@ enum {NET_SHAPER_A_MAX = (__NET_SHAPER_A_MAX -1 ) }; +enum { +NET_SHAPER_A_CAPABILITIES_IFINDEX =1 , +NET_SHAPER_A_CAPABILITIES_SCOPE , +NET_SHAPER_A_CAPABILITIES_SUPPORT_METRIC_BPS , +NET_SHAPER_A_CAPABILITIES_SUPPORT_METRIC_PPS , +NET_SHAPER_A_CAPABILITIES_SUPPORT_NESTING , +NET_SHAPER_A_CAPABILITIES_SUPPORT_BW_MIN , +NET_SHAPER_A_CAPABILITIES_SUPPORT_BW_MAX , +NET_SHAPER_A_CAPABILITIES_SUPPORT_BURST , +NET_SHAPER_A_CAPABILITIES_SUPPORT_PRIORITY , +NET_SHAPER_A_CAPABILITIES_SUPPORT_WEIGHT , + + __NET_SHAPER_A_CAPABILITIES_MAX, +NET_SHAPER_A_CAPABILITIES_MAX = (__NET_SHAPER_A_CAPABILITIES_MAX -1 ) +}; +enum {NET_SHAPER_CMD_GET =1 ,NET_SHAPER_CMD_SET ,NET_SHAPER_CMD_DELETE ,NET_SHAPER_CMD_GROUP , +NET_SHAPER_CMD_CAP_GET , __NET_SHAPER_CMD_MAX,NET_SHAPER_CMD_MAX = (__NET_SHAPER_CMD_MAX -1 )
net/shaper/shaper.c +11 -0
@@ -837,6 +837,17 @@ int net_shaper_nl_group_doit(struct sk_buff *skb, struct genl_info *info)return ret; } +int net_shaper_nl_cap_get_doit (struct sk_buff *skb,struct genl_info *info) +{ +return 0 ; +} + +int net_shaper_nl_cap_get_dumpit (struct sk_buff *skb, +struct netlink_callback *cb) +{ +return 0 ; +} +void dev_shaper_flush (struct net_device *dev) {struct xarray *xa =__sc_container (dev);
net/shaper/shaper_nl_gen.c +25 -0
@@ -67,6 +67,17 @@ static const struct nla_policy net_shaper_group_nl_policy[NET_SHAPER_A_OUTPUT + [NET_SHAPER_A_OUTPUT] = NLA_POLICY_NESTED(net_shaper_ns_output_info_nl_policy), }; +/* NET_SHAPER_CMD_CAP_GET - do */ +static const struct nla_policy net_shaper_cap_get_do_nl_policy[NET_SHAPER_A_CAPABILITIES_SCOPE +1 ] = { + [NET_SHAPER_A_CAPABILITIES_IFINDEX ] = { .type =NLA_U32 , }, + [NET_SHAPER_A_CAPABILITIES_SCOPE ] =NLA_POLICY_MAX (NLA_U32 ,4 ), +}; + +/* NET_SHAPER_CMD_CAP_GET - dump */ +static const struct nla_policy net_shaper_cap_get_dump_nl_policy[NET_SHAPER_A_CAPABILITIES_IFINDEX +1 ] = { + [NET_SHAPER_A_CAPABILITIES_IFINDEX ] = { .type =NLA_U32 , }, +}; +/* Ops table for net_shaper */ static const struct genl_split_ops net_shaper_nl_ops[] = { {
@@ -104,6 +115,20 @@ static const struct genl_split_ops net_shaper_nl_ops[] = { .maxattr = NET_SHAPER_A_OUTPUT, .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, }, + { + .cmd = NET_SHAPER_CMD_CAP_GET, + .doit = net_shaper_nl_cap_get_doit, + .policy = net_shaper_cap_get_do_nl_policy, + .maxattr = NET_SHAPER_A_CAPABILITIES_SCOPE, + .flags = GENL_CMD_CAP_DO, + }, + { + .cmd = NET_SHAPER_CMD_CAP_GET, + .dumpit = net_shaper_nl_cap_get_dumpit, + .policy = net_shaper_cap_get_dump_nl_policy, + .maxattr = NET_SHAPER_A_CAPABILITIES_IFINDEX, + .flags = GENL_CMD_CAP_DUMP, + }, }; struct genl_family net_shaper_nl_family __ro_after_init = {
net/shaper/shaper_nl_gen.h +3 -0
@@ -21,6 +21,9 @@ int net_shaper_nl_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb);int net_shaper_nl_set_doit (struct sk_buff *skb,struct genl_info *info);int net_shaper_nl_delete_doit (struct sk_buff *skb,struct genl_info *info);int net_shaper_nl_group_doit (struct sk_buff *skb,struct genl_info *info); +int net_shaper_nl_cap_get_doit (struct sk_buff *skb,struct genl_info *info); +int net_shaper_nl_cap_get_dumpit (struct sk_buff *skb, +struct netlink_callback *cb);extern struct genl_family net_shaper_nl_family;
Signature · 1 line
2.45.2
Donald Hunter
maintainerRe: [PATCH v3 06/12] netlink: spec: add shaper introspection support
Documentation/netlink/specs/shaper.yaml attribute-sets: · line 195
Quoted 5 lines · Paolo Abeni
Documentation/netlink/specs/shaper.yaml +5
-0+ - + name: support-nesting + type: flag + doc: | + the device supports nesting shaper belonging to this scope
Nit: capitalize all the doc strings for consistency.
Documentation/netlink/specs/shaper.yaml attribute-sets: · line 197
Quoted 2 lines
Documentation/netlink/specs/shaper.yaml +2
-0+ below 'detached' scoped shapers. Only 'queue' and 'detached' + scope and flag 'support-nesting'.
'and flag' looks like a typo. Do you mean 'can have flag'?
Quoted 18 lines
Documentation/netlink/specs/shaper.yaml +18
-0+ - + name: cap-get + doc: | + Get / Dump the shaper capabilities supported by the given device + attribute-set: capabilities + + do: + request: + attributes: + - ifindex + - scope + reply: + attributes: &cap-attrs + - support-metric-bps + - support-metric-pps + - support-nesting + - support-bw-min + - support-bw-max
Documentation/netlink/specs/shaper.yaml operations: · line 337
Quoted 10 lines
Documentation/netlink/specs/shaper.yaml +10
-0+ - support-burst + - support-priority + - support-weight + + dump: + request: + attributes: + - ifindex + reply: + attributes: *cap-attrs
scope is missing from the dump reply
Paolo Abeni
maintainerPATCH v3 7/12 net: shaper: implement introspection support
In reply to Paolo AbeniThe netlink op is a simple wrapper around the device callback.
Extend the existing fetch_dev() helper adding an attribute argument for the requested device. Reuse such helper in the newly implemented operation.
---
RFC v2 -> RFC v3:
- dev_put() -> netdev_put()
--- include/net/net_shaper.h | 11 ++++ net/shaper/shaper.c | 108 +++++++++++++++++++++++++++++++++++---- 2 files changed, 109 insertions(+), 10 deletions(-)
include/net/net_shaper.h +11 -0
@@ -103,6 +103,17 @@ struct net_shaper_ops {*/ int (*delete)(struct net_device *dev,u32 handle,struct netlink_ext_ack *extack); + +/** +* @capabilities: get the shaper features supported by the NIC +* +* Fills the bitmask @cap with the supported cababilites for the +* specified @scope and device @dev. +* +* Returns 0 on success or a negative error value otherwise. +*/ +int (*capabilities)(struct net_device *dev, +enum net_shaper_scope scope,unsigned long *cap); };#define NET_SHAPER_SCOPE_SHIFT 26
net/shaper/shaper.c +98 -10
164 lines not on this page · raw message
Signature · 1 line
2.45.2
Paolo Abeni
maintainerPATCH v3 8/12 testing: net-drv: add basic shaper test
In reply to Paolo AbeniLeverage a basic/dummy netdevsim implementation to do functional coverage for NL interface.
---
rfc v1 -> v2:
- added more test-cases WRT nesting and grouping
--- drivers/net/Kconfig | 1 + drivers/net/netdevsim/netdev.c | 37 +++ tools/testing/selftests/drivers/net/Makefile | 1 + tools/testing/selftests/drivers/net/shaper.py | 267 ++++++++++++++++++ .../testing/selftests/net/lib/py/__init__.py | 1 + tools/testing/selftests/net/lib/py/ynl.py | 5 + 6 files changed, 312 insertions(+) create mode 100755 tools/testing/selftests/drivers/net/shaper.py
drivers/net/Kconfig +1 -0
@@ -641,6 +641,7 @@ config NETDEVSIM depends on PTP_1588_CLOCK_MOCK || PTP_1588_CLOCK_MOCK=n select NET_DEVLINK select PAGE_POOL + select NET_SHAPER help This driver is a developer testing tool and software model that can be used to test various control path networking APIs, especially
drivers/net/netdevsim/netdev.c +37 -0
@@ -22,6 +22,7 @@#include <net/netdev_queues.h> #include <net/page_pool/helpers.h> #include <net/netlink.h> +#include <net/net_shaper.h> #include <net/pkt_cls.h> #include <net/rtnetlink.h> #include <net/udp_tunnel.h>
@@ -475,6 +476,41 @@ static int nsim_stop(struct net_device *dev)return 0 ; } +static int nsim_shaper_set (struct net_device *dev, +const struct net_shaper_info *shaper, +struct netlink_ext_ack *extack) +{ +return 0 ; +} + +static int nsim_shaper_del (struct net_device *dev,u32 handles, +struct netlink_ext_ack *extack) +{ +return 0 ; +} + +static int nsim_shaper_group (struct net_device *dev,int nr_inputs, +const struct net_shaper_info *inputs, +const struct net_shaper_info *output, +struct netlink_ext_ack *extack) +{ +return 0 ; +} + +static int nsim_shaper_cap (struct net_device *dev,enum net_shaper_scope scope, +unsigned long *flags) +{ + *flags =ULONG_MAX ; +return 0 ; +} + +static const struct net_shaper_ops nsim_shaper_ops = { + .set = nsim_shaper_set, + .delete = nsim_shaper_del, + .group = nsim_shaper_group, + .capabilities = nsim_shaper_cap, +}; +static const struct net_device_ops nsim_netdev_ops = { .ndo_start_xmit = nsim_start_xmit, .ndo_set_rx_mode = nsim_set_rx_mode,
@@ -496,6 +532,7 @@ static const struct net_device_ops nsim_netdev_ops = { .ndo_bpf = nsim_bpf, .ndo_open = nsim_open, .ndo_stop = nsim_stop, + .net_shaper_ops = &nsim_shaper_ops, };static const struct net_device_ops nsim_vf_netdev_ops = {
tools/testing/selftests/drivers/net/Makefile +1 -0
@@ -6,6 +6,7 @@ TEST_PROGS := \ ping.py \ queues.py \ stats.py \ + shaper.py # end of TEST_PROGS include ../../lib.mk
tools/testing/selftests/drivers/net/shaper.py new file +267 -0
267 lines not on this page · raw message
tools/testing/selftests/net/lib/py/__init__.py +1 -0
@@ -6,3 +6,4 @@ from .netns import NetNS from .nsim import * from .utils import * from .ynl import NlError, YnlFamily, EthtoolFamily, NetdevFamily, RtnlFamily +from .ynl import ShaperFamily
tools/testing/selftests/net/lib/py/ynl.py +5 -0
@@ -47,3 +47,8 @@ class NetdevFamily(YnlFamily): def __init__(self): super().__init__((SPEC_PATH / Path('netdev.yaml')).as_posix(), schema='') + +class ShaperFamily(YnlFamily): + def __init__(self): + super().__init__((SPEC_PATH / Path('shaper.yaml')).as_posix(), + schema='')
Signature · 1 line
2.45.2
Paolo Abeni
maintainerRe: [PATCH v3 08/12] testing: net-drv: add basic shaper test
Quoted 4 lines · Paolo Abeni
Leverage a basic/dummy netdevsim implementation to do functional coverage for NL interface.
Signed-off-by Paolo Abeni <[email protected]>
FTR, it looks like the CI build went wild around this patch, but the failures look unrelated to the actual changes here. i.e.:
https://netdev.bots.linux.dev/static/nipa/875223/13747883/build_clang/stderr
Per-file breakdown
tmp/tmp.pwD35f06q6 renamed from tmp/tmp.z9wI8zevoA +13 -0
@@ -0,0 +1,13 @@ + 4 ../drivers/block/drbd/drbd_bitmap.c + 4 ../drivers/block/drbd/drbd_main.c + 2 ../drivers/firmware/broadcom/bcm47xx_sprom.c + 6 ../drivers/most/most_usb.c + 1 ../drivers/net/ethernet/sfc/ptp.c + 1 ../drivers/net/ethernet/sfc/siena/ptp.c + 7 ../include/linux/fortify-string.h + 2 ../include/linux/kern_levels.h + 2 ../include/linux/printk.h + 2 ../kernel/audit.c + 1 ../lib/vsprintf.c + 3 ../net/ipv4/tcp_lp.c + 2 ../security/apparmor/lsm.c
Still we hit a similar issue on the previous iteration, so perhaps there is some correlation I don't see?!?
Jakub Kicinski
maintainerRe: [PATCH v3 08/12] testing: net-drv: add basic shaper test
Quoted 10 lines · On Wed, 31 Jul 2024 09:52:38 +0200 Paolo Abeni wrote:
Quoted 4 lines · Paolo Abeni
Leverage a basic/dummy netdevsim implementation to do functional coverage for NL interface.
Signed-off-by Paolo Abeni <[email protected]>FTR, it looks like the CI build went wild around this patch, but the failures look unrelated to the actual changes here. i.e.:
https://netdev.bots.linux.dev/static/nipa/875223/13747883/build_clang/stderr
Could you dig deeper?
The scripts are doing incremental builds, and changes to Kconfig confuse them. You should be able to run the build script as a normal bash script, directly, it only needs a small handful of exported env variables.
I have been trying to massage this for a while, my last change is:
https://github.com/linux-netdev/nipa/commit/5bcb890cbfecd3c1727cec2f026360646a4afc62
Simon Horman
reviewerRe: [PATCH v3 08/12] testing: net-drv: add basic shaper test
Quoted 14 lines · Jakub Kicinski
Quoted 10 lines · On Wed, 31 Jul 2024 09:52:38 +0200 Paolo Abeni wrote:
Quoted 4 lines · Paolo Abeni
Leverage a basic/dummy netdevsim implementation to do functional coverage for NL interface.
Signed-off-by Paolo Abeni <[email protected]>FTR, it looks like the CI build went wild around this patch, but the failures look unrelated to the actual changes here. i.e.:
https://netdev.bots.linux.dev/static/nipa/875223/13747883/build_clang/stderr
Could you dig deeper?
Quoted 8 lines
The scripts are doing incremental builds, and changes to
Kconfigconfuse them. You should be able to run the build script as a normal bash script, directly, it only needs a small handful of exported env variables.I have been trying to massage this for a while, my last change is:
https://github.com/linux-netdev/nipa/commit/5bcb890cbfecd3c1727cec2f026360646a4afc62
Thanks Jakub,
I am looking into this.
So far I believe it relate to a Kconfig change activating new code. But reproducing the problem is proving a little tricky.
Jakub Kicinski
maintainerRe: [PATCH v3 08/12] testing: net-drv: add basic shaper test
Quoted 18 lines · On Mon, 5 Aug 2024 15:22:53 +0100 Simon Horman wrote:
Quoted 8 lines · Jakub Kicinski
Quoted 4 lines · On Wed, 31 Jul 2024 09:52:38 +0200 Paolo Abeni wrote:
FTR, it looks like the CI build went wild around this patch, but the failures look unrelated to the actual changes here. i.e.:
https://netdev.bots.linux.dev/static/nipa/875223/13747883/build_clang/stderr
Could you dig deeper?
Quoted 8 lines
The scripts are doing incremental builds, and changes to
Kconfigconfuse them. You should be able to run the build script as a normal bash script, directly, it only needs a small handful of exported env variables.I have been trying to massage this for a while, my last change is:
https://github.com/linux-netdev/nipa/commit/5bcb890cbfecd3c1727cec2f026360646a4afc62
Quoted 5 lines
Thanks Jakub,
I am looking into this.
So far I believe it relate to aKconfigchange activating new code. But reproducing the problem is proving a little tricky.
Have you tried twiddling / exporting FIRST_IN_SERIES ?
See here for the 4 possible exports the test will look at:
https://github.com/linux-netdev/nipa/blob/6112db7d472660450c69457c98ab37b431063301/core/test.py#L124
Simon Horman
reviewerRe: [PATCH v3 08/12] testing: net-drv: add basic shaper test
Quoted 25 lines · Jakub Kicinski
Quoted 18 lines · On Mon, 5 Aug 2024 15:22:53 +0100 Simon Horman wrote:
Quoted 8 lines · Jakub Kicinski
Quoted 4 lines · On Wed, 31 Jul 2024 09:52:38 +0200 Paolo Abeni wrote:
FTR, it looks like the CI build went wild around this patch, but the failures look unrelated to the actual changes here. i.e.:
https://netdev.bots.linux.dev/static/nipa/875223/13747883/build_clang/stderr
Could you dig deeper?
Quoted 8 lines
The scripts are doing incremental builds, and changes to
Kconfigconfuse them. You should be able to run the build script as a normal bash script, directly, it only needs a small handful of exported env variables.I have been trying to massage this for a while, my last change is:
https://github.com/linux-netdev/nipa/commit/5bcb890cbfecd3c1727cec2f026360646a4afc62Quoted 5 lines
Thanks Jakub,
I am looking into this.
So far I believe it relate to aKconfigchange activating new code. But reproducing the problem is proving a little tricky.
Quoted 5 lines
Have you tried twiddling / exporting
FIRST_IN_SERIES?See here for the 4 possible exports the test will look at:
https://github.com/linux-netdev/nipa/blob/6112db7d472660450c69457c98ab37b431063301/core/test.py#L124
Thanks, I will look into that.
Simon Horman
reviewerRe: [PATCH v3 08/12] testing: net-drv: add basic shaper test
Quoted 26 lines · Simon Horman
Quoted 25 lines · Jakub Kicinski
Quoted 23 lines · On Mon, 5 Aug 2024 15:22:53 +0100 Simon Horman wrote:
Quoted 8 lines · Jakub Kicinski
Quoted 4 lines · On Wed, 31 Jul 2024 09:52:38 +0200 Paolo Abeni wrote:
FTR, it looks like the CI build went wild around this patch, but the failures look unrelated to the actual changes here. i.e.:
https://netdev.bots.linux.dev/static/nipa/875223/13747883/build_clang/stderr
Could you dig deeper?
Quoted 8 lines
The scripts are doing incremental builds, and changes to
Kconfigconfuse them. You should be able to run the build script as a normal bash script, directly, it only needs a small handful of exported env variables.I have been trying to massage this for a while, my last change is:
https://github.com/linux-netdev/nipa/commit/5bcb890cbfecd3c1727cec2f026360646a4afc62Thanks Jakub,
I am looking into this.
So far I believe it relate to aKconfigchange activating new code. But reproducing the problem is proving a little tricky.
Quoted 7 lines
Quoted 5 lines
Have you tried twiddling / exporting
FIRST_IN_SERIES?See here for the 4 possible exports the test will look at:
https://github.com/linux-netdev/nipa/blob/6112db7d472660450c69457c98ab37b431063301/core/test.py#L124
Thanks, I will look into that.
Hi Jakub,
Thanks again for the information.
I have now taken another look at this problem.
Firstly, my analysis is that the cause of the problem is a combination of the way the patchset is constricted, and the way that the build tests (I have focussed on build_allmodconfig_warn.sh [1]).
What I believe happens is this: The patches 01/12 - 07/12 modify some header files, adds a new Kconfig entry, and does a bunch of other normal stuff. Each of those patches is tested in turn, and everything seems fine.
Then we get to patch 08/12. The key thing about this patch is that it enables the CONFIG_NET_SHAPER Kconfig option, in the context of an allmodconfig build. That in turn modifies the headers include/linux/netdevice.h and net/core/dev.h (and net/Makefile). Not in the in terms of their on-disk contents changing, but rather in the case of the header files, in terms of preprocessor output. And this is, I believe, where everything goes wrong.
NIPA arrives at running build_allmodconfig_warn.sh for patch 08/12 with the tree built for the previous patch, 07/12. It then:
* touches $output_dir/include/generated/utsrelease.h
* checks out HEAD~ (patch 07/12)
* prepares the kernel config
* builds kernel and records incumbent errors (49)
The thing to note here is that the tree has been little perturbed since build tests were run for patch 07/12, and thus few files are rebuilt.
Moving on, simplifying things, the following then runs:
* touches $output_dir/include/generated/utsrelease.h
* checks out $HEAD (patch 08/12)
* prepares the kernel config
* builds kernel and records current errors (4219)
The key to understanding why the large delta between 49 and 4219 is that vastly more files have been rebuilt. Because the preprocessor output of netdevice.h and dev.h have changes since the last build, and those headers are included, directly or indirectly, by a lot of files (and compilation results in warnings for many of those files).
I was able to reproduce the result by running build_allmodconfig_warn.sh over patch 07/12 and then 07/12 with FIRST_IN_SERIES=0.
I was able to get the desired result no new compiler warnings by doing the same again, but with FIRST_IN_SERIES=1 for the invocation of build_allmodconfig_warn.sh for 08/12.
I believe this is entirely due to a baseline rebuild being run due to the FIRST_IN_SERIES=1 parameter. And, FWIIW, I believe the invocation of build_allmodconfig_warn.sh for 07/12 ensures reproducibility.
My suggestion is that while we may consider reorganising the patch-set, that is really only a work around. And it would be best to make the CI more robust in the presence of such constructions.
It may be a bit heavy handed, but my tested solution is to invoke a baseline rebuild if a Kconfig change is made. At the very last it does address the problem at hand. (In precisely the same way as manually setting FIRST_IN_SERIES=1.)
The patch implementing this for build_allmodconfig.sh which I tested is below. If we want to go ahead with this approach then I expect it is best to add it to other build tests too. But this seems to be a good point to report my findings, so here we are.
build_allmodconfig.sh 2024-08-08 09:58:22.692206313 +0000 renamed from build_allmodconfig.sh.orig 2024-08-08 07:30:56.599372164 +0000 +4 -2
@@ -34,8 +34,10 @@ echo "Tree base:" git log -1 --pretty='%h ("%s")' HEAD~ -if [ x$FIRST_IN_SERIES == x0 ]; then - echo "Skip baseline build, not the first patch" +if [ x$FIRST_IN_SERIES == x0 ] && \ + ! git diff --name-only HEAD~ | grep -q -E "Kconfig$" +then + echo "Skip baseline build, not the first patch and no Kconfig updates" else echo "Baseline building the tree"
Jakub Kicinski
maintainerRe: [PATCH v3 08/12] testing: net-drv: add basic shaper test
Quoted 14 lines · On Thu, 8 Aug 2024 13:20:42 +0100 Simon Horman wrote:
Thanks again for the information.
I have now taken another look at this problem.
Firstly, my analysis is that the cause of the problem is a combination of the way the patchset is constricted, and the way that the build tests (I have focussed on
build_allmodconfig_warn.sh[1]).What I believe happens is this: The patches 01/12 - 07/12 modify some header files, adds a new
Kconfigentry, and does a bunch of other normal stuff. Each of those patches is tested in turn, and everything seems fine.
Quoted 7 lines
Then we get to patch 08/12. The key thing about this patch is that it enables the
CONFIG_NET_SHAPERKconfigoption, in the context of an allmodconfig build. That in turn modifies the headersinclude/linux/netdevice.handnet/core/dev.h(and net/Makefile). Not in the in terms of their on-disk contents changing, but rather in the case of the header files, in terms of preprocessor output. And this is, I believe, where everything goes wrong.
That's strange, make does not understand preprocessor, does it? Either file has been modified or it has not.
I guess it doesn't matter, given your solution
Quoted 54 lines
NIPA arrives at running
build_allmodconfig_warn.shfor patch 08/12 with the tree built for the previous patch, 07/12. It then:* touches
$output_dir/include/generated/utsrelease.h
* checks out HEAD~ (patch 07/12)
* prepares the kernel config
* builds kernel and records incumbent errors (49)The thing to note here is that the tree has been little perturbed since build tests were run for patch 07/12, and thus few files are rebuilt.
Moving on, simplifying things, the following then runs:
* touches
$output_dir/include/generated/utsrelease.h
* checks out $HEAD (patch 08/12)
* prepares the kernel config
* builds kernel and records current errors (4219)The key to understanding why the large delta between 49 and 4219 is that vastly more files have been rebuilt. Because the preprocessor output of
netdevice.handdev.hhave changes since the last build, and those headers are included, directly or indirectly, by a lot of files (and compilation results in warnings for many of those files).I was able to reproduce the result by running
build_allmodconfig_warn.shover patch 07/12 and then 07/12 with FIRST_IN_SERIES=0.I was able to get the desired result no new compiler warnings by doing the same again, but with FIRST_IN_SERIES=1 for the invocation of
build_allmodconfig_warn.shfor 08/12.I believe this is entirely due to a baseline rebuild being run due to the FIRST_IN_SERIES=1 parameter. And, FWIIW, I believe the invocation of
build_allmodconfig_warn.shfor 07/12 ensures reproducibility.My suggestion is that while we may consider reorganising the patch-set, that is really only a work around. And it would be best to make the CI more robust in the presence of such constructions.
It may be a bit heavy handed, but my tested solution is to invoke a baseline rebuild if a
Kconfigchange is made. At the very last it does address the problem at hand. (In precisely the same way as manually setting FIRST_IN_SERIES=1.)The patch implementing this for
build_allmodconfig.shwhich I tested is below. If we want to go ahead with this approach then I expect it is best to add it to other build tests too. But this seems to be a good point to report my findings, so here we are.build_allmodconfig.sh 2024-08-08 09:58:22.692206313 +0000 renamed from build_allmodconfig.sh.orig 2024-08-08 07:30:56.599372164 +0000 +0
-0@@ -34,8 +34,10 @@ echo "Tree base:"
build_allmodconfig.sh 2024-08-08 09:58:22.692206313 +0000 line 42
Quoted 10 lines
build_allmodconfig.sh 2024-08-08 09:58:22.692206313 +0000 renamed from build_allmodconfig.sh.orig 2024-08-08 07:30:56.599372164 +0000 +4
-2git log -1 --pretty='%h ("%s")' HEAD~ -if [ x$FIRST_IN_SERIES == x0 ]; then - echo "Skip baseline build, not the first patch" +if [ x$FIRST_IN_SERIES == x0 ] && \ + ! git diff --name-only HEAD~ | grep -q -E "Kconfig$" +then + echo "Skip baseline build, not the first patch and no Kconfig updates" else echo "Baseline building the tree"
Excellent idea, let's try it! Could you send a PR to NIPA? Note that the code is copied 3 times for each flavor of building :(
Simon Horman
reviewerRe: [PATCH v3 08/12] testing: net-drv: add basic shaper test
Quoted 23 lines · Jakub Kicinski
Quoted 14 lines · On Thu, 8 Aug 2024 13:20:42 +0100 Simon Horman wrote:
Thanks again for the information.
I have now taken another look at this problem.
Firstly, my analysis is that the cause of the problem is a combination of the way the patchset is constricted, and the way that the build tests (I have focussed on
build_allmodconfig_warn.sh[1]).What I believe happens is this: The patches 01/12 - 07/12 modify some header files, adds a new
Kconfigentry, and does a bunch of other normal stuff. Each of those patches is tested in turn, and everything seems fine.Quoted 7 lines
Then we get to patch 08/12. The key thing about this patch is that it enables the
CONFIG_NET_SHAPERKconfigoption, in the context of an allmodconfig build. That in turn modifies the headersinclude/linux/netdevice.handnet/core/dev.h(and net/Makefile). Not in the in terms of their on-disk contents changing, but rather in the case of the header files, in terms of preprocessor output. And this is, I believe, where everything goes wrong.
Quoted 2 lines
That's strange, make does not understand preprocessor, does it? Either file has been modified or it has not.
True, that is a good point.
I would say there is something deeper going on than
I have been able to discover at this time: probably something very obvious.
Quoted 1 line
I guess it doesn't matter, given your solution
Right, in any case I think the script needs to be enhanced. My solution may prove heavy handed, but it can be improved over time.
Quoted 25 lines
Quoted 25 lines
NIPA arrives at running
build_allmodconfig_warn.shfor patch 08/12 with the tree built for the previous patch, 07/12. It then:* touches
$output_dir/include/generated/utsrelease.h
* checks out HEAD~ (patch 07/12)
* prepares the kernel config
* builds kernel and records incumbent errors (49)The thing to note here is that the tree has been little perturbed since build tests were run for patch 07/12, and thus few files are rebuilt.
Moving on, simplifying things, the following then runs:
* touches
$output_dir/include/generated/utsrelease.h
* checks out $HEAD (patch 08/12)
* prepares the kernel config
* builds kernel and records current errors (4219)The key to understanding why the large delta between 49 and 4219 is that vastly more files have been rebuilt. Because the preprocessor output of
netdevice.handdev.hhave changes since the last build, and those headers are included, directly or indirectly, by a lot of files (and compilation results in warnings for many of those files).
Quoted 2 lines
Quoted 2 lines
I was able to reproduce the result by running
build_allmodconfig_warn.shover patch 07/12 and then 07/12 with FIRST_IN_SERIES=0.
Correction: this should have read "07/12 and then 08/12"
Quoted 28 lines
Quoted 28 lines
I was able to get the desired result no new compiler warnings by doing the same again, but with FIRST_IN_SERIES=1 for the invocation of
build_allmodconfig_warn.shfor 08/12.I believe this is entirely due to a baseline rebuild being run due to the FIRST_IN_SERIES=1 parameter. And, FWIIW, I believe the invocation of
build_allmodconfig_warn.shfor 07/12 ensures reproducibility.My suggestion is that while we may consider reorganising the patch-set, that is really only a work around. And it would be best to make the CI more robust in the presence of such constructions.
It may be a bit heavy handed, but my tested solution is to invoke a baseline rebuild if a
Kconfigchange is made. At the very last it does address the problem at hand. (In precisely the same way as manually setting FIRST_IN_SERIES=1.)The patch implementing this for
build_allmodconfig.shwhich I tested is below. If we want to go ahead with this approach then I expect it is best to add it to other build tests too. But this seems to be a good point to report my findings, so here we are.build_allmodconfig.sh 2024-08-08 09:58:22.692206313 +0000 renamed from build_allmodconfig.sh.orig 2024-08-08 07:30:56.599372164 +0000 +0
-0@@ -34,8 +34,10 @@ echo "Tree base:" git log -1 --pretty='%h ("%s")' HEAD~
Quoted 10 lines
build_allmodconfig.sh 2024-08-08 09:58:22.692206313 +0000 line 42
Quoted 8 lines
build_allmodconfig.sh 2024-08-08 09:58:22.692206313 +0000 renamed from build_allmodconfig.sh.orig 2024-08-08 07:30:56.599372164 +0000 +4
-2-if [ x$FIRST_IN_SERIES == x0 ]; then - echo "Skip baseline build, not the first patch" +if [ x$FIRST_IN_SERIES == x0 ] && \ + ! git diff --name-only HEAD~ | grep -q -E "Kconfig$" +then + echo "Skip baseline build, not the first patch and no Kconfig updates" else echo "Baseline building the tree"Excellent idea, let's try it! Could you send a PR to NIPA?
Yes, can do.
Quoted 1 line
Note that the code is copied 3 times for each flavor of building :(
I assumed so :)
Simon Horman
reviewerRe: [PATCH v3 08/12] testing: net-drv: add basic shaper test
Quoted 2 lines · Simon Horman
Quoted 1 line · Jakub Kicinski
On Thu, 8 Aug 2024 13:20:42 +0100 Simon Horman wrote:
...
Quoted 27 lines
Quoted 16 lines
Quoted 16 lines
It may be a bit heavy handed, but my tested solution is to invoke a baseline rebuild if a
Kconfigchange is made. At the very last it does address the problem at hand. (In precisely the same way as manually setting FIRST_IN_SERIES=1.)The patch implementing this for
build_allmodconfig.shwhich I tested is below. If we want to go ahead with this approach then I expect it is best to add it to other build tests too. But this seems to be a good point to report my findings, so here we are.build_allmodconfig.sh 2024-08-08 09:58:22.692206313 +0000 renamed from build_allmodconfig.sh.orig 2024-08-08 07:30:56.599372164 +0000 +0
-0@@ -34,8 +34,10 @@ echo "Tree base:" git log -1 --pretty='%h ("%s")' HEAD~Quoted 10 lines
build_allmodconfig.sh 2024-08-08 09:58:22.692206313 +0000 line 42
Quoted 8 lines
build_allmodconfig.sh 2024-08-08 09:58:22.692206313 +0000 renamed from build_allmodconfig.sh.orig 2024-08-08 07:30:56.599372164 +0000 +4
-2-if [ x$FIRST_IN_SERIES == x0 ]; then - echo "Skip baseline build, not the first patch" +if [ x$FIRST_IN_SERIES == x0 ] && \ + ! git diff --name-only HEAD~ | grep -q -E "Kconfig$" +then + echo "Skip baseline build, not the first patch and no Kconfig updates" else echo "Baseline building the tree"Excellent idea, let's try it! Could you send a PR to NIPA?
Quoted 1 line
Yes, can do.
For reference, the PR is here:
https://github.com/linux-netdev/nipa/pull/35
Jakub Kicinski
maintainerRe: [PATCH v3 08/12] testing: net-drv: add basic shaper test
Quoted 6 lines · On Sun, 11 Aug 2024 13:40:53 +0100 Simon Horman wrote:
Quoted 3 lines
Quoted 1 line
Excellent idea, let's try it! Could you send a PR to NIPA?
Yes, can do.
For reference, the PR is here:
https://github.com/linux-netdev/nipa/pull/35
Deployed now, thank you!
Paolo Abeni
maintainerRe: [PATCH v3 08/12] testing: net-drv: add basic shaper test
In reply to Jakub KicinskiQuoted 23 lines · Jakub Kicinski
Quoted 14 lines · On Thu, 8 Aug 2024 13:20:42 +0100 Simon Horman wrote:
Thanks again for the information.
I have now taken another look at this problem.
Firstly, my analysis is that the cause of the problem is a combination of the way the patchset is constricted, and the way that the build tests (I have focussed on
build_allmodconfig_warn.sh[1]).What I believe happens is this: The patches 01/12 - 07/12 modify some header files, adds a new
Kconfigentry, and does a bunch of other normal stuff. Each of those patches is tested in turn, and everything seems fine.Quoted 7 lines
Then we get to patch 08/12. The key thing about this patch is that it enables the
CONFIG_NET_SHAPERKconfigoption, in the context of an allmodconfig build. That in turn modifies the headersinclude/linux/netdevice.handnet/core/dev.h(and net/Makefile). Not in the in terms of their on-disk contents changing, but rather in the case of the header files, in terms of preprocessor output. And this is, I believe, where everything goes wrong.
Quoted 1 line
That's strange, make does not understand preprocessor, does it?
AFICS kbuild creates a file for each enabled knob under include/config/.
Then, for each kernel object target, it creates a .cmd file including the list of all dependencies. Such list comprises all the included files _and_ the relevant, mentioned "knob" file under include/config/
scripts/basic/fixdep is responsible for including the "knob files" in the dependency list.
To test the above:
make drivers/net/ethernet/intel/ice/ice_main.o touch include/config/NET_SHAPER
make V=2 drivers/net/ethernet/intel/ice/ice_main.o
CALL scripts/checksyscalls.sh - due to target is PHONY
DESCEND objtool
INSTALL libsubcmd_headers
CC drivers/net/ethernet/intel/ice/ice_main.o - due to:include/config/NET_SHAPER
Cheers,
Paolo
Paolo Abeni
maintainerPATCH v3 9/12 virtchnl: support queue rate limit and quanta size configuration
In reply to Paolo AbeniFrom: Wenjun Wu <[email protected]>
This patch adds new virtchnl opcodes and structures for rate limit and quanta size configuration, which include:
1. VIRTCHNL_OP_CONFIG_QUEUE_BW, to configure max bandwidth for each VF per queue.
2. VIRTCHNL_OP_CONFIG_QUANTA, to configure quanta size per queue.
3. VIRTCHNL_OP_GET_QOS_CAPS, VF queries current QoS configuration, such as enabled TCs, arbiter type, up2tc and bandwidth of VSI node. The configuration is previously set by DCB and PF, and now is the potential QoS capability of VF. VF can take it as reference to configure queue TC mapping.
--- include/linux/avf/virtchnl.h | 119 +++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+)
include/linux/avf/virtchnl.h +119 -0
@@ -89,6 +89,9 @@ enum virtchnl_rx_hsplit { VIRTCHNL_RX_HSPLIT_SPLIT_SCTP = 8, }; +enum virtchnl_bw_limit_type { +VIRTCHNL_BW_SHAPER =0 , +};/* END GENERIC DEFINES */ /* Opcodes for VF-PF communication. These are placed in the v_opcode field
@@ -151,6 +154,11 @@ enum virtchnl_ops {VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 =55 ,VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 =56 ,VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2 =57 , +/* opcode 57 - 65 are reserved */ +VIRTCHNL_OP_GET_QOS_CAPS =66 , +/* opcode 68 through 111 are reserved */ +VIRTCHNL_OP_CONFIG_QUEUE_BW =112 , +VIRTCHNL_OP_CONFIG_QUANTA =113 , VIRTCHNL_OP_MAX, };
@@ -260,6 +268,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);#define VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC BIT(26)#define VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF BIT(27)#define VIRTCHNL_VF_OFFLOAD_FDIR_PF BIT(28) +#define VIRTCHNL_VF_OFFLOAD_QOS BIT(29)#define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \ VIRTCHNL_VF_OFFLOAD_VLAN | \
@@ -1405,6 +1414,85 @@ struct virtchnl_fdir_del {VIRTCHNL_CHECK_STRUCT_LEN (12 , virtchnl_fdir_del); +struct virtchnl_shaper_bw { +/* Unit is Kbps */ +u32 committed; +u32 peak; +}; + +VIRTCHNL_CHECK_STRUCT_LEN (8 , virtchnl_shaper_bw); + +/* VIRTCHNL_OP_GET_QOS_CAPS +* VF sends this message to get its QoS Caps, such as +* TC number, Arbiter and Bandwidth. +*/ +struct virtchnl_qos_cap_elem { +u8 tc_num; +u8 tc_prio; +#define VIRTCHNL_ABITER_STRICT 0 +#define VIRTCHNL_ABITER_ETS 2 +u8 arbiter; +#define VIRTCHNL_STRICT_WEIGHT 1 +u8 weight; +enum virtchnl_bw_limit_type type; +union { +struct virtchnl_shaper_bw shaper; +u8 pad2[32 ]; + }; +}; + +VIRTCHNL_CHECK_STRUCT_LEN (40 , virtchnl_qos_cap_elem); + +struct virtchnl_qos_cap_list { +u16 vsi_id; +u16 num_elem; +struct virtchnl_qos_cap_elem cap[]; +}; + +VIRTCHNL_CHECK_STRUCT_LEN (4 , virtchnl_qos_cap_list); +#define virtchnl_qos_cap_list_LEGACY_SIZEOF 44 + +/* VIRTCHNL_OP_CONFIG_QUEUE_BW */ +struct virtchnl_queue_bw { +u16 queue_id; +u8 tc; +u8 pad; +struct virtchnl_shaper_bw shaper; +}; + +VIRTCHNL_CHECK_STRUCT_LEN (12 , virtchnl_queue_bw); + +struct virtchnl_queues_bw_cfg { +u16 vsi_id; +u16 num_queues; +struct virtchnl_queue_bw cfg[]; +}; + +VIRTCHNL_CHECK_STRUCT_LEN (4 , virtchnl_queues_bw_cfg); +#define virtchnl_queues_bw_cfg_LEGACY_SIZEOF 16 + +enum virtchnl_queue_type { +VIRTCHNL_QUEUE_TYPE_TX =0 , +VIRTCHNL_QUEUE_TYPE_RX =1 , +}; + +/* structure to specify a chunk of contiguous queues */ +struct virtchnl_queue_chunk { +/* see enum virtchnl_queue_type */ +s32 type; +u16 start_queue_id; +u16 num_queues; +}; + +VIRTCHNL_CHECK_STRUCT_LEN (8 , virtchnl_queue_chunk); + +struct virtchnl_quanta_cfg { +u16 quanta_size; +struct virtchnl_queue_chunk queue_select; +}; + +VIRTCHNL_CHECK_STRUCT_LEN (12 , virtchnl_quanta_cfg); +#define __vss_byone (p, member, count, old) \ (struct_size(p, member, count) + (old - 1 - struct_size(p, member, 0)))
@@ -1427,6 +1515,8 @@ VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del);__vss (virtchnl_vlan_filter_list_v2, __vss_byelem, p, m, c), \__vss (virtchnl_tc_info, __vss_byelem, p, m, c), \__vss (virtchnl_rdma_qvlist_info, __vss_byelem, p, m, c), \ +__vss (virtchnl_qos_cap_list, __vss_byelem, p, m, c), \ +__vss (virtchnl_queues_bw_cfg, __vss_byelem, p, m, c), \__vss (virtchnl_rss_key, __vss_byone, p, m, c), \ __vss(virtchnl_rss_lut, __vss_byone, p, m, c))
@@ -1626,6 +1716,35 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,case VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2 : valid_len =sizeof (struct virtchnl_vlan_setting );break ; +case VIRTCHNL_OP_GET_QOS_CAPS : +break ; +case VIRTCHNL_OP_CONFIG_QUEUE_BW : + valid_len = virtchnl_queues_bw_cfg_LEGACY_SIZEOF; +if (msglen >= valid_len) { +struct virtchnl_queues_bw_cfg *q_bw = + (struct virtchnl_queues_bw_cfg *)msg; + + valid_len =virtchnl_struct_size (q_bw, cfg, + q_bw->num_queues); +if (q_bw->num_queues ==0 ) { + err_msg_format = true; +break ; + } + } +break ; +case VIRTCHNL_OP_CONFIG_QUANTA : + valid_len =sizeof (struct virtchnl_quanta_cfg ); +if (msglen >= valid_len) { +struct virtchnl_quanta_cfg *q_quanta = + (struct virtchnl_quanta_cfg *)msg; + +if (q_quanta->quanta_size ==0 || + q_quanta->queue_select.num_queues ==0 ) { + err_msg_format = true; +break ; + } + } +break ;/* These are always errors coming from the VF. */ case VIRTCHNL_OP_EVENT :case VIRTCHNL_OP_UNKNOWN :
Signature · 1 line
2.45.2
Paolo Abeni
maintainerPATCH v3 10/12 ice: Support VF queue rate limit and quanta size configuration
In reply to Paolo AbeniFrom: Wenjun Wu <[email protected]>
Add support to configure VF queue rate limit and quanta size.
For quanta size configuration, the quanta profiles are divided evenly by PF numbers. For each port, the first quanta profile is reserved for default. When VF is asked to set queue quanta size, PF will search for an available profile, change the fields and assigned this profile to the queue.
--- drivers/net/ethernet/intel/ice/ice.h | 2 + drivers/net/ethernet/intel/ice/ice_base.c | 2 + drivers/net/ethernet/intel/ice/ice_common.c | 21 ++ .../net/ethernet/intel/ice/ice_hw_autogen.h | 8 + drivers/net/ethernet/intel/ice/ice_txrx.h | 1 + drivers/net/ethernet/intel/ice/ice_type.h | 1 + drivers/net/ethernet/intel/ice/ice_vf_lib.h | 8 + drivers/net/ethernet/intel/ice/ice_virtchnl.c | 333 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_virtchnl.h | 11 + .../intel/ice/ice_virtchnl_allowlist.c | 6 + 10 files changed, 393 insertions(+)
drivers/net/ethernet/intel/ice/ice.h +2 -0
@@ -659,6 +659,8 @@ struct ice_pf {struct ice_agg_node vf_agg_node[ICE_MAX_VF_AGG_NODES ];struct ice_dplls dplls;struct device *hwmon_dev; + +u8 num_quanta_prof_used; };extern struct workqueue_struct *ice_lag_wq;
drivers/net/ethernet/intel/ice/ice_base.c +2 -0
@@ -349,6 +349,8 @@ ice_setup_tx_ctx(struct ice_tx_ring *ring, struct ice_tlan_ctx *tlan_ctx, u16 pfbreak ; } + tlan_ctx->quanta_prof_idx = ring->quanta_prof_id; + tlan_ctx->tso_ena =ICE_TX_LEGACY ; tlan_ctx->tso_qnum = pf_q;
drivers/net/ethernet/intel/ice/ice_common.c +21 -0
@@ -2436,6 +2436,25 @@ ice_parse_func_caps(struct ice_hw *hw, struct ice_hw_func_caps *func_p,ice_recalc_port_limited_caps (hw, &func_p->common_cap); } +/** +* ice_func_id_to_logical_id - map from function id to logical pf id +* @active_function_bitmap: active function bitmap +* @pf_id: function number of device +* +* Return: logical PF ID. +*/ +static int ice_func_id_to_logical_id (u32 active_function_bitmap,u8 pf_id) +{ +u8 logical_id =0 ; +u8 i; + +for (i =0 ; i < pf_id; i++) +if (active_function_bitmap &BIT (i)) + logical_id++; + +return logical_id; +} +/** * ice_parse_valid_functions_cap - Parse ICE_AQC_CAPS_VALID_FUNCTIONS caps * @hw: pointer to the HW struct
@@ -2453,6 +2472,8 @@ ice_parse_valid_functions_cap(struct ice_hw *hw, struct ice_hw_dev_caps *dev_p, dev_p->num_funcs =hweight32 (number);ice_debug (hw,ICE_DBG_INIT ,"dev caps: num_funcs = %d\n" , dev_p->num_funcs); + + hw->logical_pf_id =ice_func_id_to_logical_id (number, hw->pf_id); }/**
drivers/net/ethernet/intel/ice/ice_hw_autogen.h +8 -0
@@ -6,6 +6,14 @@#ifndef _ICE_HW_AUTOGEN_H_#define _ICE_HW_AUTOGEN_H_ +#define GLCOMM_QUANTA_PROF (_i) (0x002D2D68 + ((_i) * 4)) +#define GLCOMM_QUANTA_PROF_MAX_INDEX 15 +#define GLCOMM_QUANTA_PROF_QUANTA_SIZE_S 0 +#define GLCOMM_QUANTA_PROF_QUANTA_SIZE_M ICE_M(0x3FFF, 0) +#define GLCOMM_QUANTA_PROF_MAX_CMD_S 16 +#define GLCOMM_QUANTA_PROF_MAX_CMD_M ICE_M(0xFF, 16) +#define GLCOMM_QUANTA_PROF_MAX_DESC_S 24 +#define GLCOMM_QUANTA_PROF_MAX_DESC_M ICE_M(0x3F, 24)#define QTX_COMM_DBELL (_DBQM) (0x002C0000 + ((_DBQM) * 4))#define QTX_COMM_HEAD (_DBQM) (0x000E0000 + ((_DBQM) * 4))#define QTX_COMM_HEAD_HEAD_S 0
drivers/net/ethernet/intel/ice/ice_txrx.h +1 -0
@@ -406,6 +406,7 @@ struct ice_tx_ring {#define ICE_TX_FLAGS_RING_VLAN_L2TAG2 BIT(2)u8 flags;u8 dcb_tc;/* Traffic class of ring */ +u16 quanta_prof_id; }____cacheline_internodealigned_in_smp ;static inline bool ice_ring_uses_build_skb (struct ice_rx_ring *ring)
drivers/net/ethernet/intel/ice/ice_type.h +1 -0
@@ -903,6 +903,7 @@ struct ice_hw {u8 revision_id;u8 pf_id;/* device profile info */ +u8 logical_pf_id;u16 max_burst_size;/* driver sets this value */
drivers/net/ethernet/intel/ice/ice_vf_lib.h +8 -0
@@ -52,6 +52,13 @@ struct ice_mdd_vf_events {u16 last_printed; }; +struct ice_vf_qs_bw { +u32 committed; +u32 peak; +u16 queue_id; +u8 tc; +}; +/* VF operations */ struct ice_vf_ops {enum ice_disq_rst_src reset_type;
@@ -132,6 +139,7 @@ struct ice_vf {struct devlink_port devlink_port;u16 num_msix;/* num of MSI-X configured on this VF */ +struct ice_vf_qs_bw qs_bw[ICE_MAX_RSS_QS_PER_VF ]; };/* Flags for controlling behavior of ice_reset_vf */
drivers/net/ethernet/intel/ice/ice_virtchnl.c +333 -0
363 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_virtchnl.h +11 -0
@@ -13,6 +13,13 @@/* Restrict number of MAC Addr and VLAN that non-trusted VF can programmed */ #define ICE_MAX_VLAN_PER_VF 8 +#define ICE_DFLT_QUANTA 1024 +#define ICE_MAX_QUANTA_SIZE 4096 +#define ICE_MIN_QUANTA_SIZE 256 + +#define calc_quanta_desc (x) \ + max_t(u16, 12, min_t(u16, 63, (((x) + 66) / 132) * 2 + 4)) +/* MAC filters: 1 is reserved for the VF's default/perm_addr/LAA MAC, 1 for * broadcast, and 16 for additional unicast/multicast filters */
@@ -61,6 +68,10 @@ struct ice_virtchnl_ops {int (*dis_vlan_stripping_v2_msg)(struct ice_vf *vf,u8 *msg);int (*ena_vlan_insertion_v2_msg)(struct ice_vf *vf,u8 *msg);int (*dis_vlan_insertion_v2_msg)(struct ice_vf *vf,u8 *msg); +int (*get_qos_caps)(struct ice_vf *vf); +int (*cfg_q_tc_map)(struct ice_vf *vf,u8 *msg); +int (*cfg_q_bw)(struct ice_vf *vf,u8 *msg); +int (*cfg_q_quanta)(struct ice_vf *vf,u8 *msg); };#ifdef CONFIG_PCI_IOV
drivers/net/ethernet/intel/ice/ice_virtchnl_allowlist.c +6 -0
@@ -84,6 +84,11 @@ static const u32 fdir_pf_allowlist_opcodes[] = { VIRTCHNL_OP_ADD_FDIR_FILTER, VIRTCHNL_OP_DEL_FDIR_FILTER, }; +static const u32 tc_allowlist_opcodes[] = { +VIRTCHNL_OP_GET_QOS_CAPS ,VIRTCHNL_OP_CONFIG_QUEUE_BW , +VIRTCHNL_OP_CONFIG_QUANTA , +}; +struct allowlist_opcode_info {const u32 *opcodes;size_t size;
@@ -104,6 +109,7 @@ static const struct allowlist_opcode_info allowlist_opcodes[] = {ALLOW_ITEM (VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF , adv_rss_pf_allowlist_opcodes),ALLOW_ITEM (VIRTCHNL_VF_OFFLOAD_FDIR_PF , fdir_pf_allowlist_opcodes),ALLOW_ITEM (VIRTCHNL_VF_OFFLOAD_VLAN_V2 , vlan_v2_allowlist_opcodes), + ALLOW_ITEM(VIRTCHNL_VF_OFFLOAD_QOS, tc_allowlist_opcodes), };/**
Signature · 1 line
2.45.2
Paolo Abeni
maintainerPATCH v3 11/12 iavf: Add net_shaper_ops support
In reply to Paolo AbeniFrom: Sudheer Mogilappagari <[email protected]>
Implement net_shaper_ops support for IAVF. This enables configuration of rate limiting on per queue basis. Customer intends to enforce bandwidth limit on Tx traffic steered to the queue by configuring rate limits on the queue.
To set rate limiting for a queue, update shaper object of given queues in driver and send VIRTCHNL_OP_CONFIG_QUEUE_BW to PF to update HW configuration.
Deleting shaper configured for queue is nothing but configuring shaper with bw_max 0. The PF restores the default rate limiting config when bw_max is zero.
--- drivers/net/ethernet/intel/Kconfig | 1 + drivers/net/ethernet/intel/iavf/iavf.h | 3 + drivers/net/ethernet/intel/iavf/iavf_main.c | 171 ++++++++++++++++++ drivers/net/ethernet/intel/iavf/iavf_txrx.h | 2 + .../net/ethernet/intel/iavf/iavf_virtchnl.c | 65 +++++++ 5 files changed, 242 insertions(+)
drivers/net/ethernet/intel/Kconfig +1 -0
@@ -258,6 +258,7 @@ config I40E_DCB config IAVF tristate select LIBIE + select NET_SHAPER config I40EVF tristate "Intel(R) Ethernet Adaptive Virtual Function support"
drivers/net/ethernet/intel/iavf/iavf.h +3 -0
@@ -33,6 +33,7 @@#include <net/udp.h> #include <net/tc_act/tc_gact.h> #include <net/tc_act/tc_mirred.h> +#include <net/net_shaper.h> #include "iavf_type.h" #include <linux/avf/virtchnl.h>
@@ -335,6 +336,7 @@ struct iavf_adapter {#define IAVF_FLAG_AQ_DISABLE_CTAG_VLAN_INSERTION BIT_ULL(36)#define IAVF_FLAG_AQ_ENABLE_STAG_VLAN_INSERTION BIT_ULL(37)#define IAVF_FLAG_AQ_DISABLE_STAG_VLAN_INSERTION BIT_ULL(38) +#define IAVF_FLAG_AQ_CONFIGURE_QUEUES_BW BIT_ULL(39)/* flags for processing extended capability messages during * __IAVF_INIT_EXTENDED_CAPS. Each capability exchange requires
@@ -551,6 +553,7 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,int iavf_config_rss (struct iavf_adapter *adapter);int iavf_lan_add_device (struct iavf_adapter *adapter);int iavf_lan_del_device (struct iavf_adapter *adapter); +void iavf_cfg_queues_bw (struct iavf_adapter *adapter);void iavf_enable_channels (struct iavf_adapter *adapter);void iavf_disable_channels (struct iavf_adapter *adapter);void iavf_add_cloud_filter (struct iavf_adapter *adapter);
drivers/net/ethernet/intel/iavf/iavf_main.c +171 -0
201 lines not on this page · raw message
drivers/net/ethernet/intel/iavf/iavf_txrx.h +2 -0
@@ -296,6 +296,8 @@ struct iavf_ring {*/ u32 rx_buf_len; +struct net_shaper_info q_shaper; +bool q_shaper_update; }____cacheline_internodealigned_in_smp ;#define IAVF_ITR_ADAPTIVE_MIN_INC 0x0002
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +65 -0
83 lines not on this page · raw message
Signature · 1 line
2.45.2
Paolo Abeni
maintainerPATCH v3 12/12 iavf: add support to exchange qos capabilities
In reply to Paolo AbeniFrom: Sudheer Mogilappagari <[email protected]>
During driver initialization VF determines QOS capability is allowed by PF and receives QOS parameters. After which quanta size for queues is configured which is not configurable and is set to 1KB currently.
--- drivers/net/ethernet/intel/iavf/iavf.h | 10 ++ drivers/net/ethernet/intel/iavf/iavf_main.c | 46 +++++++++- .../net/ethernet/intel/iavf/iavf_virtchnl.c | 92 ++++++++++++++++++- 3 files changed, 145 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/iavf/iavf.h +10 -0
@@ -250,6 +250,9 @@ struct iavf_cloud_filter {#define IAVF_RESET_WAIT_DETECTED_COUNT 500#define IAVF_RESET_WAIT_COMPLETE_COUNT 2000 +#define IAVF_MAX_QOS_TC_NUM 8 +#define IAVF_DEFAULT_QUANTA_SIZE 1024 +/* board specific private data structure */ struct iavf_adapter {struct workqueue_struct *wq;
@@ -337,6 +340,8 @@ struct iavf_adapter {#define IAVF_FLAG_AQ_ENABLE_STAG_VLAN_INSERTION BIT_ULL(37)#define IAVF_FLAG_AQ_DISABLE_STAG_VLAN_INSERTION BIT_ULL(38)#define IAVF_FLAG_AQ_CONFIGURE_QUEUES_BW BIT_ULL(39) +#define IAVF_FLAG_AQ_CFG_QUEUES_QUANTA_SIZE BIT_ULL(40) +#define IAVF_FLAG_AQ_GET_QOS_CAPS BIT_ULL(41)/* flags for processing extended capability messages during * __IAVF_INIT_EXTENDED_CAPS. Each capability exchange requires
@@ -407,6 +412,8 @@ struct iavf_adapter { VIRTCHNL_VF_OFFLOAD_FDIR_PF)#define ADV_RSS_SUPPORT (_a) ((_a)->vf_res->vf_cap_flags & \ VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF) +#define QOS_ALLOWED (_a) ((_a)->vf_res->vf_cap_flags & \ + VIRTCHNL_VF_OFFLOAD_QOS)struct virtchnl_vf_resource *vf_res;/* incl. all VSIs */ struct virtchnl_vsi_resource *vsi_res;/* our LAN VSI */ struct virtchnl_version_info pf_version;
@@ -415,6 +422,7 @@ struct iavf_adapter {struct virtchnl_vlan_caps vlan_v2_caps;u16 msg_enable;struct iavf_eth_stats current_stats; +struct virtchnl_qos_cap_list *qos_caps;struct iavf_vsi vsi;u32 aq_wait_count;/* RSS stuff */
@@ -554,6 +562,8 @@ int iavf_config_rss(struct iavf_adapter *adapter);int iavf_lan_add_device (struct iavf_adapter *adapter);int iavf_lan_del_device (struct iavf_adapter *adapter);void iavf_cfg_queues_bw (struct iavf_adapter *adapter); +void iavf_cfg_queues_quanta_size (struct iavf_adapter *adapter); +void iavf_get_qos_caps (struct iavf_adapter *adapter);void iavf_enable_channels (struct iavf_adapter *adapter);void iavf_disable_channels (struct iavf_adapter *adapter);void iavf_add_cloud_filter (struct iavf_adapter *adapter);
drivers/net/ethernet/intel/iavf/iavf_main.c +44 -2
82 lines not on this page · raw message
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +91 -1
116 lines not on this page · raw message
Signature · 1 line
2.45.2
Quoted 26 lines · Tue, Jul 30, 2024 at 10:39:43PM CEST, [email protected] wrote:
We have a plurality of shaping-related drivers API, but none flexible enough to meet existing demand from vendors[1].
This series introduces new device APIs to configure in a flexible way TX H/W shaping. The new functionalities are exposed via a newly defined generic netlink interface and include introspection capabilities. Some self-tests are included, on top of a dummy netdevsim implementation, and a basic implementation for the iavf driver.
Some usage examples:
* Configure shaping on a given queue:
./tools/net/ynl/cli.py --spec Documentation/netlink/specs/shaper.yaml \ --do set --json '{"ifindex":'$IFINDEX', "shaper": {"handle": {"scope": "queue", "id":'$QUEUEID' }, "bw-max": 2000000 }}'* Container B/W sharing
The orchestration infrastructure wants to group the container-related queues under a RR scheduling and limit the aggregate bandwidth:
Quoted 11 lines
./tools/net/ynl/cli.py --spec Documentation/netlink/specs/shaper.yaml \
--do group --json '{"ifindex":'$IFINDEX',
"inputs": [
{"handle": {"scope": "queue", "id":'$QID1' },
"weight": '$W1'},
{"handle": {"scope": "queue", "id":'$QID2' },
"weight": '$W2'}],
{"handle": {"scope": "queue", "id":'$QID3' },
"weight": '$W3'}],
"output": { "handle": {"scope":"netdev"},
"output": { "handle": {"scope":"netdev"},I got here and got lost :) What's "input" and "output" meaning here?
In general, I'm missing some documentation file to describe the design of the shapers. I lookes at the patch descriptions and comments, could not figure it out :/ Could you please draft it?
Quoted 124 lines
"bw-max": 10000000}}'{'handle': {'id': 0, 'scope': 'netdev'}}
* Delegation
A container wants to set a B/W limit on 2 of its own queues:
./tools/net/ynl/cli.py --spec Documentation/netlink/specs/shaper.yaml \ --do group --json '{"ifindex":'$IFINDEX', "inputs": [ {"handle": {"scope": "queue", "id":'$QID1' }, "weight": '$W1'}, {"handle": {"scope": "queue", "id":'$QID2' }, "weight": '$W2'}], "output": { "handle": {"scope":"detached"}, "bw-max": 5000000}}'{'handle': {'id': 0, 'scope': 'detached'}}
* Cleanup:
Deleting a single queue shaper:
./tools/net/ynl/cli.py --spec Documentation/netlink/specs/shaper.yaml \ --do delete --json \ '{"ifindex":'$IFINDEX', "handle": {"scope": "queue", "id":'$QID1' }}'deleting the last shaper under a group deletes the group, too:
./tools/net/ynl/cli.py --spec Documentation/netlink/specs/shaper.yaml \ --do delete --json \ '{"ifindex":'$IFINDEX', "handle": {"scope": "queue", "id":'$QID2' }}' ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/shaper.yaml \ --do get --json '{"ifindex":'$IF', "handle": { "scope": "detached", "id": 0}}' Netlink error: Invalid argument nl_len = 80 (64) nl_flags = 0x300 nl_type = 2 error: -22 extack: {'msg': "Can't find shaper for handle 10000000"}Changes from RFC v2:
- added patch 1
- fixed deprecated API usageRFC v2: https://lore.kernel.org/netdev/[email protected]/
Changes from RFC v1:
-set()anddelete()ops operate on a single shaper
- addedgroup()op to allow grouping and nesting
- split the NL implementation into multiple patches to help reviewingRFC v1: https://lore.kernel.org/netdev/[email protected]/
[1] https://lore.kernel.org/netdev/[email protected]/
Paolo Abeni (8):
tools: ynl: lift an assumption about spec file name
netlink: spec: add shaper YAML spec
net-shapers: implement NL get operation
net-shapers: implement NL set and delete operations
net-shapers: implement NL group operation
netlink: spec: add shaper introspection support
net: shaper: implement introspection support
testing: net-drv: add basic shaper testSudheer Mogilappagari (2):
iavf: Addnet_shaper_opssupport
iavf: add support to exchange qos capabilitiesWenjun Wu (2):
virtchnl: support queue rate limit and quanta size configuration
ice: Support VF queue rate limit and quanta size configurationDocumentation/netlink/specs/shaper.yaml | 337 ++++++ Documentation/networking/kapi.rst | 3 + MAINTAINERS | 1 + drivers/net/Kconfig | 1 + drivers/net/ethernet/intel/Kconfig | 1 + drivers/net/ethernet/intel/iavf/iavf.h | 13 + drivers/net/ethernet/intel/iavf/iavf_main.c | 215 +++- drivers/net/ethernet/intel/iavf/iavf_txrx.h | 2 + .../net/ethernet/intel/iavf/iavf_virtchnl.c | 157 ++- drivers/net/ethernet/intel/ice/ice.h | 2 + drivers/net/ethernet/intel/ice/ice_base.c | 2 + drivers/net/ethernet/intel/ice/ice_common.c | 21 + .../net/ethernet/intel/ice/ice_hw_autogen.h | 8 + drivers/net/ethernet/intel/ice/ice_txrx.h | 1 + drivers/net/ethernet/intel/ice/ice_type.h | 1 + drivers/net/ethernet/intel/ice/ice_vf_lib.h | 8 + drivers/net/ethernet/intel/ice/ice_virtchnl.c | 333 ++++++ drivers/net/ethernet/intel/ice/ice_virtchnl.h | 11 + .../intel/ice/ice_virtchnl_allowlist.c | 6 + drivers/net/netdevsim/netdev.c | 37 + include/linux/avf/virtchnl.h | 119 +++ include/linux/netdevice.h | 17 + include/net/net_shaper.h | 169 +++ include/uapi/linux/net_shaper.h | 91 ++ net/Kconfig | 3 + net/Makefile | 1 + net/core/dev.c | 2 + net/core/dev.h | 6 + net/shaper/Makefile | 9 + net/shaper/shaper.c | 963 ++++++++++++++++++ net/shaper/shaper_nl_gen.c | 142 +++ net/shaper/shaper_nl_gen.h | 30 + tools/net/ynl/ynl-gen-c.py | 6 +- tools/testing/selftests/drivers/net/Makefile | 1 + tools/testing/selftests/drivers/net/shaper.py | 267 +++++ .../testing/selftests/net/lib/py/__init__.py | 1 + tools/testing/selftests/net/lib/py/ynl.py | 5 + 37 files changed, 2988 insertions(+), 4 deletions(-)create mode 100644
Documentation/netlink/specs/shaper.yamlcreate mode 100644include/net/net_shaper.h
create mode 100644include/uapi/linux/net_shaper.hcreate mode 100644net/shaper/Makefile
create mode 100644net/shaper/shaper.c
create mode 100644net/shaper/shaper_nl_gen.c
create mode 100644net/shaper/shaper_nl_gen.h
create mode 100755tools/testing/selftests/drivers/net/shaper.pySignature · 1 line
2.45.2