xref: /linux/net/shaper/shaper_nl_gen.c (revision c8b90d40d5bba8e6fba457b8a7c10d3c0d467e37)
1 // SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
2 /* Do not edit directly, auto-generated from: */
3 /*	Documentation/netlink/specs/net_shaper.yaml */
4 /* YNL-GEN kernel source */
5 
6 #include <net/netlink.h>
7 #include <net/genetlink.h>
8 
9 #include "shaper_nl_gen.h"
10 
11 #include <uapi/linux/net_shaper.h>
12 
13 /* Common nested types */
14 const struct nla_policy net_shaper_handle_nl_policy[NET_SHAPER_A_HANDLE_ID + 1] = {
15 	[NET_SHAPER_A_HANDLE_SCOPE] = NLA_POLICY_MAX(NLA_U32, 3),
16 	[NET_SHAPER_A_HANDLE_ID] = { .type = NLA_U32, },
17 };
18 
19 const struct nla_policy net_shaper_leaf_info_nl_policy[NET_SHAPER_A_WEIGHT + 1] = {
20 	[NET_SHAPER_A_HANDLE] = NLA_POLICY_NESTED(net_shaper_handle_nl_policy),
21 	[NET_SHAPER_A_PRIORITY] = { .type = NLA_U32, },
22 	[NET_SHAPER_A_WEIGHT] = { .type = NLA_U32, },
23 };
24 
25 /* NET_SHAPER_CMD_GET - do */
26 static const struct nla_policy net_shaper_get_do_nl_policy[NET_SHAPER_A_IFINDEX + 1] = {
27 	[NET_SHAPER_A_IFINDEX] = { .type = NLA_U32, },
28 	[NET_SHAPER_A_HANDLE] = NLA_POLICY_NESTED(net_shaper_handle_nl_policy),
29 };
30 
31 /* NET_SHAPER_CMD_GET - dump */
32 static const struct nla_policy net_shaper_get_dump_nl_policy[NET_SHAPER_A_IFINDEX + 1] = {
33 	[NET_SHAPER_A_IFINDEX] = { .type = NLA_U32, },
34 };
35 
36 /* NET_SHAPER_CMD_SET - do */
37 static const struct nla_policy net_shaper_set_nl_policy[NET_SHAPER_A_IFINDEX + 1] = {
38 	[NET_SHAPER_A_IFINDEX] = { .type = NLA_U32, },
39 	[NET_SHAPER_A_HANDLE] = NLA_POLICY_NESTED(net_shaper_handle_nl_policy),
40 	[NET_SHAPER_A_METRIC] = NLA_POLICY_MAX(NLA_U32, 1),
41 	[NET_SHAPER_A_BW_MIN] = { .type = NLA_UINT, },
42 	[NET_SHAPER_A_BW_MAX] = { .type = NLA_UINT, },
43 	[NET_SHAPER_A_BURST] = { .type = NLA_UINT, },
44 	[NET_SHAPER_A_PRIORITY] = { .type = NLA_U32, },
45 	[NET_SHAPER_A_WEIGHT] = { .type = NLA_U32, },
46 };
47 
48 /* NET_SHAPER_CMD_DELETE - do */
49 static const struct nla_policy net_shaper_delete_nl_policy[NET_SHAPER_A_IFINDEX + 1] = {
50 	[NET_SHAPER_A_IFINDEX] = { .type = NLA_U32, },
51 	[NET_SHAPER_A_HANDLE] = NLA_POLICY_NESTED(net_shaper_handle_nl_policy),
52 };
53 
54 /* NET_SHAPER_CMD_GROUP - do */
55 static const struct nla_policy net_shaper_group_nl_policy[NET_SHAPER_A_LEAVES + 1] = {
56 	[NET_SHAPER_A_IFINDEX] = { .type = NLA_U32, },
57 	[NET_SHAPER_A_PARENT] = NLA_POLICY_NESTED(net_shaper_handle_nl_policy),
58 	[NET_SHAPER_A_HANDLE] = NLA_POLICY_NESTED(net_shaper_handle_nl_policy),
59 	[NET_SHAPER_A_METRIC] = NLA_POLICY_MAX(NLA_U32, 1),
60 	[NET_SHAPER_A_BW_MIN] = { .type = NLA_UINT, },
61 	[NET_SHAPER_A_BW_MAX] = { .type = NLA_UINT, },
62 	[NET_SHAPER_A_BURST] = { .type = NLA_UINT, },
63 	[NET_SHAPER_A_PRIORITY] = { .type = NLA_U32, },
64 	[NET_SHAPER_A_WEIGHT] = { .type = NLA_U32, },
65 	[NET_SHAPER_A_LEAVES] = NLA_POLICY_NESTED(net_shaper_leaf_info_nl_policy),
66 };
67 
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 
79 /* Ops table for net_shaper */
80 static const struct genl_split_ops net_shaper_nl_ops[] = {
81 	{
82 		.cmd		= NET_SHAPER_CMD_GET,
83 		.pre_doit	= net_shaper_nl_pre_doit,
84 		.doit		= net_shaper_nl_get_doit,
85 		.post_doit	= net_shaper_nl_post_doit,
86 		.policy		= net_shaper_get_do_nl_policy,
87 		.maxattr	= NET_SHAPER_A_IFINDEX,
88 		.flags		= GENL_CMD_CAP_DO,
89 	},
90 	{
91 		.cmd		= NET_SHAPER_CMD_GET,
92 		.start		= net_shaper_nl_pre_dumpit,
93 		.dumpit		= net_shaper_nl_get_dumpit,
94 		.done		= net_shaper_nl_post_dumpit,
95 		.policy		= net_shaper_get_dump_nl_policy,
96 		.maxattr	= NET_SHAPER_A_IFINDEX,
97 		.flags		= GENL_CMD_CAP_DUMP,
98 	},
99 	{
100 		.cmd		= NET_SHAPER_CMD_SET,
101 		.pre_doit	= net_shaper_nl_pre_doit,
102 		.doit		= net_shaper_nl_set_doit,
103 		.post_doit	= net_shaper_nl_post_doit,
104 		.policy		= net_shaper_set_nl_policy,
105 		.maxattr	= NET_SHAPER_A_IFINDEX,
106 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
107 	},
108 	{
109 		.cmd		= NET_SHAPER_CMD_DELETE,
110 		.pre_doit	= net_shaper_nl_pre_doit,
111 		.doit		= net_shaper_nl_delete_doit,
112 		.post_doit	= net_shaper_nl_post_doit,
113 		.policy		= net_shaper_delete_nl_policy,
114 		.maxattr	= NET_SHAPER_A_IFINDEX,
115 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
116 	},
117 	{
118 		.cmd		= NET_SHAPER_CMD_GROUP,
119 		.pre_doit	= net_shaper_nl_pre_doit,
120 		.doit		= net_shaper_nl_group_doit,
121 		.post_doit	= net_shaper_nl_post_doit,
122 		.policy		= net_shaper_group_nl_policy,
123 		.maxattr	= NET_SHAPER_A_LEAVES,
124 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
125 	},
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 	},
144 };
145 
146 struct genl_family net_shaper_nl_family __ro_after_init = {
147 	.name		= NET_SHAPER_FAMILY_NAME,
148 	.version	= NET_SHAPER_FAMILY_VERSION,
149 	.netnsok	= true,
150 	.parallel_ops	= true,
151 	.module		= THIS_MODULE,
152 	.split_ops	= net_shaper_nl_ops,
153 	.n_split_ops	= ARRAY_SIZE(net_shaper_nl_ops),
154 };
155