xref: /spdk/include/spdk/crc32.h (revision 5d025489b81a698ec9af7a6b19d25c48cd5b7ac1)
1 /*   SPDX-License-Identifier: BSD-3-Clause
2  *   Copyright (C) 2017 Intel Corporation.
3  *   All rights reserved.
4  */
5 
6 /**
7  * \file
8  * CRC-32 utility functions
9  */
10 
11 #ifndef SPDK_CRC32_H
12 #define SPDK_CRC32_H
13 
14 #include "spdk/stdinc.h"
15 #include "spdk/config.h"
16 
17 #define SPDK_CRC32_SIZE_BYTES 4
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 /**
24  * Calculate a partial CRC-32 IEEE checksum.
25  *
26  * \param buf Data buffer to checksum.
27  * \param len Length of buf in bytes.
28  * \param crc Previous CRC-32 value.
29  * \return Updated CRC-32 value.
30  */
31 uint32_t spdk_crc32_ieee_update(const void *buf, size_t len, uint32_t crc);
32 
33 /**
34  * Calculate a partial CRC-32C checksum.
35  *
36  * \param buf Data buffer to checksum.
37  * \param len Length of buf in bytes.
38  * \param crc Previous CRC-32C value.
39  * \return Updated CRC-32C value.
40  */
41 uint32_t spdk_crc32c_update(const void *buf, size_t len, uint32_t crc);
42 
43 /**
44  * Calculate a partial CRC-32C checksum.
45  *
46  * \param iov Data buffer vectors to checksum.
47  * \param iovcnt size of iov parameter.
48  * \param crc32c Previous CRC-32C value.
49  * \return Updated CRC-32C value.
50  */
51 uint32_t spdk_crc32c_iov_update(struct iovec *iov, int iovcnt, uint32_t crc32c);
52 
53 /**
54  * Calculate a CRC-32C checksum, for NVMe Protection Information
55  *
56  * \param buf Data buffer to checksum.
57  * \param len Length of buf in bytes.
58  * \param crc Previous CRC-32C value.
59  * \return Updated CRC-32C value.
60  */
61 uint32_t spdk_crc32c_nvme(const void *buf, size_t len, uint32_t crc);
62 
63 #ifdef __cplusplus
64 }
65 #endif
66 
67 #endif /* SPDK_CRC32_H */
68