Skip to content

Commit a714b6b

Browse files
committed
netlink: spec: add shaper introspection support
JIRA: https://issues.redhat.com/browse/RHEL-89973 commit 14bba92 Author: Paolo Abeni <pabeni@redhat.com> Date: Wed Oct 9 10:09:54 2024 +0200 netlink: spec: add shaper introspection support Allow the user-space to fine-grain query the shaping features supported by the NIC on each domain. Reviewed-by: Jiri Pirko <jiri@nvidia.com> Reviewed-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Link: https://patch.msgid.link/3ddd10e450e3fe7d4b944c0d0b886d4483529ee6.1728460186.git.pabeni@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
1 parent cc61d20 commit a714b6b

File tree

5 files changed

+176
-0
lines changed

5 files changed

+176
-0
lines changed

Documentation/netlink/specs/net_shaper.yaml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ doc: |
2626
2727
The user can query the running configuration via the @get operation.
2828
29+
Different devices can provide different feature sets, e.g. with no
30+
support for complex scheduling hierarchy, or for some shaping
31+
parameters. The user can introspect the HW capabilities via the
32+
@cap-get operation.
33+
2934
definitions:
3035
-
3136
type: enum
@@ -148,6 +153,53 @@ attribute-sets:
148153
name: priority
149154
-
150155
name: weight
156+
-
157+
name: caps
158+
attributes:
159+
-
160+
name: ifindex
161+
type: u32
162+
doc: Interface index queried for shapers capabilities.
163+
-
164+
name: scope
165+
type: u32
166+
enum: scope
167+
doc: The scope to which the queried capabilities apply.
168+
-
169+
name: support-metric-bps
170+
type: flag
171+
doc: The device accepts 'bps' metric for bw-min, bw-max and burst.
172+
-
173+
name: support-metric-pps
174+
type: flag
175+
doc: The device accepts 'pps' metric for bw-min, bw-max and burst.
176+
-
177+
name: support-nesting
178+
type: flag
179+
doc: |
180+
The device supports nesting shaper belonging to this scope
181+
below 'node' scoped shapers. Only 'queue' and 'node'
182+
scope can have flag 'support-nesting'.
183+
-
184+
name: support-bw-min
185+
type: flag
186+
doc: The device supports a minimum guaranteed B/W.
187+
-
188+
name: support-bw-max
189+
type: flag
190+
doc: The device supports maximum B/W shaping.
191+
-
192+
name: support-burst
193+
type: flag
194+
doc: The device supports a maximum burst size.
195+
-
196+
name: support-priority
197+
type: flag
198+
doc: The device supports priority scheduling.
199+
-
200+
name: support-weight
201+
type: flag
202+
doc: The device supports weighted round robin scheduling.
151203

152204
operations:
153205
list:
@@ -272,3 +324,39 @@ operations:
272324
- leaves
273325
reply:
274326
attributes: *ns-binding
327+
328+
-
329+
name: cap-get
330+
doc: |
331+
Get the shaper capabilities supported by the given device
332+
for the specified scope.
333+
attribute-set: caps
334+
335+
do:
336+
pre: net-shaper-nl-cap-pre-doit
337+
post: net-shaper-nl-cap-post-doit
338+
request:
339+
attributes:
340+
- ifindex
341+
- scope
342+
reply:
343+
attributes: &cap-attrs
344+
- ifindex
345+
- scope
346+
- support-metric-bps
347+
- support-metric-pps
348+
- support-nesting
349+
- support-bw-min
350+
- support-bw-max
351+
- support-burst
352+
- support-priority
353+
- support-weight
354+
355+
dump:
356+
pre: net-shaper-nl-cap-pre-dumpit
357+
post: net-shaper-nl-cap-post-dumpit
358+
request:
359+
attributes:
360+
- ifindex
361+
reply:
362+
attributes: *cap-attrs

include/uapi/linux/net_shaper.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,28 @@ enum {
6565
NET_SHAPER_A_HANDLE_MAX = (__NET_SHAPER_A_HANDLE_MAX - 1)
6666
};
6767

