xref: /freebsd/sys/contrib/openzfs/module/zfs/zfs_impl.c (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1*61145dc2SMartin Matuska // SPDX-License-Identifier: CDDL-1.0
22a58b312SMartin Matuska /*
32a58b312SMartin Matuska  * CDDL HEADER START
42a58b312SMartin Matuska  *
52a58b312SMartin Matuska  * The contents of this file are subject to the terms of the
62a58b312SMartin Matuska  * Common Development and Distribution License (the "License").
72a58b312SMartin Matuska  * You may not use this file except in compliance with the License.
82a58b312SMartin Matuska  *
92a58b312SMartin Matuska  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
102a58b312SMartin Matuska  * or https://opensource.org/licenses/CDDL-1.0.
112a58b312SMartin Matuska  * See the License for the specific language governing permissions
122a58b312SMartin Matuska  * and limitations under the License.
132a58b312SMartin Matuska  *
142a58b312SMartin Matuska  * When distributing Covered Code, include this CDDL HEADER in each
152a58b312SMartin Matuska  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
162a58b312SMartin Matuska  * If applicable, add the following below this CDDL HEADER, with the
172a58b312SMartin Matuska  * fields enclosed by brackets "[]" replaced with your own identifying
182a58b312SMartin Matuska  * information: Portions Copyright [yyyy] [name of copyright owner]
192a58b312SMartin Matuska  *
202a58b312SMartin Matuska  * CDDL HEADER END
212a58b312SMartin Matuska  */
222a58b312SMartin Matuska 
232a58b312SMartin Matuska /*
242a58b312SMartin Matuska  * Copyright (c) 2022 Tino Reichardt <milky-zfs@mcmilk.de>
252a58b312SMartin Matuska  */
262a58b312SMartin Matuska 
272a58b312SMartin Matuska #include <sys/zio_checksum.h>
282a58b312SMartin Matuska #include <sys/zfs_context.h>
292a58b312SMartin Matuska #include <sys/zfs_impl.h>
302a58b312SMartin Matuska 
312a58b312SMartin Matuska #include <sys/blake3.h>
322a58b312SMartin Matuska #include <sys/sha2.h>
332a58b312SMartin Matuska 
342a58b312SMartin Matuska /*
352a58b312SMartin Matuska  * impl_ops - backend for implementations of algorithms
362a58b312SMartin Matuska  */
372a58b312SMartin Matuska const zfs_impl_t *impl_ops[] = {
382a58b312SMartin Matuska 	&zfs_blake3_ops,
392a58b312SMartin Matuska 	&zfs_sha256_ops,
402a58b312SMartin Matuska 	&zfs_sha512_ops,
412a58b312SMartin Matuska 	NULL
422a58b312SMartin Matuska };
432a58b312SMartin Matuska 
442a58b312SMartin Matuska /*
452a58b312SMartin Matuska  * zfs_impl_get_ops - Get the API functions for an impl backend
462a58b312SMartin Matuska  */
472a58b312SMartin Matuska const zfs_impl_t *
zfs_impl_get_ops(const char * algo)482a58b312SMartin Matuska zfs_impl_get_ops(const char *algo)
492a58b312SMartin Matuska {
502a58b312SMartin Matuska 	const zfs_impl_t **ops = impl_ops;
512a58b312SMartin Matuska 
522a58b312SMartin Matuska 	if (!algo || !*algo)
532a58b312SMartin Matuska 		return (*ops);
542a58b312SMartin Matuska 
552a58b312SMartin Matuska 	for (; *ops; ops++) {
562a58b312SMartin Matuska 		if (strcmp(algo, (*ops)->name) == 0)
572a58b312SMartin Matuska 			break;
582a58b312SMartin Matuska 	}
592a58b312SMartin Matuska 
602a58b312SMartin Matuska 	ASSERT3P(ops, !=, NULL);
612a58b312SMartin Matuska 	return (*ops);
622a58b312SMartin Matuska }
63