diff options
author | Lars Ellenberg <lars.ellenberg@linbit.com> | 2011-03-07 04:20:08 -0500 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2011-10-14 10:48:08 -0400 |
commit | ec2c35ac1ea288f5c931e32452ecea50068e8450 (patch) | |
tree | 0f21d21aab56f188c21109fc38305d17dcce6df3 /include/linux/drbd_genl.h | |
parent | 3cb7a2a90fe35eb3059e8860d0c6917eb414f791 (diff) |
drbd: prepare the transition from connector to genetlink
This adds the new API header and helper files.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'include/linux/drbd_genl.h')
-rw-r--r-- | include/linux/drbd_genl.h | 349 |
1 files changed, 349 insertions, 0 deletions
diff --git a/include/linux/drbd_genl.h b/include/linux/drbd_genl.h new file mode 100644 index 000000000000..84e16848f7a1 --- /dev/null +++ b/include/linux/drbd_genl.h | |||
@@ -0,0 +1,349 @@ | |||
1 | /* | ||
2 | * General overview: | ||
3 | * full generic netlink message: | ||
4 | * |nlmsghdr|genlmsghdr|<payload> | ||
5 | * | ||
6 | * payload: | ||
7 | * |optional fixed size family header|<sequence of netlink attributes> | ||
8 | * | ||
9 | * sequence of netlink attributes: | ||
10 | * I chose to have all "top level" attributes NLA_NESTED, | ||
11 | * corresponding to some real struct. | ||
12 | * So we have a sequence of |tla, len|<nested nla sequence> | ||
13 | * | ||
14 | * nested nla sequence: | ||
15 | * may be empty, or contain a sequence of netlink attributes | ||
16 | * representing the struct fields. | ||
17 | * | ||
18 | * The tag number of any field (regardless of containing struct) | ||
19 | * will be available as T_ ## field_name, | ||
20 | * so you cannot have the same field name in two differnt structs. | ||
21 | * | ||
22 | * The tag numbers themselves are per struct, though, | ||
23 | * so should always begin at 1 (not 0, that is the special "NLA_UNSPEC" type, | ||
24 | * which we won't use here). | ||
25 | * The tag numbers are used as index in the respective nla_policy array. | ||
26 | * | ||
27 | * GENL_struct(tag_name, tag_number, struct name, struct fields) - struct and policy | ||
28 | * genl_magic_struct.h | ||
29 | * generates the struct declaration, | ||
30 | * generates an entry in the tla enum, | ||
31 | * genl_magic_func.h | ||
32 | * generates an entry in the static tla policy | ||
33 | * with .type = NLA_NESTED | ||
34 | * generates the static <struct_name>_nl_policy definition, | ||
35 | * and static conversion functions | ||
36 | * | ||
37 | * genl_magic_func.h | ||
38 | * | ||
39 | * GENL_mc_group(group) | ||
40 | * genl_magic_struct.h | ||
41 | * does nothing | ||
42 | * genl_magic_func.h | ||
43 | * defines and registers the mcast group, | ||
44 | * and provides a send helper | ||
45 | * | ||
46 | * GENL_notification(op_name, op_num, mcast_group, tla list) | ||
47 | * These are notifications to userspace. | ||
48 | * | ||
49 | * genl_magic_struct.h | ||
50 | * generates an entry in the genl_ops enum, | ||
51 | * genl_magic_func.h | ||
52 | * does nothing | ||
53 | * | ||
54 | * mcast group: the name of the mcast group this notification should be | ||
55 | * expected on | ||
56 | * tla list: the list of expected top level attributes, | ||
57 | * for documentation and sanity checking. | ||
58 | * | ||
59 | * GENL_op(op_name, op_num, flags and handler, tla list) - "genl operations" | ||
60 | * These are requests from userspace. | ||
61 | * | ||
62 | * _op and _notification share the same "number space", | ||
63 | * op_nr will be assigned to "genlmsghdr->cmd" | ||
64 | * | ||
65 | * genl_magic_struct.h | ||
66 | * generates an entry in the genl_ops enum, | ||
67 | * genl_magic_func.h | ||
68 | * generates an entry in the static genl_ops array, | ||
69 | * and static register/unregister functions to | ||
70 | * genl_register_family_with_ops(). | ||
71 | * | ||
72 | * flags and handler: | ||
73 | * GENL_op_init( .doit = x, .dumpit = y, .flags = something) | ||
74 | * GENL_doit(x) => .dumpit = NULL, .flags = GENL_ADMIN_PERM | ||
75 | * tla list: the list of expected top level attributes, | ||
76 | * for documentation and sanity checking. | ||
77 | */ | ||
78 | |||
79 | /* | ||
80 | * STRUCTS | ||
81 | */ | ||
82 | |||
83 | /* this is sent kernel -> userland on various error conditions, and contains | ||
84 | * informational textual info, which is supposedly human readable. | ||
85 | * The computer relevant return code is in the drbd_genlmsghdr. | ||
86 | */ | ||
87 | GENL_struct(DRBD_NLA_CFG_REPLY, 1, drbd_cfg_reply, | ||
88 | /* "arbitrary" size strings, nla_policy.len = 0 */ | ||
89 | __str_field(1, GENLA_F_MANDATORY, info_text, 0) | ||
90 | ) | ||
91 | |||
92 | /* Configuration requests typically need a context to operate on. | ||
93 | * Possible keys are device minor (fits in the drbd_genlmsghdr), | ||
94 | * the replication link (aka connection) name, | ||
95 | * and/or the replication group (aka resource) name, | ||
96 | * and the volume id within the resource. */ | ||
97 | GENL_struct(DRBD_NLA_CFG_CONTEXT, 2, drbd_cfg_context, | ||
98 | /* currently only 256 volumes per group, | ||
99 | * but maybe we still change that */ | ||
100 | __u32_field(1, GENLA_F_MANDATORY, ctx_volume) | ||
101 | __str_field(2, GENLA_F_MANDATORY, ctx_conn_name, 128) | ||
102 | ) | ||
103 | |||
104 | GENL_struct(DRBD_NLA_DISK_CONF, 3, disk_conf, | ||
105 | __u64_field(1, GENLA_F_MANDATORY, disk_size) | ||
106 | __str_field(2, GENLA_F_REQUIRED, backing_dev, 128) | ||
107 | __str_field(3, GENLA_F_REQUIRED, meta_dev, 128) | ||
108 | __u32_field(4, GENLA_F_REQUIRED, meta_dev_idx) | ||
109 | __u32_field(5, GENLA_F_MANDATORY, max_bio_bvecs) | ||
110 | __u32_field(6, GENLA_F_MANDATORY, on_io_error) | ||
111 | __u32_field(7, GENLA_F_MANDATORY, fencing) | ||
112 | __flg_field(8, GENLA_F_MANDATORY, no_disk_barrier) | ||
113 | __flg_field(9, GENLA_F_MANDATORY, no_disk_flush) | ||
114 | __flg_field(10, GENLA_F_MANDATORY, no_disk_drain) | ||
115 | __flg_field(11, GENLA_F_MANDATORY, no_md_flush) | ||
116 | __flg_field(12, GENLA_F_MANDATORY, use_bmbv) | ||
117 | ) | ||
118 | |||
119 | GENL_struct(DRBD_NLA_SYNCER_CONF, 4, syncer_conf, | ||
120 | __u32_field(1, GENLA_F_MANDATORY, rate) | ||
121 | __u32_field(2, GENLA_F_MANDATORY, after) | ||
122 | __u32_field(3, GENLA_F_MANDATORY, al_extents) | ||
123 | __str_field(4, GENLA_F_MANDATORY, cpu_mask, 32) | ||
124 | __str_field(5, GENLA_F_MANDATORY, verify_alg, SHARED_SECRET_MAX) | ||
125 | __str_field(6, GENLA_F_MANDATORY, csums_alg, SHARED_SECRET_MAX) | ||
126 | __flg_field(7, GENLA_F_MANDATORY, use_rle) | ||
127 | __u32_field(8, GENLA_F_MANDATORY, on_no_data) | ||
128 | __u32_field(9, GENLA_F_MANDATORY, c_plan_ahead) | ||
129 | __u32_field(10, GENLA_F_MANDATORY, c_delay_target) | ||
130 | __u32_field(11, GENLA_F_MANDATORY, c_fill_target) | ||
131 | __u32_field(12, GENLA_F_MANDATORY, c_max_rate) | ||
132 | __u32_field(13, GENLA_F_MANDATORY, c_min_rate) | ||
133 | ) | ||
134 | |||
135 | GENL_struct(DRBD_NLA_NET_CONF, 5, net_conf, | ||
136 | __str_field(1, GENLA_F_MANDATORY | GENLA_F_SENSITIVE, | ||
137 | shared_secret, SHARED_SECRET_MAX) | ||
138 | __str_field(2, GENLA_F_MANDATORY, cram_hmac_alg, SHARED_SECRET_MAX) | ||
139 | __str_field(3, GENLA_F_MANDATORY, integrity_alg, SHARED_SECRET_MAX) | ||
140 | __str_field(4, GENLA_F_REQUIRED, my_addr, 128) | ||
141 | __str_field(5, GENLA_F_REQUIRED, peer_addr, 128) | ||
142 | __u32_field(6, GENLA_F_REQUIRED, wire_protocol) | ||
143 | __u32_field(7, GENLA_F_MANDATORY, try_connect_int) | ||
144 | __u32_field(8, GENLA_F_MANDATORY, timeout) | ||
145 | __u32_field(9, GENLA_F_MANDATORY, ping_int) | ||
146 | __u32_field(10, GENLA_F_MANDATORY, ping_timeo) | ||
147 | __u32_field(11, GENLA_F_MANDATORY, sndbuf_size) | ||
148 | __u32_field(12, GENLA_F_MANDATORY, rcvbuf_size) | ||
149 | __u32_field(13, GENLA_F_MANDATORY, ko_count) | ||
150 | __u32_field(14, GENLA_F_MANDATORY, max_buffers) | ||
151 | __u32_field(15, GENLA_F_MANDATORY, max_epoch_size) | ||
152 | __u32_field(16, GENLA_F_MANDATORY, unplug_watermark) | ||
153 | __u32_field(17, GENLA_F_MANDATORY, after_sb_0p) | ||
154 | __u32_field(18, GENLA_F_MANDATORY, after_sb_1p) | ||
155 | __u32_field(19, GENLA_F_MANDATORY, after_sb_2p) | ||
156 | __u32_field(20, GENLA_F_MANDATORY, rr_conflict) | ||
157 | __u32_field(21, GENLA_F_MANDATORY, on_congestion) | ||
158 | __u32_field(22, GENLA_F_MANDATORY, cong_fill) | ||
159 | __u32_field(23, GENLA_F_MANDATORY, cong_extents) | ||
160 | __flg_field(24, GENLA_F_MANDATORY, two_primaries) | ||
161 | __flg_field(25, GENLA_F_MANDATORY, want_lose) | ||
162 | __flg_field(26, GENLA_F_MANDATORY, no_cork) | ||
163 | __flg_field(27, GENLA_F_MANDATORY, always_asbp) | ||
164 | __flg_field(28, GENLA_F_MANDATORY, dry_run) | ||
165 | ) | ||
166 | |||
167 | GENL_struct(DRBD_NLA_SET_ROLE_PARMS, 6, set_role_parms, | ||
168 | __flg_field(1, GENLA_F_MANDATORY, assume_uptodate) | ||
169 | ) | ||
170 | |||
171 | GENL_struct(DRBD_NLA_RESIZE_PARMS, 7, resize_parms, | ||
172 | __u64_field(1, GENLA_F_MANDATORY, resize_size) | ||
173 | __flg_field(2, GENLA_F_MANDATORY, resize_force) | ||
174 | __flg_field(3, GENLA_F_MANDATORY, no_resync) | ||
175 | ) | ||
176 | |||
177 | GENL_struct(DRBD_NLA_STATE_INFO, 8, state_info, | ||
178 | /* the reason of the broadcast, | ||
179 | * if this is an event triggered broadcast. */ | ||
180 | __u32_field(1, GENLA_F_MANDATORY, sib_reason) | ||
181 | __u32_field(2, GENLA_F_REQUIRED, current_state) | ||
182 | __u64_field(3, GENLA_F_MANDATORY, capacity) | ||
183 | __u64_field(4, GENLA_F_MANDATORY, ed_uuid) | ||
184 | |||
185 | /* These are for broadcast from after state change work. | ||
186 | * prev_state and new_state are from the moment the state change took | ||
187 | * place, new_state is not neccessarily the same as current_state, | ||
188 | * there may have been more state changes since. Which will be | ||
189 | * broadcasted soon, in their respective after state change work. */ | ||
190 | __u32_field(5, GENLA_F_MANDATORY, prev_state) | ||
191 | __u32_field(6, GENLA_F_MANDATORY, new_state) | ||
192 | |||
193 | /* if we have a local disk: */ | ||
194 | __bin_field(7, GENLA_F_MANDATORY, uuids, (UI_SIZE*sizeof(__u64))) | ||
195 | __u32_field(8, GENLA_F_MANDATORY, disk_flags) | ||
196 | __u64_field(9, GENLA_F_MANDATORY, bits_total) | ||
197 | __u64_field(10, GENLA_F_MANDATORY, bits_oos) | ||
198 | /* and in case resync or online verify is active */ | ||
199 | __u64_field(11, GENLA_F_MANDATORY, bits_rs_total) | ||
200 | __u64_field(12, GENLA_F_MANDATORY, bits_rs_failed) | ||
201 | |||
202 | /* for pre and post notifications of helper execution */ | ||
203 | __str_field(13, GENLA_F_MANDATORY, helper, 32) | ||
204 | __u32_field(14, GENLA_F_MANDATORY, helper_exit_code) | ||
205 | ) | ||
206 | |||
207 | GENL_struct(DRBD_NLA_START_OV_PARMS, 9, start_ov_parms, | ||
208 | __u64_field(1, GENLA_F_MANDATORY, ov_start_sector) | ||
209 | ) | ||
210 | |||
211 | GENL_struct(DRBD_NLA_NEW_C_UUID_PARMS, 10, new_c_uuid_parms, | ||
212 | __flg_field(1, GENLA_F_MANDATORY, clear_bm) | ||
213 | ) | ||
214 | |||
215 | GENL_struct(DRBD_NLA_TIMEOUT_PARMS, 11, timeout_parms, | ||
216 | __u32_field(1, GENLA_F_REQUIRED, timeout_type) | ||
217 | ) | ||
218 | |||
219 | GENL_struct(DRBD_NLA_DISCONNECT_PARMS, 12, disconnect_parms, | ||
220 | __flg_field(1, GENLA_F_MANDATORY, force_disconnect) | ||
221 | ) | ||
222 | |||
223 | /* | ||
224 | * Notifications and commands (genlmsghdr->cmd) | ||
225 | */ | ||
226 | GENL_mc_group(events) | ||
227 | |||
228 | /* kernel -> userspace announcement of changes */ | ||
229 | GENL_notification( | ||
230 | DRBD_EVENT, 1, events, | ||
231 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED) | ||
232 | GENL_tla_expected(DRBD_NLA_STATE_INFO, GENLA_F_REQUIRED) | ||
233 | GENL_tla_expected(DRBD_NLA_NET_CONF, GENLA_F_MANDATORY) | ||
234 | GENL_tla_expected(DRBD_NLA_DISK_CONF, GENLA_F_MANDATORY) | ||
235 | GENL_tla_expected(DRBD_NLA_SYNCER_CONF, GENLA_F_MANDATORY) | ||
236 | ) | ||
237 | |||
238 | /* query kernel for specific or all info */ | ||
239 | GENL_op( | ||
240 | DRBD_ADM_GET_STATUS, 2, | ||
241 | GENL_op_init( | ||
242 | .doit = drbd_adm_get_status, | ||
243 | .dumpit = drbd_adm_get_status_all, | ||
244 | /* anyone may ask for the status, | ||
245 | * it is broadcasted anyways */ | ||
246 | ), | ||
247 | /* To select the object .doit. | ||
248 | * Or a subset of objects in .dumpit. */ | ||
249 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_MANDATORY) | ||
250 | ) | ||
251 | |||
252 | #if 0 | ||
253 | /* TO BE DONE */ | ||
254 | /* create or destroy resources, aka replication groups */ | ||
255 | GENL_op(DRBD_ADM_CREATE_RESOURCE, 3, GENL_doit(drbd_adm_create_resource), | ||
256 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) | ||
257 | GENL_op(DRBD_ADM_DELETE_RESOURCE, 4, GENL_doit(drbd_adm_delete_resource), | ||
258 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) | ||
259 | #endif | ||
260 | |||
261 | /* add DRBD minor devices as volumes to resources */ | ||
262 | GENL_op(DRBD_ADM_ADD_MINOR, 5, GENL_doit(drbd_adm_add_minor), | ||
263 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) | ||
264 | GENL_op(DRBD_ADM_DEL_MINOR, 6, GENL_doit(drbd_adm_delete_minor), | ||
265 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) | ||
266 | |||
267 | /* add or delete replication links to resources */ | ||
268 | GENL_op(DRBD_ADM_ADD_LINK, 7, GENL_doit(drbd_adm_create_connection), | ||
269 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) | ||
270 | GENL_op(DRBD_ADM_DEL_LINK, 8, GENL_doit(drbd_adm_delete_connection), | ||
271 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) | ||
272 | |||
273 | /* operates on replication links */ | ||
274 | GENL_op(DRBD_ADM_SYNCER, 9, | ||
275 | GENL_doit(drbd_adm_syncer), | ||
276 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED) | ||
277 | GENL_tla_expected(DRBD_NLA_SYNCER_CONF, GENLA_F_MANDATORY) | ||
278 | ) | ||
279 | |||
280 | GENL_op( | ||
281 | DRBD_ADM_CONNECT, 10, | ||
282 | GENL_doit(drbd_adm_connect), | ||
283 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED) | ||
284 | GENL_tla_expected(DRBD_NLA_NET_CONF, GENLA_F_REQUIRED) | ||
285 | ) | ||
286 | |||
287 | GENL_op(DRBD_ADM_DISCONNECT, 11, GENL_doit(drbd_adm_disconnect), | ||
288 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) | ||
289 | |||
290 | /* operates on minors */ | ||
291 | GENL_op(DRBD_ADM_ATTACH, 12, | ||
292 | GENL_doit(drbd_adm_attach), | ||
293 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED) | ||
294 | GENL_tla_expected(DRBD_NLA_DISK_CONF, GENLA_F_REQUIRED) | ||
295 | ) | ||
296 | |||
297 | GENL_op( | ||
298 | DRBD_ADM_RESIZE, 13, | ||
299 | GENL_doit(drbd_adm_resize), | ||
300 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED) | ||
301 | GENL_tla_expected(DRBD_NLA_RESIZE_PARMS, GENLA_F_MANDATORY) | ||
302 | ) | ||
303 | |||
304 | /* operates on all volumes within a resource */ | ||
305 | GENL_op( | ||
306 | DRBD_ADM_PRIMARY, 14, | ||
307 | GENL_doit(drbd_adm_set_role), | ||
308 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED) | ||
309 | GENL_tla_expected(DRBD_NLA_SET_ROLE_PARMS, GENLA_F_REQUIRED) | ||
310 | ) | ||
311 | |||
312 | GENL_op( | ||
313 | DRBD_ADM_SECONDARY, 15, | ||
314 | GENL_doit(drbd_adm_set_role), | ||
315 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED) | ||
316 | GENL_tla_expected(DRBD_NLA_SET_ROLE_PARMS, GENLA_F_REQUIRED) | ||
317 | ) | ||
318 | |||
319 | GENL_op( | ||
320 | DRBD_ADM_NEW_C_UUID, 16, | ||
321 | GENL_doit(drbd_adm_new_c_uuid), | ||
322 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED) | ||
323 | GENL_tla_expected(DRBD_NLA_NEW_C_UUID_PARMS, GENLA_F_MANDATORY) | ||
324 | ) | ||
325 | |||
326 | GENL_op( | ||
327 | DRBD_ADM_START_OV, 17, | ||
328 | GENL_doit(drbd_adm_start_ov), | ||
329 | GENL_tla_expected(DRBD_NLA_START_OV_PARMS, GENLA_F_MANDATORY) | ||
330 | ) | ||
331 | |||
332 | GENL_op(DRBD_ADM_DETACH, 18, GENL_doit(drbd_adm_detach), | ||
333 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) | ||
334 | GENL_op(DRBD_ADM_INVALIDATE, 19, GENL_doit(drbd_adm_invalidate), | ||
335 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) | ||
336 | GENL_op(DRBD_ADM_INVAL_PEER, 20, GENL_doit(drbd_adm_invalidate_peer), | ||
337 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) | ||
338 | GENL_op(DRBD_ADM_PAUSE_SYNC, 21, GENL_doit(drbd_adm_pause_sync), | ||
339 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) | ||
340 | GENL_op(DRBD_ADM_RESUME_SYNC, 22, GENL_doit(drbd_adm_resume_sync), | ||
341 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) | ||
342 | GENL_op(DRBD_ADM_SUSPEND_IO, 23, GENL_doit(drbd_adm_suspend_io), | ||
343 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) | ||
344 | GENL_op(DRBD_ADM_RESUME_IO, 24, GENL_doit(drbd_adm_resume_io), | ||
345 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) | ||
346 | GENL_op(DRBD_ADM_OUTDATE, 25, GENL_doit(drbd_adm_outdate), | ||
347 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) | ||
348 | GENL_op(DRBD_ADM_GET_TIMEOUT_TYPE, 26, GENL_doit(drbd_adm_get_timeout_type), | ||
349 | GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, GENLA_F_REQUIRED)) | ||