68+
enum {
69+
NET_SHAPER_A_CAPS_IFINDEX = 1,
70+
NET_SHAPER_A_CAPS_SCOPE,
71+
NET_SHAPER_A_CAPS_SUPPORT_METRIC_BPS,
72+
NET_SHAPER_A_CAPS_SUPPORT_METRIC_PPS,
73+
NET_SHAPER_A_CAPS_SUPPORT_NESTING,
74+
NET_SHAPER_A_CAPS_SUPPORT_BW_MIN,
75+
NET_SHAPER_A_CAPS_SUPPORT_BW_MAX,
76+
NET_SHAPER_A_CAPS_SUPPORT_BURST,
77+
NET_SHAPER_A_CAPS_SUPPORT_PRIORITY,
78+
NET_SHAPER_A_CAPS_SUPPORT_WEIGHT,
79+
80+
__NET_SHAPER_A_CAPS_MAX,
81+
NET_SHAPER_A_CAPS_MAX = (__NET_SHAPER_A_CAPS_MAX - 1)
82+
};
83+
6884
enum {
6985
NET_SHAPER_CMD_GET = 1,
7086
NET_SHAPER_CMD_SET,
7187
NET_SHAPER_CMD_DELETE,
7288
NET_SHAPER_CMD_GROUP,
89+
NET_SHAPER_CMD_CAP_GET,
7390

7491
__NET_SHAPER_CMD_MAX,
7592
NET_SHAPER_CMD_MAX = (__NET_SHAPER_CMD_MAX - 1)

net/shaper/shaper.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,27 @@ int net_shaper_nl_post_dumpit(struct netlink_callback *cb)
598598
return 0;
599599
}
600600

601+
int net_shaper_nl_cap_pre_doit(const struct genl_split_ops *ops,
602+
struct sk_buff *skb, struct genl_info *info)
603+
{
604+
return -EOPNOTSUPP;
605+
}
606+
607+
void net_shaper_nl_cap_post_doit(const struct genl_split_ops *ops,
608+
struct sk_buff *skb, struct genl_info *info)
609+
{
610+
}
611+
612+
int net_shaper_nl_cap_pre_dumpit(struct netlink_callback *cb)
613+
{
614+
return -EOPNOTSUPP;
615+
}
616+
617+
int net_shaper_nl_cap_post_dumpit(struct netlink_callback *cb)
618+
{
619+
return -EOPNOTSUPP;
620+
}
621+
601622
int net_shaper_nl_get_doit(struct sk_buff *skb, struct genl_info *info)
602623
{
603624
struct net_shaper_binding *binding;
@@ -1126,6 +1147,17 @@ int net_shaper_nl_group_doit(struct sk_buff *skb, struct genl_info *info)
11261147
goto free_leaves;
11271148
}
11281149

