xref: /linux/net/core/netdev-genl-gen.c (revision 705c09bb3cdffb141986598ad4ff9c9b0a66c3bd)
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/netdev.yaml */
4 /* YNL-GEN kernel source */
5 
6 #include <net/netlink.h>
7 #include <net/genetlink.h>
8 
9 #include "netdev-genl-gen.h"
10 
11 #include <uapi/linux/netdev.h>
12 
13 /* Integer value ranges */
14 static const struct netlink_range_validation netdev_a_page_pool_id_range = {
15 	.min	= 1ULL,
16 	.max	= 4294967295ULL,
17 };
18 
19 static const struct netlink_range_validation netdev_a_page_pool_ifindex_range = {
20 	.min	= 1ULL,
21 	.max	= 2147483647ULL,
22 };
23 
24 /* Common nested types */
25 const struct nla_policy netdev_page_pool_info_nl_policy[NETDEV_A_PAGE_POOL_IFINDEX + 1] = {
26 	[NETDEV_A_PAGE_POOL_ID] = NLA_POLICY_FULL_RANGE(NLA_UINT, &netdev_a_page_pool_id_range),
27 	[NETDEV_A_PAGE_POOL_IFINDEX] = NLA_POLICY_FULL_RANGE(NLA_U32, &netdev_a_page_pool_ifindex_range),
28 };
29 
30 /* NETDEV_CMD_DEV_GET - do */
31 static const struct nla_policy netdev_dev_get_nl_policy[NETDEV_A_DEV_IFINDEX + 1] = {
32 	[NETDEV_A_DEV_IFINDEX] = NLA_POLICY_MIN(NLA_U32, 1),
33 };
34 
35 /* NETDEV_CMD_PAGE_POOL_GET - do */
36 #ifdef CONFIG_PAGE_POOL
37 static const struct nla_policy netdev_page_pool_get_nl_policy[NETDEV_A_PAGE_POOL_ID + 1] = {
38 	[NETDEV_A_PAGE_POOL_ID] = NLA_POLICY_FULL_RANGE(NLA_UINT, &netdev_a_page_pool_id_range),
39 };
40 #endif /* CONFIG_PAGE_POOL */
41 
42 /* NETDEV_CMD_PAGE_POOL_STATS_GET - do */
43 #ifdef CONFIG_PAGE_POOL_STATS
44 static const struct nla_policy netdev_page_pool_stats_get_nl_policy[NETDEV_A_PAGE_POOL_STATS_INFO + 1] = {
45 	[NETDEV_A_PAGE_POOL_STATS_INFO] = NLA_POLICY_NESTED(netdev_page_pool_info_nl_policy),
46 };
47 #endif /* CONFIG_PAGE_POOL_STATS */
48 
49 /* NETDEV_CMD_QUEUE_GET - do */
50 static const struct nla_policy netdev_queue_get_do_nl_policy[NETDEV_A_QUEUE_TYPE + 1] = {
51 	[NETDEV_A_QUEUE_IFINDEX] = NLA_POLICY_MIN(NLA_U32, 1),
52 	[NETDEV_A_QUEUE_TYPE] = NLA_POLICY_MAX(NLA_U32, 1),
53 	[NETDEV_A_QUEUE_ID] = { .type = NLA_U32, },
54 };
55 
56 /* NETDEV_CMD_QUEUE_GET - dump */
57 static const struct nla_policy netdev_queue_get_dump_nl_policy[NETDEV_A_QUEUE_IFINDEX + 1] = {
58 	[NETDEV_A_QUEUE_IFINDEX] = NLA_POLICY_MIN(NLA_U32, 1),
59 };
60 
61 /* NETDEV_CMD_NAPI_GET - do */
62 static const struct nla_policy netdev_napi_get_do_nl_policy[NETDEV_A_NAPI_ID + 1] = {
63 	[NETDEV_A_NAPI_ID] = { .type = NLA_U32, },
64 };
65 
66 /* NETDEV_CMD_NAPI_GET - dump */
67 static const struct nla_policy netdev_napi_get_dump_nl_policy[NETDEV_A_NAPI_IFINDEX + 1] = {
68 	[NETDEV_A_NAPI_IFINDEX] = NLA_POLICY_MIN(NLA_U32, 1),
69 };
70 
71 /* NETDEV_CMD_QSTATS_GET - dump */
72 static const struct nla_policy netdev_qstats_get_nl_policy[NETDEV_A_QSTATS_SCOPE + 1] = {
73 	[NETDEV_A_QSTATS_SCOPE] = NLA_POLICY_MASK(NLA_UINT, 0x1),
74 };
75 
76 /* Ops table for netdev */
77 static const struct genl_split_ops netdev_nl_ops[] = {
78 	{
79 		.cmd		= NETDEV_CMD_DEV_GET,
80 		.doit		= netdev_nl_dev_get_doit,
81 		.policy		= netdev_dev_get_nl_policy,
82 		.maxattr	= NETDEV_A_DEV_IFINDEX,
83 		.flags		= GENL_CMD_CAP_DO,
84 	},
85 	{
86 		.cmd	= NETDEV_CMD_DEV_GET,
87 		.dumpit	= netdev_nl_dev_get_dumpit,
88 		.flags	= GENL_CMD_CAP_DUMP,
89 	},
90 #ifdef CONFIG_PAGE_POOL
91 	{
92 		.cmd		= NETDEV_CMD_PAGE_POOL_GET,
93 		.doit		= netdev_nl_page_pool_get_doit,
94 		.policy		= netdev_page_pool_get_nl_policy,
95 		.maxattr	= NETDEV_A_PAGE_POOL_ID,
96 		.flags		= GENL_CMD_CAP_DO,
97 	},
98 	{
99 		.cmd	= NETDEV_CMD_PAGE_POOL_GET,
100 		.dumpit	= netdev_nl_page_pool_get_dumpit,
101 		.flags	= GENL_CMD_CAP_DUMP,
102 	},
103 #endif /* CONFIG_PAGE_POOL */
104 #ifdef CONFIG_PAGE_POOL_STATS
105 	{
106 		.cmd		= NETDEV_CMD_PAGE_POOL_STATS_GET,
107 		.doit		= netdev_nl_page_pool_stats_get_doit,
108 		.policy		= netdev_page_pool_stats_get_nl_policy,
109 		.maxattr	= NETDEV_A_PAGE_POOL_STATS_INFO,
110 		.flags		= GENL_CMD_CAP_DO,
111 	},
112 	{
113 		.cmd	= NETDEV_CMD_PAGE_POOL_STATS_GET,
114 		.dumpit	= netdev_nl_page_pool_stats_get_dumpit,
115 		.flags	= GENL_CMD_CAP_DUMP,
116 	},
117 #endif /* CONFIG_PAGE_POOL_STATS */
118 	{
119 		.cmd		= NETDEV_CMD_QUEUE_GET,
120 		.doit		= netdev_nl_queue_get_doit,
121 		.policy		= netdev_queue_get_do_nl_policy,
122 		.maxattr	= NETDEV_A_QUEUE_TYPE,
123 		.flags		= GENL_CMD_CAP_DO,
124 	},
125 	{
126 		.cmd		= NETDEV_CMD_QUEUE_GET,
127 		.dumpit		= netdev_nl_queue_get_dumpit,
128 		.policy		= netdev_queue_get_dump_nl_policy,
129 		.maxattr	= NETDEV_A_QUEUE_IFINDEX,
130 		.flags		= GENL_CMD_CAP_DUMP,
131 	},
132 	{
133 		.cmd		= NETDEV_CMD_NAPI_GET,
134 		.doit		= netdev_nl_napi_get_doit,
135 		.policy		= netdev_napi_get_do_nl_policy,
136 		.maxattr	= NETDEV_A_NAPI_ID,
137 		.flags		= GENL_CMD_CAP_DO,
138 	},
139 	{
140 		.cmd		= NETDEV_CMD_NAPI_GET,
141 		.dumpit		= netdev_nl_napi_get_dumpit,
142 		.policy		= netdev_napi_get_dump_nl_policy,
143 		.maxattr	= NETDEV_A_NAPI_IFINDEX,
144 		.flags		= GENL_CMD_CAP_DUMP,
145 	},
146 	{
147 		.cmd		= NETDEV_CMD_QSTATS_GET,
148 		.dumpit		= netdev_nl_qstats_get_dumpit,
149 		.policy		= netdev_qstats_get_nl_policy,
150 		.maxattr	= NETDEV_A_QSTATS_SCOPE,
151 		.flags		= GENL_CMD_CAP_DUMP,
152 	},
153 };
154 
155 static const struct genl_multicast_group netdev_nl_mcgrps[] = {
156 	[NETDEV_NLGRP_MGMT] = { "mgmt", },
157 	[NETDEV_NLGRP_PAGE_POOL] = { "page-pool", },
158 };
159 
160 struct genl_family netdev_nl_family __ro_after_init = {
161 	.name		= NETDEV_FAMILY_NAME,
162 	.version	= NETDEV_FAMILY_VERSION,
163 	.netnsok	= true,
164 	.parallel_ops	= true,
165 	.module		= THIS_MODULE,
166 	.split_ops	= netdev_nl_ops,
167 	.n_split_ops	= ARRAY_SIZE(netdev_nl_ops),
168 	.mcgrps		= netdev_nl_mcgrps,
169 	.n_mcgrps	= ARRAY_SIZE(netdev_nl_mcgrps),
170 };
171