util/crc32c: Add spdk_crc32c_iov_update.
Purpose: To support caculating crc32c for iovs. Change-Id: I7ea6d8b71ea2cf6e8b81903439787870923b9bef Signed-off-by: Ziye Yang <ziye.yang@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8093 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
ee8f6dd1d5
commit
b85127cc6f
@ -14,6 +14,11 @@ Updated DPDK submodule to DPDK 21.02.
|
|||||||
Remove the probe_cb parameter in spdk_idxd_probe function. And remove the definition
|
Remove the probe_cb parameter in spdk_idxd_probe function. And remove the definition
|
||||||
of spdk_idxd_probe_cb function pointer. It should be implemented in idxd_user.c.
|
of spdk_idxd_probe_cb function pointer. It should be implemented in idxd_user.c.
|
||||||
|
|
||||||
|
### util
|
||||||
|
|
||||||
|
`spdk_crc32c_iov_update` function was added to support calculating the crc32c of the
|
||||||
|
iovs.
|
||||||
|
|
||||||
### nvmf
|
### nvmf
|
||||||
|
|
||||||
Added `min_cntlid` and `max_cntlid` to `nvmf_create_subsystem` to limit the controller ID range.
|
Added `min_cntlid` and `max_cntlid` to `nvmf_create_subsystem` to limit the controller ID range.
|
||||||
|
@ -559,20 +559,6 @@ batch_done(void *cb_arg, int status)
|
|||||||
spdk_thread_send_msg(worker_batch->worker->thread, _batch_done, worker_batch);
|
spdk_thread_send_msg(worker_batch->worker->thread, _batch_done, worker_batch);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t
|
|
||||||
_update_crc32c_iov(struct iovec *iov, int iovcnt, uint32_t crc32c)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < iovcnt; i++) {
|
|
||||||
assert(iov[i].iov_base != NULL);
|
|
||||||
assert(iov[i].iov_len != 0);
|
|
||||||
crc32c = spdk_crc32c_update(iov[i].iov_base, iov[i].iov_len, crc32c);
|
|
||||||
|
|
||||||
}
|
|
||||||
return crc32c;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_accel_done(void *arg1)
|
_accel_done(void *arg1)
|
||||||
{
|
{
|
||||||
@ -586,7 +572,7 @@ _accel_done(void *arg1)
|
|||||||
if (g_verify && task->status == 0) {
|
if (g_verify && task->status == 0) {
|
||||||
switch (g_workload_selection) {
|
switch (g_workload_selection) {
|
||||||
case ACCEL_CRC32C:
|
case ACCEL_CRC32C:
|
||||||
sw_crc32c = _update_crc32c_iov(task->iovs, task->iov_cnt, ~g_crc32c_seed);
|
sw_crc32c = spdk_crc32c_iov_update(task->iovs, task->iov_cnt, ~g_crc32c_seed);
|
||||||
if (*(uint32_t *)task->dst != sw_crc32c) {
|
if (*(uint32_t *)task->dst != sw_crc32c) {
|
||||||
SPDK_NOTICELOG("CRC-32C miscompare\n");
|
SPDK_NOTICELOG("CRC-32C miscompare\n");
|
||||||
worker->xfer_failed++;
|
worker->xfer_failed++;
|
||||||
|
@ -66,6 +66,16 @@ uint32_t spdk_crc32_ieee_update(const void *buf, size_t len, uint32_t crc);
|
|||||||
*/
|
*/
|
||||||
uint32_t spdk_crc32c_update(const void *buf, size_t len, uint32_t crc);
|
uint32_t spdk_crc32c_update(const void *buf, size_t len, uint32_t crc);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate a partial CRC-32C checksum.
|
||||||
|
*
|
||||||
|
* \param iov Data buffer vectors to checksum.
|
||||||
|
* \param iovcnt size of iov parameter.
|
||||||
|
* \param crc32c Previous CRC-32C value.
|
||||||
|
* \return Updated CRC-32C value.
|
||||||
|
*/
|
||||||
|
uint32_t spdk_crc32c_iov_update(struct iovec *iov, int iovcnt, uint32_t crc32c);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -200,20 +200,6 @@ nvme_tcp_pdu_calc_header_digest(struct nvme_tcp_pdu *pdu)
|
|||||||
return crc32c;
|
return crc32c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t
|
|
||||||
_update_crc32c_iov(struct iovec *iov, int iovcnt, uint32_t crc32c)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < iovcnt; i++) {
|
|
||||||
assert(iov[i].iov_base != NULL);
|
|
||||||
assert(iov[i].iov_len != 0);
|
|
||||||
crc32c = spdk_crc32c_update(iov[i].iov_base, iov[i].iov_len, crc32c);
|
|
||||||
}
|
|
||||||
|
|
||||||
return crc32c;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint32_t
|
static uint32_t
|
||||||
nvme_tcp_pdu_calc_data_digest(struct nvme_tcp_pdu *pdu)
|
nvme_tcp_pdu_calc_data_digest(struct nvme_tcp_pdu *pdu)
|
||||||
{
|
{
|
||||||
@ -223,7 +209,7 @@ nvme_tcp_pdu_calc_data_digest(struct nvme_tcp_pdu *pdu)
|
|||||||
assert(pdu->data_len != 0);
|
assert(pdu->data_len != 0);
|
||||||
|
|
||||||
if (spdk_likely(!pdu->dif_ctx)) {
|
if (spdk_likely(!pdu->dif_ctx)) {
|
||||||
crc32c = _update_crc32c_iov(pdu->data_iov, pdu->data_iovcnt, crc32c);
|
crc32c = spdk_crc32c_iov_update(pdu->data_iov, pdu->data_iovcnt, crc32c);
|
||||||
} else {
|
} else {
|
||||||
spdk_dif_update_crc32c_stream(pdu->data_iov, pdu->data_iovcnt,
|
spdk_dif_update_crc32c_stream(pdu->data_iov, pdu->data_iovcnt,
|
||||||
0, pdu->data_len, &crc32c, pdu->dif_ctx);
|
0, pdu->data_len, &crc32c, pdu->dif_ctx);
|
||||||
|
@ -131,3 +131,21 @@ spdk_crc32c_update(const void *buf, size_t len, uint32_t crc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
uint32_t
|
||||||
|
spdk_crc32c_iov_update(struct iovec *iov, int iovcnt, uint32_t crc32c)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (iov == NULL) {
|
||||||
|
return crc32c;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < iovcnt; i++) {
|
||||||
|
assert(iov[i].iov_base != NULL);
|
||||||
|
assert(iov[i].iov_len != 0);
|
||||||
|
crc32c = spdk_crc32c_update(iov[i].iov_base, iov[i].iov_len, crc32c);
|
||||||
|
}
|
||||||
|
|
||||||
|
return crc32c;
|
||||||
|
}
|
||||||
|
@ -61,6 +61,7 @@
|
|||||||
# public functions in crc32.h
|
# public functions in crc32.h
|
||||||
spdk_crc32_ieee_update;
|
spdk_crc32_ieee_update;
|
||||||
spdk_crc32c_update;
|
spdk_crc32c_update;
|
||||||
|
spdk_crc32c_iov_update;
|
||||||
|
|
||||||
# public functions in dif.h
|
# public functions in dif.h
|
||||||
spdk_dif_ctx_init;
|
spdk_dif_ctx_init;
|
||||||
|
@ -42,7 +42,8 @@ static void
|
|||||||
test_crc32c(void)
|
test_crc32c(void)
|
||||||
{
|
{
|
||||||
uint32_t crc;
|
uint32_t crc;
|
||||||
char buf[1024];
|
char buf[1024], buf1[1024];
|
||||||
|
struct iovec iov[2] = {};
|
||||||
|
|
||||||
/* Verify a string's CRC32-C value against the known correct result. */
|
/* Verify a string's CRC32-C value against the known correct result. */
|
||||||
snprintf(buf, sizeof(buf), "%s", "Hello world!");
|
snprintf(buf, sizeof(buf), "%s", "Hello world!");
|
||||||
@ -51,6 +52,26 @@ test_crc32c(void)
|
|||||||
crc ^= 0xFFFFFFFFu;
|
crc ^= 0xFFFFFFFFu;
|
||||||
CU_ASSERT(crc == 0x7b98e751);
|
CU_ASSERT(crc == 0x7b98e751);
|
||||||
|
|
||||||
|
crc = 0xFFFFFFFFu;
|
||||||
|
iov[0].iov_base = buf;
|
||||||
|
iov[0].iov_len = strlen(buf);
|
||||||
|
crc = spdk_crc32c_iov_update(iov, 1, crc);
|
||||||
|
crc ^= 0xFFFFFFFFu;
|
||||||
|
CU_ASSERT(crc == 0x7b98e751);
|
||||||
|
|
||||||
|
crc = 0xFFFFFFFFu;
|
||||||
|
snprintf(buf, sizeof(buf), "%s", "Hello");
|
||||||
|
iov[0].iov_base = buf;
|
||||||
|
iov[0].iov_len = strlen(buf);
|
||||||
|
|
||||||
|
snprintf(buf1, sizeof(buf1), "%s", " world!");
|
||||||
|
iov[1].iov_base = buf1;
|
||||||
|
iov[1].iov_len = strlen(buf1);
|
||||||
|
|
||||||
|
crc = spdk_crc32c_iov_update(iov, 2, crc);
|
||||||
|
crc ^= 0xFFFFFFFFu;
|
||||||
|
CU_ASSERT(crc == 0x7b98e751);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The main loop of the optimized CRC32-C implementation processes data in 8-byte blocks,
|
* The main loop of the optimized CRC32-C implementation processes data in 8-byte blocks,
|
||||||
* followed by a loop to handle the 0-7 trailing bytes.
|
* followed by a loop to handle the 0-7 trailing bytes.
|
||||||
|
Loading…
Reference in New Issue
Block a user