0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
};
-unsigned short crc16(const void *buffer, unsigned int len)
+unsigned short fio_crc16(const void *buffer, unsigned int len)
{
const unsigned char *cp = (const unsigned char *) buffer;
unsigned short crc = 0;
extern unsigned short const crc16_table[256];
-extern unsigned short crc16(const void *buffer, unsigned int len);
+extern unsigned short fio_crc16(const void *buffer, unsigned int len);
static inline unsigned short crc16_byte(unsigned short crc,
const unsigned char data)
0xA2F33668, 0xBCB4666D, 0xB8757BDA, 0xB5365D03, 0xB1F740B4
};
-uint32_t crc32(const void *buffer, unsigned long length)
+uint32_t fio_crc32(const void *buffer, unsigned long length)
{
const unsigned char *cp = (const unsigned char *) buffer;
uint32_t crc = 0;
#ifndef CRC32_H
#define CRC32_H
-extern uint32_t crc32(const void * const, unsigned long);
+extern uint32_t fio_crc32(const void * const, unsigned long);
#endif
}
#endif
-static inline uint32_t crc32c(unsigned char const *buf, unsigned long len)
+static inline uint32_t fio_crc32c(unsigned char const *buf, unsigned long len)
{
if (crc32c_intel_available)
return crc32c_intel(buf, len);
0x29b7d047efec8728ULL
};
-unsigned long long crc64(const unsigned char *buffer, unsigned long length)
+unsigned long long fio_crc64(const unsigned char *buffer, unsigned long length)
{
unsigned long long crc = 0;
#ifndef CRC64_H
#define CRC64_H
-unsigned long long crc64(const unsigned char *, unsigned long);
+unsigned long long fio_crc64(const unsigned char *, unsigned long);
#endif
0x46, 0x4f, 0x54, 0x5d, 0x62, 0x6b, 0x70, 0x79
};
-unsigned char crc7(const unsigned char *buffer, unsigned int len)
+unsigned char fio_crc7(const unsigned char *buffer, unsigned int len)
{
unsigned char crc = 0;
return crc7_syndrome_table[(crc << 1) ^ data];
}
-extern unsigned char crc7(const unsigned char *buffer, unsigned int len);
+extern unsigned char fio_crc7(const unsigned char *buffer, unsigned int len);
#endif
hash[3] += d;
}
-void md5_init(struct md5_ctx *mctx)
+void fio_md5_init(struct fio_md5_ctx *mctx)
{
mctx->hash[0] = 0x67452301;
mctx->hash[1] = 0xefcdab89;
mctx->hash[3] = 0x10325476;
}
-void md5_update(struct md5_ctx *mctx, const uint8_t *data, unsigned int len)
+void fio_md5_update(struct fio_md5_ctx *mctx, const uint8_t *data,
+ unsigned int len)
{
const uint32_t avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f);
#define MD5STEP(f, w, x, y, z, in, s) \
(w += f(x, y, z) + in, w = (w<<s | w>>(32-s)) + x)
-struct md5_ctx {
+struct fio_md5_ctx {
uint32_t *hash;
uint32_t block[MD5_BLOCK_WORDS];
uint64_t byte_count;
};
-extern void md5_update(struct md5_ctx *, const uint8_t *, unsigned int);
-extern void md5_init(struct md5_ctx *);
+extern void fio_md5_update(struct fio_md5_ctx *, const uint8_t *, unsigned int);
+extern void fio_md5_init(struct fio_md5_ctx *);
#endif
#include "sha1.h"
/* Hash one 64-byte block of data */
-static void blk_SHA1Block(struct sha1_ctx *ctx, const unsigned int *data);
+static void blk_SHA1Block(struct fio_sha1_ctx *ctx, const unsigned int *data);
-void sha1_init(struct sha1_ctx *ctx)
+void fio_sha1_init(struct fio_sha1_ctx *ctx)
{
ctx->size = 0;
ctx->H[4] = 0xc3d2e1f0;
}
-void sha1_update(struct sha1_ctx *ctx, const void *data, unsigned long len)
+void fio_sha1_update(struct fio_sha1_ctx *ctx, const void *data,
+ unsigned long len)
{
int lenW = ctx->size & 63;
memcpy(ctx->W, data, len);
}
-void sha1_final(unsigned char hashout[20], struct sha1_ctx *ctx)
+void fio_sha1_final(unsigned char hashout[20], struct fio_sha1_ctx *ctx)
{
static const unsigned char pad[64] = { 0x80 };
unsigned int padlen[2];
padlen[1] = htonl(ctx->size << 3);
i = ctx->size & 63;
- sha1_update(ctx, pad, 1+ (63 & (55 - i)));
- sha1_update(ctx, padlen, 8);
+ fio_sha1_update(ctx, pad, 1+ (63 & (55 - i)));
+ fio_sha1_update(ctx, padlen, 8);
/* Output hash
*/
#define T_40_59(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, ((B&C)+(D&(B^C))) , 0x8f1bbcdc, A, B, C, D, E )
#define T_60_79(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, (B^C^D) , 0xca62c1d6, A, B, C, D, E )
-static void blk_SHA1Block(struct sha1_ctx *ctx, const unsigned int *data)
+static void blk_SHA1Block(struct fio_sha1_ctx *ctx, const unsigned int *data)
{
unsigned int A,B,C,D,E;
unsigned int array[16];
* and to avoid unnecessary copies into the context array.
*/
-struct sha1_ctx {
+struct fio_sha1_ctx {
uint32_t *H;
unsigned int W[16];
unsigned long long size;
};
-void sha1_init(struct sha1_ctx *);
-void sha1_update(struct sha1_ctx *, const void *dataIn, unsigned long len);
-void sha1_final(unsigned char hashout[20], struct sha1_ctx *);
+void fio_sha1_init(struct fio_sha1_ctx *);
+void fio_sha1_update(struct fio_sha1_ctx *, const void *dataIn, unsigned long len);
+void fio_sha1_final(unsigned char hashout[20], struct fio_sha1_ctx *);
#endif
memset(W, 0, 64 * sizeof(uint32_t));
}
-void sha256_init(struct sha256_ctx *sctx)
+void fio_sha256_init(struct fio_sha256_ctx *sctx)
{
sctx->state[0] = H0;
sctx->state[1] = H1;
sctx->count[0] = sctx->count[1] = 0;
}
-void sha256_update(struct sha256_ctx *sctx, const uint8_t *data,
- unsigned int len)
+void fio_sha256_update(struct fio_sha256_ctx *sctx, const uint8_t *data,
+ unsigned int len)
{
unsigned int i, idx, part_len;
#ifndef FIO_SHA256_H
#define FIO_SHA256_H
-struct sha256_ctx {
+struct fio_sha256_ctx {
uint32_t count[2];
uint32_t state[8];
uint8_t *buf;
};
-void sha256_init(struct sha256_ctx *);
-void sha256_update(struct sha256_ctx *, const uint8_t *, unsigned int);
+void fio_sha256_init(struct fio_sha256_ctx *);
+void fio_sha256_update(struct fio_sha256_ctx *, const uint8_t *, unsigned int);
#endif
a = b = c = d = e = f = g = h = t1 = t2 = 0;
}
-void sha512_init(struct sha512_ctx *sctx)
+void fio_sha512_init(struct fio_sha512_ctx *sctx)
{
sctx->state[0] = H0;
sctx->state[1] = H1;
sctx->count[0] = sctx->count[1] = sctx->count[2] = sctx->count[3] = 0;
}
-void sha512_update(struct sha512_ctx *sctx, const uint8_t *data,
- unsigned int len)
+void fio_sha512_update(struct fio_sha512_ctx *sctx, const uint8_t *data,
+ unsigned int len)
{
unsigned int i, idx, part_len;
#ifndef FIO_SHA512_H
#define FIO_SHA512_H
-struct sha512_ctx {
+struct fio_sha512_ctx {
uint64_t state[8];
uint32_t count[4];
uint8_t *buf;
uint64_t W[80];
};
-void sha512_init(struct sha512_ctx *);
-void sha512_update(struct sha512_ctx *, const uint8_t *, unsigned int);
+void fio_sha512_init(struct fio_sha512_ctx *);
+void fio_sha512_update(struct fio_sha512_ctx *, const uint8_t *, unsigned int);
#endif
cmd->cmd_crc16 = le16_to_cpu(cmd->cmd_crc16);
cmd->pdu_crc16 = le16_to_cpu(cmd->pdu_crc16);
- crc = crc16(cmd, FIO_NET_CMD_CRC_SZ);
+ crc = fio_crc16(cmd, FIO_NET_CMD_CRC_SZ);
if (crc != cmd->cmd_crc16) {
log_err("fio: server bad crc on command (got %x, wanted %x)\n",
cmd->cmd_crc16, crc);
break;
/* Verify payload crc */
- crc = crc16(pdu, cmd.pdu_len);
+ crc = fio_crc16(pdu, cmd.pdu_len);
if (crc != cmd.pdu_crc16) {
log_err("fio: server bad crc on payload ");
log_err("(got %x, wanted %x)\n", cmd.pdu_crc16, crc);
{
uint32_t pdu_len;
- cmd->cmd_crc16 = __cpu_to_le16(crc16(cmd, FIO_NET_CMD_CRC_SZ));
+ cmd->cmd_crc16 = __cpu_to_le16(fio_crc16(cmd, FIO_NET_CMD_CRC_SZ));
pdu_len = le32_to_cpu(cmd->pdu_len);
if (pdu_len)
- cmd->pdu_crc16 = __cpu_to_le16(crc16(cmd->payload, pdu_len));
+ cmd->pdu_crc16 = __cpu_to_le16(fio_crc16(cmd->payload, pdu_len));
}
int fio_net_send_cmd(int fd, uint16_t opcode, const void *buf, off_t size,
void *p = io_u_verify_off(hdr, vc);
struct vhdr_sha512 *vh = hdr_priv(hdr);
uint8_t sha512[128];
- struct sha512_ctx sha512_ctx = {
+ struct fio_sha512_ctx sha512_ctx = {
.buf = sha512,
};
dprint(FD_VERIFY, "sha512 verify io_u %p, len %u\n", vc->io_u, hdr->len);
- sha512_init(&sha512_ctx);
- sha512_update(&sha512_ctx, p, hdr->len - hdr_size(hdr));
+ fio_sha512_init(&sha512_ctx);
+ fio_sha512_update(&sha512_ctx, p, hdr->len - hdr_size(hdr));
if (!memcmp(vh->sha512, sha512_ctx.buf, sizeof(sha512)))
return 0;
void *p = io_u_verify_off(hdr, vc);
struct vhdr_sha256 *vh = hdr_priv(hdr);
uint8_t sha256[64];
- struct sha256_ctx sha256_ctx = {
+ struct fio_sha256_ctx sha256_ctx = {
.buf = sha256,
};
dprint(FD_VERIFY, "sha256 verify io_u %p, len %u\n", vc->io_u, hdr->len);
- sha256_init(&sha256_ctx);
- sha256_update(&sha256_ctx, p, hdr->len - hdr_size(hdr));
+ fio_sha256_init(&sha256_ctx);
+ fio_sha256_update(&sha256_ctx, p, hdr->len - hdr_size(hdr));
if (!memcmp(vh->sha256, sha256_ctx.buf, sizeof(sha256)))
return 0;
void *p = io_u_verify_off(hdr, vc);
struct vhdr_sha1 *vh = hdr_priv(hdr);
uint32_t sha1[5];
- struct sha1_ctx sha1_ctx = {
+ struct fio_sha1_ctx sha1_ctx = {
.H = sha1,
};
dprint(FD_VERIFY, "sha1 verify io_u %p, len %u\n", vc->io_u, hdr->len);
- sha1_init(&sha1_ctx);
- sha1_update(&sha1_ctx, p, hdr->len - hdr_size(hdr));
+ fio_sha1_init(&sha1_ctx);
+ fio_sha1_update(&sha1_ctx, p, hdr->len - hdr_size(hdr));
if (!memcmp(vh->sha1, sha1_ctx.H, sizeof(sha1)))
return 0;
dprint(FD_VERIFY, "crc7 verify io_u %p, len %u\n", vc->io_u, hdr->len);
- c = crc7(p, hdr->len - hdr_size(hdr));
+ c = fio_crc7(p, hdr->len - hdr_size(hdr));
if (c == vh->crc7)
return 0;
dprint(FD_VERIFY, "crc16 verify io_u %p, len %u\n", vc->io_u, hdr->len);
- c = crc16(p, hdr->len - hdr_size(hdr));
+ c = fio_crc16(p, hdr->len - hdr_size(hdr));
if (c == vh->crc16)
return 0;
dprint(FD_VERIFY, "crc64 verify io_u %p, len %u\n", vc->io_u, hdr->len);
- c = crc64(p, hdr->len - hdr_size(hdr));
+ c = fio_crc64(p, hdr->len - hdr_size(hdr));
if (c == vh->crc64)
return 0;
dprint(FD_VERIFY, "crc32 verify io_u %p, len %u\n", vc->io_u, hdr->len);
- c = crc32(p, hdr->len - hdr_size(hdr));
+ c = fio_crc32(p, hdr->len - hdr_size(hdr));
if (c == vh->crc32)
return 0;
dprint(FD_VERIFY, "crc32c verify io_u %p, len %u\n", vc->io_u, hdr->len);
- c = crc32c(p, hdr->len - hdr_size(hdr));
+ c = fio_crc32c(p, hdr->len - hdr_size(hdr));
if (c == vh->crc32)
return 0;
void *p = io_u_verify_off(hdr, vc);
struct vhdr_md5 *vh = hdr_priv(hdr);
uint32_t hash[MD5_HASH_WORDS];
- struct md5_ctx md5_ctx = {
+ struct fio_md5_ctx md5_ctx = {
.hash = hash,
};
dprint(FD_VERIFY, "md5 verify io_u %p, len %u\n", vc->io_u, hdr->len);
- md5_init(&md5_ctx);
- md5_update(&md5_ctx, p, hdr->len - hdr_size(hdr));
+ fio_md5_init(&md5_ctx);
+ fio_md5_update(&md5_ctx, p, hdr->len - hdr_size(hdr));
if (!memcmp(vh->md5_digest, md5_ctx.hash, sizeof(hash)))
return 0;
if (hdr->magic != FIO_HDR_MAGIC)
return 0;
- crc = crc32c(p, offsetof(struct verify_header, crc32));
+ crc = fio_crc32c(p, offsetof(struct verify_header, crc32));
if (crc == hdr->crc32)
return 1;
static void fill_sha512(struct verify_header *hdr, void *p, unsigned int len)
{
struct vhdr_sha512 *vh = hdr_priv(hdr);
- struct sha512_ctx sha512_ctx = {
+ struct fio_sha512_ctx sha512_ctx = {
.buf = vh->sha512,
};
- sha512_init(&sha512_ctx);
- sha512_update(&sha512_ctx, p, len);
+ fio_sha512_init(&sha512_ctx);
+ fio_sha512_update(&sha512_ctx, p, len);
}
static void fill_sha256(struct verify_header *hdr, void *p, unsigned int len)
{
struct vhdr_sha256 *vh = hdr_priv(hdr);
- struct sha256_ctx sha256_ctx = {
+ struct fio_sha256_ctx sha256_ctx = {
.buf = vh->sha256,
};
- sha256_init(&sha256_ctx);
- sha256_update(&sha256_ctx, p, len);
+ fio_sha256_init(&sha256_ctx);
+ fio_sha256_update(&sha256_ctx, p, len);
}
static void fill_sha1(struct verify_header *hdr, void *p, unsigned int len)
{
struct vhdr_sha1 *vh = hdr_priv(hdr);
- struct sha1_ctx sha1_ctx = {
+ struct fio_sha1_ctx sha1_ctx = {
.H = vh->sha1,
};
- sha1_init(&sha1_ctx);
- sha1_update(&sha1_ctx, p, len);
+ fio_sha1_init(&sha1_ctx);
+ fio_sha1_update(&sha1_ctx, p, len);
}
static void fill_crc7(struct verify_header *hdr, void *p, unsigned int len)
{
struct vhdr_crc7 *vh = hdr_priv(hdr);
- vh->crc7 = crc7(p, len);
+ vh->crc7 = fio_crc7(p, len);
}
static void fill_crc16(struct verify_header *hdr, void *p, unsigned int len)
{
struct vhdr_crc16 *vh = hdr_priv(hdr);
- vh->crc16 = crc16(p, len);
+ vh->crc16 = fio_crc16(p, len);
}
static void fill_crc32(struct verify_header *hdr, void *p, unsigned int len)
{
struct vhdr_crc32 *vh = hdr_priv(hdr);
- vh->crc32 = crc32(p, len);
+ vh->crc32 = fio_crc32(p, len);
}
static void fill_crc32c(struct verify_header *hdr, void *p, unsigned int len)
{
struct vhdr_crc32 *vh = hdr_priv(hdr);
- vh->crc32 = crc32c(p, len);
+ vh->crc32 = fio_crc32c(p, len);
}
static void fill_crc64(struct verify_header *hdr, void *p, unsigned int len)
{
struct vhdr_crc64 *vh = hdr_priv(hdr);
- vh->crc64 = crc64(p, len);
+ vh->crc64 = fio_crc64(p, len);
}
static void fill_md5(struct verify_header *hdr, void *p, unsigned int len)
{
struct vhdr_md5 *vh = hdr_priv(hdr);
- struct md5_ctx md5_ctx = {
+ struct fio_md5_ctx md5_ctx = {
.hash = (uint32_t *) vh->md5_digest,
};
- md5_init(&md5_ctx);
- md5_update(&md5_ctx, p, len);
+ fio_md5_init(&md5_ctx);
+ fio_md5_update(&md5_ctx, p, len);
}
static void populate_hdr(struct thread_data *td, struct io_u *io_u,
hdr->verify_type = td->o.verify;
hdr->len = header_len;
hdr->rand_seed = io_u->rand_seed;
- hdr->crc32 = crc32c(p, offsetof(struct verify_header, crc32));
+ hdr->crc32 = fio_crc32c(p, offsetof(struct verify_header, crc32));
data_len = header_len - hdr_size(hdr);