import "github.com/intel/ixl-go/crc"
Package crc provides CRC calculation functions which leverage IAA hardware.
- Constants
- func Ready() bool
- func YieldProcessor(c *CRC32C)
- type CRC32C
- type CRC32COption
- type Calculator
const (
// ISO polynomial value
ISO uint64 = 0xD800000000000000
// ECMA polynomial value
ECMA uint64 = 0xC96C5795D7870F42
)
const (
// IEEE polynomial value
IEEE uint32 = 0xedb88320
// Castagnoli polynomial value
Castagnoli uint32 = 0x82f63b78
// Koopman polynomial value
Koopman uint32 = 0xeb31d82e
)
const (
// CCITT polynomial value
CCITT uint16 = 0x8408
// T10DIF polynomial value
T10DIF uint16 = 0x8BB7
)
func Ready
func Ready() bool
Ready returns true if the device is ready for use.
func YieldProcessor
func YieldProcessor(c *CRC32C)
YieldProcessor yields the processor while submitting the CRC job to hardware, instead of busy polling the result.
type CRC32C
CRC32C represents a CRC32C calculator. This calculator uses Castagnoli's polynomial, which is widely used in iSCSI. The calculator is compliant with the hash.Hash32 interface.
type CRC32C struct {
// contains filtered or unexported fields
}
func NewCRC32C
func NewCRC32C(opts ...CRC32COption) (*CRC32C, error)
NewCRC32C function initializes a new CRC32C hasher. This hasher is compliant with the hash.Hash32 interface. Returns an error if no hardware device is detected (Intel® DSA).
func (*CRC32C) BlockSize
func (c *CRC32C) BlockSize() int
BlockSize returns the hash's underlying block size. The Write method must be able to accept any amount of data, but it may operate more efficiently if all writes are a multiple of the block size.
func (*CRC32C) Reset
func (c *CRC32C) Reset()
Reset resets the Hash to its initial state.
func (*CRC32C) Size
func (c *CRC32C) Size() int
Size returns the number of bytes Sum will return.
func (*CRC32C) Sum
func (c *CRC32C) Sum(b []byte) []byte
Sum appends the current hash to b and returns the resulting slice. It does not change the underlying hash state.
func (*CRC32C) Sum32
func (c *CRC32C) Sum32() uint32
func (*CRC32C) Write
func (c *CRC32C) Write(data []byte) (n int, err error)
type CRC32COption
type CRC32COption func(c *CRC32C)
type Calculator
Calculator is used for CRC64 calculation Notice: the data size should be less than your device's max_transfer_size.
type Calculator struct {
// contains filtered or unexported fields
}
func NewCalculator
func NewCalculator() (*Calculator, error)
NewCalculator creates a new Calculator to be used for CRC64 calculation
func (*Calculator) CheckSum16
func (calc *Calculator) CheckSum16(data []byte, poly uint16) (uint16, error)
CheckSum16 calculates the CRC16 checksum for the given data and polynomial value
func (*Calculator) CheckSum32
func (calc *Calculator) CheckSum32(data []byte, poly uint32) (uint32, error)
CheckSum32 calculates the CRC32 checksum for the given data and polynomial value
func (*Calculator) CheckSum64
func (calc *Calculator) CheckSum64(data []byte, poly uint64) (uint64, error)
CheckSum64 calculates the CRC64 checksum for the given data and polynomial value
Generated by gomarkdoc