Rate This Document
Findability
Accuracy
Completeness
Readability

Using the SPDK CRC Feature

SPDK has built-in isal-crc32c and isal-crc16 algorithms. In the spdk21.01.1-for-KAE branch, the Huawei-developed KSAL-CRC algorithm is introduced, providing 20% higher performance than the CRC implementation in isal 2.29. This section describes how to perform performance and system tests on KSAL-CRC in SPDK.

Performance Test

  1. To use the KSAL-CRC algorithm, add the compilation option --with-ksal in step 7 of Compiling SPDK and then run the make -j command to perform compilation.
  2. Perform a unit test to verify the ksal-crc16 performance. Access the crc16 unit test module in SPDK and run the crc16_ut executable program to verify the performance.
    cd /home/spdk/test/unit/lib/util/crc16.c/
    ./crc16_ut

    By default, ./crc16_ut performs 100,000 crc16 calculations on a 4 KB data block and obtain the average value. One CRC calculation takes only nanoseconds. To ensure a stable and correct value, you need to obtain the average value of a large number of CRC calculations. During execution, you can specify the block size, number of calculations, and checksum verification (to check whether the calculation result is correct). For details, run the ./crc16_ut -h command.

  3. Perform a unit test to verify the ksal-crc32c performance. Access the crc32c unit test module in SPDK and run the crc32c_ut executable program to verify the performance.
    cd /home/spdk/test/unit/lib/util/crc32c.c/
    ./crc32c_ut
  4. Switch to the isal environment. Go to the spdk directory, add the compilation option --without-ksal, and run the make -j command to perform compilation.
    cd /home/spdk
    ./configure --with-crypto --with-reduce --without-ksal --with-crypto_openssl
    make -j
  5. Verify the isal-crc16 and crc32c performance by referring to 2 and 3.

System Test

  1. Start the SPDK process.
    ./build/bin/nvmf_tgt --wait-for-rpc
  2. Initialize the framework.
    ./scripts/rpc.py framework_start_init
  3. Create a test bdev.
    ./scripts/rpc.py bdev_aio_create /dev/sda sda
    ./scripts/rpc.py bdev_crypto_create sda crypto crypto_openssl 0123456789123456 -c AES_CBC

    In this example, a crypto bdev is created. You can also create another bdev for testing.

  4. Create an NVMe drive and mount it to the system.
    ./scripts/rpc.py nvmf_create_transport -t TCP -u 16384 -m 8 -c 8192
    ./scripts/rpc.py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode2 -a -s SPDK00000000000001 -d SPDK_Controller1
    ./scripts/rpc.py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode2 crypto
    ./scripts/rpc.py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode2 -t TCP -a 90.90.82.112 -s 4420
    nvme discover -t tcp -a 90.90.82.112 -s 4420
    nvme connect -t tcp -n "nqn.2016-06.io.spdk:cnode2" -a 90.90.82.112 -s 4420 -g -G
  5. Use the fio tool to test the read and write performance of the mounted NVMe drive.
    fio -filename=/dev/nvme0n1 -direct=1 -iodepth=64 -thread -rw=randwrite -ioengine=libaio -bs=4k -size=10G -numjobs=1 -group_reporting -name=mytest --verify_pattern=0x12345678

    The read and write data delivered by fio is transmitted to the NVMe drive over the NVMe-oF protocol. In SPDK, NVMe-oF uses the CRC algorithm to verify each protocol data unit (PDU) to be transmitted. Therefore, each I/O operation requires a CRC calculation. During fio execution, you can check whether KSAL-CRC is enabled by using the perf tool to capture function hotspot information of the SPDK process and then check whether the KsalCrc32c function exists in the information. If yes, KSAL-CRC is enabled.