1150+
int net_shaper_nl_cap_get_doit(struct sk_buff *skb, struct genl_info *info)
1151+
{
1152+
return 0;
1153+
}
1154+
1155+
int net_shaper_nl_cap_get_dumpit(struct sk_buff *skb,
1156+
struct netlink_callback *cb)
1157+
{
1158+
return 0;
1159+
}
1160+
11291161
static void net_shaper_flush(struct net_shaper_binding *binding)
11301162
{
11311163
struct net_shaper_hierarchy *hierarchy = net_shaper_hierarchy(binding);

net/shaper/shaper_nl_gen.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ static const struct nla_policy net_shaper_group_nl_policy[NET_SHAPER_A_LEAVES +
6565
[NET_SHAPER_A_LEAVES] = NLA_POLICY_NESTED(net_shaper_leaf_info_nl_policy),
6666
};
6767

68+
/* NET_SHAPER_CMD_CAP_GET - do */
69+
static const struct nla_policy net_shaper_cap_get_do_nl_policy[NET_SHAPER_A_CAPS_SCOPE + 1] = {
70+
[NET_SHAPER_A_CAPS_IFINDEX] = { .type = NLA_U32, },
71+
[NET_SHAPER_A_CAPS_SCOPE] = NLA_POLICY_MAX(NLA_U32, 3),
72+
};
73+
74+
/* NET_SHAPER_CMD_CAP_GET - dump */
75+
static const struct nla_policy net_shaper_cap_get_dump_nl_policy[NET_SHAPER_A_CAPS_IFINDEX + 1] = {
76+
[NET_SHAPER_A_CAPS_IFINDEX] = { .type = NLA_U32, },
77+
};
78+
6879
/* Ops table for net_shaper */
6980
static const struct genl_split_ops net_shaper_nl_ops[] = {
7081
{
@@ -112,6 +123,24 @@ static const struct genl_split_ops net_shaper_nl_ops[] = {
112123
.maxattr = NET_SHAPER_A_LEAVES,
113124
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
114125
},
126+
{
127+
.cmd = NET_SHAPER_CMD_CAP_GET,
128+
.pre_doit = net_shaper_nl_cap_pre_doit,
129+
.doit = net_shaper_nl_cap_get_doit,
130+
.post_doit = net_shaper_nl_cap_post_doit,
131+
.policy = net_shaper_cap_get_do_nl_policy,
132+
.maxattr = NET_SHAPER_A_CAPS_SCOPE,
133+
.flags = GENL_CMD_CAP_DO,
134+
},
135+
{
136+
.cmd = NET_SHAPER_CMD_CAP_GET,
137+
.start = net_shaper_nl_cap_pre_dumpit,
138+
.dumpit = net_shaper_nl_cap_get_dumpit,
139+
.done = net_shaper_nl_cap_post_dumpit,
140+
.policy = net_shaper_cap_get_dump_nl_policy,
141+
.maxattr = NET_SHAPER_A_CAPS_IFINDEX,
142+
.flags = GENL_CMD_CAP_DUMP,
143+
},
115144
};
116145

117146
struct genl_family net_shaper_nl_family __ro_after_init = {

net/shaper/shaper_nl_gen.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,27 @@ extern const struct nla_policy net_shaper_leaf_info_nl_policy[NET_SHAPER_A_WEIGH
1717

1818
int net_shaper_nl_pre_doit(const struct genl_split_ops *ops,
1919
struct sk_buff *skb, struct genl_info *info);
20+
int net_shaper_nl_cap_pre_doit(const struct genl_split_ops *ops,
21+
struct sk_buff *skb, struct genl_info *info);
2022
void
2123
net_shaper_nl_post_doit(const struct genl_split_ops *ops, struct sk_buff *skb,
2224
struct genl_info *info);
25+
void
26+
net_shaper_nl_cap_post_doit(const struct genl_split_ops *ops,
27+
struct sk_buff *skb, struct genl_info *info);
2328
int net_shaper_nl_pre_dumpit(struct netlink_callback *cb);
29+
int net_shaper_nl_cap_pre_dumpit(struct netlink_callback *cb);
2430
int net_shaper_nl_post_dumpit(struct netlink_callback *cb);
31+
int net_shaper_nl_cap_post_dumpit(struct netlink_callback *cb);
2532

2633
int net_shaper_nl_get_doit(struct sk_buff *skb, struct genl_info *info);
2734
int net_shaper_nl_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb);
2835
int net_shaper_nl_set_doit(struct sk_buff *skb, struct genl_info *info);
2936
int net_shaper_nl_delete_doit(struct sk_buff *skb, struct genl_info *info);
3037
int net_shaper_nl_group_doit(struct sk_buff *skb, struct genl_info *info);
38+
int net_shaper_nl_cap_get_doit(struct sk_buff *skb, struct genl_info *info);
39+
int net_shaper_nl_cap_get_dumpit(struct sk_buff *skb,
40+
struct netlink_callback *cb);
3141

3242
extern struct genl_family net_shaper_nl_family;
3343

0 commit comments

Comments
 (0)