xref: /netbsd-src/sys/dev/dmover/dmover_util.c (revision 95e1ffb15694e54f29f8baaa4232152b703c2a5a)
1*95e1ffb1Schristos /*	$NetBSD: dmover_util.c,v 1.5 2005/12/11 12:21:20 christos Exp $	*/
25d06c0e8Sthorpej 
35d06c0e8Sthorpej /*
45d06c0e8Sthorpej  * Copyright (c) 2002 Wasabi Systems, Inc.
55d06c0e8Sthorpej  * All rights reserved.
65d06c0e8Sthorpej  *
75d06c0e8Sthorpej  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
85d06c0e8Sthorpej  *
95d06c0e8Sthorpej  * Redistribution and use in source and binary forms, with or without
105d06c0e8Sthorpej  * modification, are permitted provided that the following conditions
115d06c0e8Sthorpej  * are met:
125d06c0e8Sthorpej  * 1. Redistributions of source code must retain the above copyright
135d06c0e8Sthorpej  *    notice, this list of conditions and the following disclaimer.
145d06c0e8Sthorpej  * 2. Redistributions in binary form must reproduce the above copyright
155d06c0e8Sthorpej  *    notice, this list of conditions and the following disclaimer in the
165d06c0e8Sthorpej  *    documentation and/or other materials provided with the distribution.
175d06c0e8Sthorpej  * 3. All advertising materials mentioning features or use of this software
185d06c0e8Sthorpej  *    must display the following acknowledgement:
195d06c0e8Sthorpej  *	This product includes software developed for the NetBSD Project by
205d06c0e8Sthorpej  *	Wasabi Systems, Inc.
215d06c0e8Sthorpej  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
225d06c0e8Sthorpej  *    or promote products derived from this software without specific prior
235d06c0e8Sthorpej  *    written permission.
245d06c0e8Sthorpej  *
255d06c0e8Sthorpej  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
265d06c0e8Sthorpej  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
275d06c0e8Sthorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
285d06c0e8Sthorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
295d06c0e8Sthorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
305d06c0e8Sthorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
315d06c0e8Sthorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
325d06c0e8Sthorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
335d06c0e8Sthorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
345d06c0e8Sthorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
355d06c0e8Sthorpej  * POSSIBILITY OF SUCH DAMAGE.
365d06c0e8Sthorpej  */
375d06c0e8Sthorpej 
385d06c0e8Sthorpej /*
395d06c0e8Sthorpej  * dmover_util.c: Utility functions for dmover-api.
405d06c0e8Sthorpej  */
415d06c0e8Sthorpej 
425d06c0e8Sthorpej #include <sys/cdefs.h>
43*95e1ffb1Schristos __KERNEL_RCSID(0, "$NetBSD: dmover_util.c,v 1.5 2005/12/11 12:21:20 christos Exp $");
445d06c0e8Sthorpej 
455d06c0e8Sthorpej #include <sys/param.h>
465d06c0e8Sthorpej #include <sys/systm.h>
475d06c0e8Sthorpej 
485d06c0e8Sthorpej #include <dev/dmover/dmovervar.h>
495d06c0e8Sthorpej 
505d06c0e8Sthorpej /****************************************************************************
515d06c0e8Sthorpej  * Well-known data mover function names.
525d06c0e8Sthorpej  ****************************************************************************/
535d06c0e8Sthorpej 
545d06c0e8Sthorpej const char dmover_funcname_zero[] = "zero";
555d06c0e8Sthorpej const char dmover_funcname_fill8[] = "fill8";
565d06c0e8Sthorpej const char dmover_funcname_copy[] = "copy";
57a2a587d6Sthorpej const char dmover_funcname_iscsi_crc32c[] = "iscsi-crc32c";
5832ff9181Sthorpej const char dmover_funcname_xor2[] = "xor2";
5932ff9181Sthorpej const char dmover_funcname_xor3[] = "xor3";
6032ff9181Sthorpej const char dmover_funcname_xor4[] = "xor4";
6116003abdSthorpej const char dmover_funcname_xor5[] = "xor5";
6216003abdSthorpej const char dmover_funcname_xor6[] = "xor6";
6316003abdSthorpej const char dmover_funcname_xor7[] = "xor7";
6416003abdSthorpej const char dmover_funcname_xor8[] = "xor8";
655d06c0e8Sthorpej 
665d06c0e8Sthorpej /****************************************************************************
675d06c0e8Sthorpej  * Utility functions.
685d06c0e8Sthorpej  ****************************************************************************/
695d06c0e8Sthorpej 
705d06c0e8Sthorpej /*
715d06c0e8Sthorpej  * dmover_algdesc_lookup:
725d06c0e8Sthorpej  *
735d06c0e8Sthorpej  *	Look up the algdesc in the provided array by name.
745d06c0e8Sthorpej  */
755d06c0e8Sthorpej const struct dmover_algdesc *
dmover_algdesc_lookup(const struct dmover_algdesc * dad,int ndad,const char * name)765d06c0e8Sthorpej dmover_algdesc_lookup(const struct dmover_algdesc *dad, int ndad,
775d06c0e8Sthorpej     const char *name)
785d06c0e8Sthorpej {
795d06c0e8Sthorpej 
805d06c0e8Sthorpej 	for (; ndad != 0; ndad--, dad++) {
815d06c0e8Sthorpej 		if (name[0] == dad->dad_name[0] &&
825d06c0e8Sthorpej 		    strcmp(name, dad->dad_name) == 0)
835d06c0e8Sthorpej 			return (dad);
845d06c0e8Sthorpej 	}
855d06c0e8Sthorpej 	return (NULL);
865d06c0e8Sthorpej }
87