fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2000 by Cisco Systems, Inc. All rights reserved.
d4b0f84707225327c617c6838361d3cfb7762b34Jack Meng * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This file contains CRC-32C code use to verify
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI HeaderDigests and DataDigests.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This is the CRC-32C table
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Generated with:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * width = 32 bits
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * poly = 0x1EDC6F41
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reflect input bytes = true
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reflect output bytes = true
d4b0f84707225327c617c6838361d3cfb7762b34Jack Meng * -1 - uninitialized
d4b0f84707225327c617c6838361d3cfb7762b34Jack Meng * 0 - applicable
d4b0f84707225327c617c6838361d3cfb7762b34Jack Meng * others - NA
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi_crc32c - Steps through buffer one byte at at time, calculates
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reflected crc using table.
d4b0f84707225327c617c6838361d3cfb7762b34Jack Meng if (hd_crc32_avail((uint32_t *)iscsi_crc32c_table) == B_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte crc = iscsi_crc32c_table[(crc ^ *buffer++) & 0xFFL] ^
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte result = ((byte0 << 24) | (byte1 << 16) | (byte2 << 8) | byte3);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _BIG_ENDIAN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi_crc32c_continued - Continues stepping through buffer one
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * byte at at time, calculates reflected crc using table.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_crc32c_continued(void *address, unsigned long length, uint32_t crc)
d4b0f84707225327c617c6838361d3cfb7762b34Jack Meng if (hd_crc32_avail((uint32_t *)iscsi_crc32c_table) == B_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte crc = ((byte3 << 24) | (byte2 << 16) | (byte1 << 8) | byte0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte crc = iscsi_crc32c_table[(crc ^ *buffer++) & 0xFFL] ^
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte result = ((byte0 << 24) | (byte1 << 16) | (byte2 << 8) | byte3);