xref: /linux/drivers/dpll/dpll_nl.c (revision e97ffa4e975c303979b54c7bae45a9ec937c5366)
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/dpll.yaml */
4 /* YNL-GEN kernel source */
5 /* To regenerate run: tools/net/ynl/ynl-regen.sh */
6 
7 #include <net/netlink.h>
8 #include <net/genetlink.h>
9 
10 #include "dpll_nl.h"
11 
12 #include <uapi/linux/dpll.h>
13 
14 /* Common nested types */
15 const struct nla_policy dpll_pin_parent_device_nl_policy[DPLL_A_PIN_OPERSTATE + 1] = {
16 	[DPLL_A_PIN_PARENT_ID] = { .type = NLA_U32, },
17 	[DPLL_A_PIN_DIRECTION] = NLA_POLICY_RANGE(NLA_U32, 1, 2),
18 	[DPLL_A_PIN_PRIO] = { .type = NLA_U32, },
19 	[DPLL_A_PIN_STATE] = NLA_POLICY_RANGE(NLA_U32, 1, 3),
20 	[DPLL_A_PIN_OPERSTATE] = NLA_POLICY_RANGE(NLA_U32, 1, 4),
21 	[DPLL_A_PIN_PHASE_OFFSET] = { .type = NLA_S64, },
22 };
23 
24 const struct nla_policy dpll_pin_parent_pin_nl_policy[DPLL_A_PIN_STATE + 1] = {
25 	[DPLL_A_PIN_PARENT_ID] = { .type = NLA_U32, },
26 	[DPLL_A_PIN_STATE] = NLA_POLICY_RANGE(NLA_U32, 1, 3),
27 };
28 
29 const struct nla_policy dpll_reference_sync_nl_policy[DPLL_A_PIN_STATE + 1] = {
30 	[DPLL_A_PIN_ID] = { .type = NLA_U32, },
31 	[DPLL_A_PIN_STATE] = NLA_POLICY_RANGE(NLA_U32, 1, 3),
32 };
33 
34 /* DPLL_CMD_DEVICE_ID_GET - do */
35 static const struct nla_policy dpll_device_id_get_nl_policy[DPLL_A_TYPE + 1] = {
36 	[DPLL_A_MODULE_NAME] = { .type = NLA_NUL_STRING, },
37 	[DPLL_A_CLOCK_ID] = { .type = NLA_U64, },
38 	[DPLL_A_TYPE] = NLA_POLICY_RANGE(NLA_U32, 1, 2),
39 };
40 
41 /* DPLL_CMD_DEVICE_GET - do */
42 static const struct nla_policy dpll_device_get_nl_policy[DPLL_A_ID + 1] = {
43 	[DPLL_A_ID] = { .type = NLA_U32, },
44 };
45 
46 /* DPLL_CMD_DEVICE_SET - do */
47 static const struct nla_policy dpll_device_set_nl_policy[DPLL_A_FREQUENCY_MONITOR + 1] = {
48 	[DPLL_A_ID] = { .type = NLA_U32, },
49 	[DPLL_A_MODE] = NLA_POLICY_RANGE(NLA_U32, 1, 2),
50 	[DPLL_A_PHASE_OFFSET_MONITOR] = NLA_POLICY_MAX(NLA_U32, 1),
51 	[DPLL_A_PHASE_OFFSET_AVG_FACTOR] = { .type = NLA_U32, },
52 	[DPLL_A_FREQUENCY_MONITOR] = NLA_POLICY_MAX(NLA_U32, 1),
53 };
54 
55 /* DPLL_CMD_PIN_ID_GET - do */
56 static const struct nla_policy dpll_pin_id_get_nl_policy[DPLL_A_PIN_TYPE + 1] = {
57 	[DPLL_A_PIN_MODULE_NAME] = { .type = NLA_NUL_STRING, },
58 	[DPLL_A_PIN_CLOCK_ID] = { .type = NLA_U64, },
59 	[DPLL_A_PIN_BOARD_LABEL] = { .type = NLA_NUL_STRING, },
60 	[DPLL_A_PIN_PANEL_LABEL] = { .type = NLA_NUL_STRING, },
61 	[DPLL_A_PIN_PACKAGE_LABEL] = { .type = NLA_NUL_STRING, },
62 	[DPLL_A_PIN_TYPE] = NLA_POLICY_RANGE(NLA_U32, 1, 5),
63 };
64 
65 /* DPLL_CMD_PIN_GET - do */
66 static const struct nla_policy dpll_pin_get_do_nl_policy[DPLL_A_PIN_ID + 1] = {
67 	[DPLL_A_PIN_ID] = { .type = NLA_U32, },
68 };
69 
70 /* DPLL_CMD_PIN_GET - dump */
71 static const struct nla_policy dpll_pin_get_dump_nl_policy[DPLL_A_PIN_ID + 1] = {
72 	[DPLL_A_PIN_ID] = { .type = NLA_U32, },
73 };
74 
75 /* DPLL_CMD_PIN_SET - do */
76 static const struct nla_policy dpll_pin_set_nl_policy[DPLL_A_PIN_REFERENCE_SYNC + 1] = {
77 	[DPLL_A_PIN_ID] = { .type = NLA_U32, },
78 	[DPLL_A_PIN_FREQUENCY] = { .type = NLA_U64, },
79 	[DPLL_A_PIN_DIRECTION] = NLA_POLICY_RANGE(NLA_U32, 1, 2),
80 	[DPLL_A_PIN_PRIO] = { .type = NLA_U32, },
81 	[DPLL_A_PIN_STATE] = NLA_POLICY_RANGE(NLA_U32, 1, 3),
82 	[DPLL_A_PIN_PARENT_DEVICE] = NLA_POLICY_NESTED(dpll_pin_parent_device_nl_policy),
83 	[DPLL_A_PIN_PARENT_PIN] = NLA_POLICY_NESTED(dpll_pin_parent_pin_nl_policy),
84 	[DPLL_A_PIN_PHASE_ADJUST] = { .type = NLA_S32, },
85 	[DPLL_A_PIN_ESYNC_FREQUENCY] = { .type = NLA_U64, },
86 	[DPLL_A_PIN_REFERENCE_SYNC] = NLA_POLICY_NESTED(dpll_reference_sync_nl_policy),
87 };
88 
89 /* Ops table for dpll */
90 static const struct genl_split_ops dpll_nl_ops[] = {
91 	{
92 		.cmd		= DPLL_CMD_DEVICE_ID_GET,
93 		.pre_doit	= dpll_lock_doit,
94 		.doit		= dpll_nl_device_id_get_doit,
95 		.post_doit	= dpll_unlock_doit,
96 		.policy		= dpll_device_id_get_nl_policy,
97 		.maxattr	= DPLL_A_TYPE,
98 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
99 	},
100 	{
101 		.cmd		= DPLL_CMD_DEVICE_GET,
102 		.pre_doit	= dpll_pre_doit,
103 		.doit		= dpll_nl_device_get_doit,
104 		.post_doit	= dpll_post_doit,
105 		.policy		= dpll_device_get_nl_policy,
106 		.maxattr	= DPLL_A_ID,
107 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
108 	},
109 	{
110 		.cmd	= DPLL_CMD_DEVICE_GET,
111 		.dumpit	= dpll_nl_device_get_dumpit,
112 		.flags	= GENL_ADMIN_PERM | GENL_CMD_CAP_DUMP,
113 	},
114 	{
115 		.cmd		= DPLL_CMD_DEVICE_SET,
116 		.pre_doit	= dpll_pre_doit,
117 		.doit		= dpll_nl_device_set_doit,
118 		.post_doit	= dpll_post_doit,
119 		.policy		= dpll_device_set_nl_policy,
120 		.maxattr	= DPLL_A_FREQUENCY_MONITOR,
121 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
122 	},
123 	{
124 		.cmd		= DPLL_CMD_PIN_ID_GET,
125 		.pre_doit	= dpll_lock_doit,
126 		.doit		= dpll_nl_pin_id_get_doit,
127 		.post_doit	= dpll_unlock_doit,
128 		.policy		= dpll_pin_id_get_nl_policy,
129 		.maxattr	= DPLL_A_PIN_TYPE,
130 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
131 	},
132 	{
133 		.cmd		= DPLL_CMD_PIN_GET,
134 		.pre_doit	= dpll_pin_pre_doit,
135 		.doit		= dpll_nl_pin_get_doit,
136 		.post_doit	= dpll_pin_post_doit,
137 		.policy		= dpll_pin_get_do_nl_policy,
138 		.maxattr	= DPLL_A_PIN_ID,
139 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
140 	},
141 	{
142 		.cmd		= DPLL_CMD_PIN_GET,
143 		.dumpit		= dpll_nl_pin_get_dumpit,
144 		.policy		= dpll_pin_get_dump_nl_policy,
145 		.maxattr	= DPLL_A_PIN_ID,
146 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DUMP,
147 	},
148 	{
149 		.cmd		= DPLL_CMD_PIN_SET,
150 		.pre_doit	= dpll_pin_pre_doit,
151 		.doit		= dpll_nl_pin_set_doit,
152 		.post_doit	= dpll_pin_post_doit,
153 		.policy		= dpll_pin_set_nl_policy,
154 		.maxattr	= DPLL_A_PIN_REFERENCE_SYNC,
155 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
156 	},
157 };
158 
159 static const struct genl_multicast_group dpll_nl_mcgrps[] = {
160 	[DPLL_NLGRP_MONITOR] = { "monitor", },
161 };
162 
163 struct genl_family dpll_nl_family __ro_after_init = {
164 	.name		= DPLL_FAMILY_NAME,
165 	.version	= DPLL_FAMILY_VERSION,
166 	.netnsok	= true,
167 	.parallel_ops	= true,
168 	.module		= THIS_MODULE,
169 	.split_ops	= dpll_nl_ops,
170 	.n_split_ops	= ARRAY_SIZE(dpll_nl_ops),
171 	.mcgrps		= dpll_nl_mcgrps,
172 	.n_mcgrps	= ARRAY_SIZE(dpll_nl_mcgrps),
173 };
174