/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <nxge_fflp_hash.h>
/*
* The crc32c algorithms are taken from sctp_crc32 implementation
* common/inet/sctp_crc32.{c,h}
*
*/
/*
* Fast CRC32C calculation algorithm. The basic idea is to look at it
* four bytes (one word) at a time, using four tables. The
* standard algorithm in RFC 3309 uses one table.
*/
/*
* polynomial 0x1EDC6F41L
*/
/* CRC-CCITT Polynomial */
/* The four CRC32c tables. */
/* The four CRC-CCITT tables. */
/* the four tables for H1 Computation */
static uint32_t
{
int i;
for (i = 0; i < 32; i++) {
if (b & 1) {
}
b >>= 1;
}
return (rw);
}
static uint32_t
{
return (((w >> 24) | ((w >> 8) & 0xff00) |
((w << 8) & 0xff0000) | (w << 24)));
}
/*
* reference crc-ccitt implementation
*/
{
crc << 1;
mcrc <<= 1;
}
}
/*
* Initialize the crc32c tables.
*/
void
nxge_crc32c_init(void)
{
}
#ifdef _BIG_ENDIAN
#else
#endif
}
}
}
/*
* Initialize the crc-ccitt tables.
*/
void
nxge_crc_ccitt_init(void)
{
}
#ifdef _BIG_ENDIAN
#else
#endif
}
}
}
/*
* Lookup the crc32c for a byte stream
*/
static void
{
int i;
for (i = 0; i < len; i++) {
#ifdef _BIG_ENDIAN
#else
#endif
}
}
/*
* Lookup the crc-ccitt for a byte stream
*/
static void
{
int i;
for (i = 0; i < len; i++) {
#ifdef _BIG_ENDIAN
#else
#endif
}
}
/*
* Lookup the crc32c for a 32 bit word stream
* Lookup is done fro the 4 bytes in parallel
* from the tables computed earlier
*
*/
static void
{
int i;
for (i = 0; i < len; i++) {
}
}
/*
* Lookup the crc-ccitt for a stream of bytes
*
* Since the parallel lookup version doesn't work yet,
* use the byte stream version (lookup crc for a byte
* at a time
*
*/
{
return (crc16);
}
/*
* Lookup the crc32c for a stream of bytes
*
* Tries to lookup the CRC on 4 byte words
* If the buffer is not 4 byte aligned, first compute
* with byte lookup until aligned. Then compute crc
* for each 4 bytes. If there are bytes left at the end of
* the buffer, then perform a byte lookup for the remaining bytes
*
*
*/
{
int rem;
if (rem != 0) {
}
}
if (len > 3) {
}
if (rem != 0) {
}
return (crc32);
}
void
{
}
}
}
}
/*
* Reference Neptune H1 computation function
*
* It is a slightly modified implementation of
* CRC-32C implementation
*/
{
}
}
return (crc_h1);
}
/*
* table based implementation
* uses 4 four tables in parallel
* 1 for each byte of a 32 bit word
*
* This is the default h1 computing function
*
*/
{
for (i = 0; i < length / 4; i++) {
#ifdef _BIG_ENDIAN
#else
#endif
}
return (crch1);
}
/*
* table based implementation
* uses a single table and computes h1 for a byte
* at a time.
*
*/
{
for (i = 0; i < length; i++) {
}
return (crch1);
}