1789Sahrens /* 2789Sahrens * CDDL HEADER START 3789Sahrens * 4789Sahrens * The contents of this file are subject to the terms of the 51544Seschrock * Common Development and Distribution License (the "License"). 61544Seschrock * You may not use this file except in compliance with the License. 7789Sahrens * 8789Sahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9789Sahrens * or http://www.opensolaris.org/os/licensing. 10789Sahrens * See the License for the specific language governing permissions 11789Sahrens * and limitations under the License. 12789Sahrens * 13789Sahrens * When distributing Covered Code, include this CDDL HEADER in each 14789Sahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15789Sahrens * If applicable, add the following below this CDDL HEADER, with the 16789Sahrens * fields enclosed by brackets "[]" replaced with your own identifying 17789Sahrens * information: Portions Copyright [yyyy] [name of copyright owner] 18789Sahrens * 19789Sahrens * CDDL HEADER END 20789Sahrens */ 21789Sahrens /* 22*12470SMatthew.Ahrens@Sun.COM * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 23789Sahrens */ 24789Sahrens 25789Sahrens #ifndef _SYS_ZIO_CHECKSUM_H 26789Sahrens #define _SYS_ZIO_CHECKSUM_H 27789Sahrens 28789Sahrens #include <sys/zio.h> 29789Sahrens 30789Sahrens #ifdef __cplusplus 31789Sahrens extern "C" { 32789Sahrens #endif 33789Sahrens 34789Sahrens /* 35789Sahrens * Signature for checksum functions. 36789Sahrens */ 37789Sahrens typedef void zio_checksum_t(const void *data, uint64_t size, zio_cksum_t *zcp); 38789Sahrens 39789Sahrens /* 40789Sahrens * Information about each checksum function. 41789Sahrens */ 42789Sahrens typedef struct zio_checksum_info { 43789Sahrens zio_checksum_t *ci_func[2]; /* checksum function for each byteorder */ 44789Sahrens int ci_correctable; /* number of correctable bits */ 4511670SNeil.Perrin@Sun.COM int ci_eck; /* uses zio embedded checksum? */ 4610922SJeff.Bonwick@Sun.COM int ci_dedup; /* strong enough for dedup? */ 47789Sahrens char *ci_name; /* descriptive name */ 48789Sahrens } zio_checksum_info_t; 49789Sahrens 5010614SJonathan.Adams@Sun.COM typedef struct zio_bad_cksum { 5110614SJonathan.Adams@Sun.COM zio_cksum_t zbc_expected; 5210614SJonathan.Adams@Sun.COM zio_cksum_t zbc_actual; 5310614SJonathan.Adams@Sun.COM const char *zbc_checksum_name; 5410614SJonathan.Adams@Sun.COM uint8_t zbc_byteswapped; 5510614SJonathan.Adams@Sun.COM uint8_t zbc_injected; 5610614SJonathan.Adams@Sun.COM uint8_t zbc_has_cksum; /* expected/actual valid */ 5710614SJonathan.Adams@Sun.COM } zio_bad_cksum_t; 5810614SJonathan.Adams@Sun.COM 59789Sahrens extern zio_checksum_info_t zio_checksum_table[ZIO_CHECKSUM_FUNCTIONS]; 60789Sahrens 61789Sahrens /* 62789Sahrens * Checksum routines. 63789Sahrens */ 64789Sahrens extern zio_checksum_t zio_checksum_SHA256; 65789Sahrens 667754SJeff.Bonwick@Sun.COM extern void zio_checksum_compute(zio_t *zio, enum zio_checksum checksum, 67789Sahrens void *data, uint64_t size); 6810614SJonathan.Adams@Sun.COM extern int zio_checksum_error(zio_t *zio, zio_bad_cksum_t *out); 69*12470SMatthew.Ahrens@Sun.COM extern enum zio_checksum spa_dedup_checksum(spa_t *spa); 70789Sahrens 71789Sahrens #ifdef __cplusplus 72789Sahrens } 73789Sahrens #endif 74789Sahrens 75789Sahrens #endif /* _SYS_ZIO_CHECKSUM_H */ 76