Skip to content

Commit

Permalink
control/server.py: Enable DSA to offload and accelerate CRC calculation
Browse files Browse the repository at this point in the history
Signed-off-by: Yin Congmin <congmin.yin@intel.com>
  • Loading branch information
CongMinYin authored and Alexander Indenbaum committed Sep 9, 2024
1 parent 33c320d commit d00e37e
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ SPDK_URL="https://spdk.io"

SPDK_PKGDEP_ARGS="--rbd"
# check spdk/configure --help
SPDK_CONFIGURE_ARGS="--with-rbd --disable-tests --disable-unit-tests --disable-examples --enable-debug"
SPDK_CONFIGURE_ARGS="--with-rbd --with-idxd --disable-tests --disable-unit-tests --disable-examples --enable-debug"
SPDK_TARGET_ARCH="x86-64-v2"
SPDK_MAKEFLAGS=
SPDK_CENTOS_BASE="https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/"
Expand Down
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,72 @@ sh -c 'echo 4096 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages'
This is automatically done in the `make setup` step. The amount of hugepages can be configured with `make setup HUGEPAGES=512`.
### Enable DSA to offload and accelerate CRC calculation
Intel® Data Streaming Accelerator (Intel® DSA) can generate and test CRC checksum or Data Integrity Field (DIF) on the memory region to support usages typical with storage and networking applications. This feature has already been implemented in SPDK. Enabling this feature allows for offloading and accelerating CRC calculations in NVMe-oF.
#### DSA Configuration
```bash
[spdk]
enable_dsa = True
```
#### Enable DSA in containers using vfio driver
Refer: [SPDK System Configuration User Guide: Device access](https://spdk.io/doc/system_configuration.html#system_configuration_nonroot_device_access).
1. Load `vfio` and `vfio-pci` drivers. Enable `IOMMU`.
2. Use DPDK to bind DSA as `vfio-pci`. In `ceph-nvmeof` directory, execute:
```bash
./spdk/dpdk/usertools/dpdk-devbind.py -s
```
The output may include:
```bash
DMA devices using DPDK-compatible driver
========================================
0000:6a:01.0 'Device 0b25' drv=vfio-pci unused=idxd
0000:e7:01.0 'Device 0b25' drv=vfio-pci unused=idxd
```
If the driver is not `vfio-pci`, bind it to this. Execute:
```bash
./spdk/dpdk/usertools/dpdk-devbind.py -u 0000:6a:01.0 0000:e7:01.0
./spdk/dpdk/usertools/dpdk-devbind.py -b vfio-pci 0000:6a:01.0 0000:e7:01.0
```
3. Check the IOMMU group of DSA devices:
```bash
readlink "/sys/bus/pci/devices/0000:6a:01.0/iommu_group"
```
The output should be e.g. `../../../kernel/iommu_groups/49`
4. update docker-compose.yaml:
```bash
nvmeof-base:
devices:
- /dev/vfio/vfio:/dev/vfio/vfio
- /dev/vfio/49:/dev/vfio/49
- /dev/vfio/250:/dev/vfio/250
volumes:
cap_add:
- IPC_LOCK # DMA pinning
```
Then run `make up` to start container. If DSA is successfully enabled, the following logs can be seen:
```bash
accel_dsa_rpc.c: 50:rpc_dsa_scan_accel_module: *NOTICE*: Enabled DSA user-mode
```
## Development
### Set-up
Expand Down
3 changes: 3 additions & 0 deletions ceph-nvmeof.conf
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ tgt_path = /usr/local/bin/nvmf_tgt
timeout = 60.0
#log_level = WARNING

# True / False to enable dsa
# enable_dsa = False

# Example value: -m 0x3 -L all
# tgt_cmd_extra_args =

Expand Down
10 changes: 10 additions & 0 deletions control/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,11 @@ def _start_spdk(self, omap_state):
"spdk", "tgt_cmd_extra_args", "")
cmd = [spdk_tgt_path, "-u", "-r", self.spdk_rpc_socket_path]

spdk_tgt_dsa = self.config.getboolean_with_default("spdk", "enable_dsa", False)
if spdk_tgt_dsa:
self.logger.info(f"Start SPDK, but wait for DSA detection before initialization")
cmd = [spdk_tgt_path, "-r", self.spdk_rpc_socket_path, "--wait-for-rpc"]

# Add extra args from the conf file
if spdk_tgt_cmd_extra_args:
cmd += shlex.split(spdk_tgt_cmd_extra_args)
Expand Down Expand Up @@ -434,6 +439,11 @@ def _start_spdk(self, omap_state):
log_level=protocol_log_level,
conn_retries=conn_retries,
)
if spdk_tgt_dsa:
# init dsa
spdk.rpc.dsa.dsa_scan_accel_module(self.spdk_rpc_client)
spdk.rpc.framework_start_init(self.spdk_rpc_client)
self.logger.info(f"SPDK with DSA started")
except Exception:
self.logger.exception(f"Unable to initialize SPDK")
raise
Expand Down

0 comments on commit d00e37e

Please sign in to comment.