Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ all: libdto dto-test-wodto
DML_LIB_CXX=-D_GNU_SOURCE

libdto: dto.c
gcc -shared -fPIC -Wl,-soname,libdto.so dto.c $(DML_LIB_CXX) -DDTO_STATS_SUPPORT -o libdto.so.1.0 -laccel-config -ldl -lnuma -mwaitpkg
gcc -shared -fPIC -Wl,-soname,libdto.so dto.c $(DML_LIB_CXX) -DDTO_STATS_SUPPORT -msse4.2 -o libdto.so.1.0 -laccel-config -ldl -lnuma -mwaitpkg

libdto_nostats: dto.c
gcc -shared -fPIC -Wl,-soname,libdto.so dto.c $(DML_LIB_CXX) -o libdto.so.1.0 -laccel-config -ldl -lnuma -mwaitpkg
gcc -shared -fPIC -Wl,-soname,libdto.so dto.c $(DML_LIB_CXX) -msse4.2 -o libdto.so.1.0 -laccel-config -ldl -lnuma -mwaitpkg

install:
cp libdto.so.1.0 /usr/lib64/
ln -sf /usr/lib64/libdto.so.1.0 /usr/lib64/libdto.so.1
ln -sf /usr/lib64/libdto.so.1.0 /usr/lib64/libdto.so
cp dto.h /usr/include/

install-local:
ln -sf ./libdto.so.1.0 ./libdto.so.1
Expand Down
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,65 @@ can be enabled or disabled using an environment variable DTO_AUTO_ADJUST_KNOBS.

DTO can also be used to learn certain application characterics by building histogram of various API types and sizes. The histogram can be built using an environment variable DTO_COLLECT_STATS.

## DTO API

DTO provides drop-in replacements for standard memory operations. Each function
is available in three forms:

- `*_default` uses library defaults.
- `*_cfg` accepts a `struct dto_call_cfg` to override per-call behavior.
- The unsuffixed name derives configuration from a bitwise OR of `DTO_API_*`
flags.

We also support CRC32C offload via `dto_memcpy_crc` and `dto_crc` functions. `dto_memcpy_crc`
offloads both memcpy and CRC32C computation to DSA, while `dto_crc` offloads only CRC32C computation to DSA.

Available entry points include:

- `dto_memcpy_default`, `dto_memcpy_cfg`, `dto_memcpy`
- `dto_memmove_default`, `dto_memmove_cfg`, `dto_memmove`
- `dto_memset_default`, `dto_memset_cfg`, `dto_memset`
- `dto_memcmp_default`, `dto_memcmp_cfg`, `dto_memcmp`
- `dto_memcpy_crc_default`, `dto_memcpy_crc_cfg`, `dto_memcpy_crc`
- `dto_crc_default`, `dto_crc_cfg`, `dto_crc`

### Sample usage

```c
#include <stdint.h>
#include "dto.h"

int main(void)
{
char src[64] = "example";
char dst[64];

/* Use defaults */
dto_memcpy_default(dst, src, sizeof(src));

/* Per-call configuration */
struct dto_call_cfg cfg = {
.auto_adjust = 0,
.cache_control = 1,
.wait_method = WAIT_BUSYPOLL,
.numa_mode = NA_BUFFER_CENTRIC,
.overlapping_action = OVERLAPPING_CPU,
};
int diff = dto_memcmp_cfg(dst, src, sizeof(src), &cfg);

/* Flags-based configuration */
dto_memset(dst, 0, sizeof(dst), DTO_API_WAIT_YIELD);

/* Copy while computing CRC */
uint32_t c1 = dto_memcpy_crc_default(dst, src, sizeof(src));

/* Compute CRC with flags-based configuration */
uint32_t c2 = dto_crc(src, sizeof(src), DTO_API_WAIT_YIELD, NULL, NULL);

return diff;
}
```

```bash
dto.c: DSA Transparent Offload shared library
dto-test.c: Sample multi-threaded test application
Expand Down
8 changes: 7 additions & 1 deletion accelConfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ echo "OPTIONAL Arg-1: DSA device id. Default: 0"
echo "OPTIONAL Arg-2: Enable/Disable DSA device. Default: yes"
echo "OPTIONAL Arg-3: SHARED WQ id. Default: 1"
echo "OPTIONAL Arg-4: ENGINE count. Default: 4"
echo "OPTIONAL Arg-5: Block on fault. Default: no, but this is needed for CRC32!"

if [ "$#" -ge 5 ]; then
echo "ERROR: Incorrect argument count. Expected arg count <= 4"
Expand All @@ -14,6 +15,7 @@ DEVID=${1:-0}
ENABLE=${2:-yes}
SWQID=${3:-1}
NENGS=${4:-4}
BLOCKONFAULT=${5:-no}

DEV=dsa${DEVID}
SWQ=${DEV}/wq${DEVID}.${SWQID}
Expand Down Expand Up @@ -41,7 +43,11 @@ accel-config config-wq ${SWQ} --priority=1
accel-config config-wq ${SWQ} --wq-size=128
accel-config config-wq ${SWQ} --max-batch-size=1024
accel-config config-wq ${SWQ} --max-transfer-size=2147483648
accel-config config-wq ${SWQ} --block-on-fault=0
if [ "${BLOCKONFAULT}" == "yes" ]; then
accel-config config-wq ${SWQ} --block-on-fault=1
else
accel-config config-wq ${SWQ} --block-on-fault=0

accel-config config-wq ${SWQ} --type=user
accel-config config-wq ${SWQ} --name="dsa-test"
accel-config config-wq ${SWQ} --mode=shared
Expand Down
Loading