xref: /freebsd/sys/contrib/openzfs/include/sys/zfs_impl.h (revision 22649d4dba730d46244fd2dff4fd174903c8379f)
1 // SPDX-License-Identifier: CDDL-1.0
2 /*
3  * This file and its contents are supplied under the terms of the
4  * Common Development and Distribution License ("CDDL"), version 1.0.
5  * You may only use this file in accordance with the terms of version
6  * 1.0 of the CDDL.
7  *
8  * A full copy of the text of the CDDL should have accompanied this
9  * source.  A copy of the CDDL is also available via the Internet at
10  * https://opensource.org/license/CDDL-1.0.
11  */
12 
13 /*
14  * Copyright (c) 2022 Tino Reichardt <milky-zfs@mcmilk.de>
15  */
16 
17 #ifndef	_SYS_ZFS_IMPL_H
18 #define	_SYS_ZFS_IMPL_H
19 
20 #ifdef	__cplusplus
21 extern "C" {
22 #endif
23 
24 /* generic implementation backends */
25 typedef struct
26 {
27 	/* algorithm name */
28 	const char *name;
29 
30 	/* get number of supported implementations */
31 	uint32_t (*getcnt)(void);
32 
33 	/* get id of selected implementation */
34 	uint32_t (*getid)(void);
35 
36 	/* get name of selected implementation */
37 	const char *(*getname)(void);
38 
39 	/* setup id as fastest implementation */
40 	void (*set_fastest)(uint32_t id);
41 
42 	/* set implementation by id */
43 	void (*setid)(uint32_t id);
44 
45 	/* set implementation by name */
46 	int (*setname)(const char *val);
47 } zfs_impl_t;
48 
49 /* return some set of function pointer */
50 extern const zfs_impl_t *zfs_impl_get_ops(const char *algo);
51 
52 extern const zfs_impl_t zfs_blake3_ops;
53 extern const zfs_impl_t zfs_sha256_ops;
54 extern const zfs_impl_t zfs_sha512_ops;
55 
56 #ifdef	__cplusplus
57 }
58 #endif
59 
60 #endif	/* _SYS_ZFS_IMPL_H */
61