]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/dpdk/drivers/net/nfp/nfpcore/nfp_crc.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Netronome Systems, Inc.
11 static inline uint32_t
12 nfp_crc32_be_generic(uint32_t crc
, unsigned char const *p
, size_t len
,
18 for (i
= 0; i
< 8; i
++)
19 crc
= (crc
<< 1) ^ ((crc
& 0x80000000) ? polynomial
:
25 static inline uint32_t
26 nfp_crc32_be(uint32_t crc
, unsigned char const *p
, size_t len
)
28 return nfp_crc32_be_generic(crc
, p
, len
, CRCPOLY_BE
);
32 nfp_crc32_posix_end(uint32_t crc
, size_t total_len
)
34 /* Extend with the length of the string. */
35 while (total_len
!= 0) {
36 uint8_t c
= total_len
& 0xff;
38 crc
= nfp_crc32_be(crc
, &c
, 1);
46 nfp_crc32_posix(const void *buff
, size_t len
)
48 return nfp_crc32_posix_end(nfp_crc32_be(0, buff
, len
), len
);