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