Skip to content
Merged
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
52 changes: 46 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- [WhiteBox SSD Mode (OCSSD)](#whitebox-ssd-mode-ocssd)
- [Zoned Namespace SSD Mode (ZNSSD)](#zoned-namespace-ssd-mode-znssd)
- [NoSSD Mode](#nossd-mode)
- [Computational Storage Mode (CSD)](#computational-storage-mode-csd)
- [Configuration](#configuration)
- [Development](#development)
- [Troubleshooting](#troubleshooting)
Expand Down Expand Up @@ -62,12 +63,12 @@ FEMU bridges the gap between SSD hardware platforms and SSD simulators by provid

## Features

| Feature | BlackBox | WhiteBox | ZNS | NoSSD |
|---------|----------|----------|-----|--------|
| **FTL Management** | Device-side | Host-side | Zone-based | None |
| **Use Cases** | Commercial SSD simulation | OpenChannel SSD research | ZNS research | SCM emulation |
| **Latency Model** | Realistic NAND | Realistic NAND | Zone-optimized | Ultra-low (sub-10μs) |
| **Guest Support** | Full NVMe | OpenChannel 1.2/2.0 | NVMe ZNS | NVMe basic |
| Feature | BlackBox | WhiteBox | ZNS | NoSSD | CSD |
|---------|----------|----------|-----|--------|-----|
| **FTL Management** | Device-side | Host-side | Zone-based | None | Device-side |
| **Use Cases** | Commercial SSD simulation | OpenChannel SSD research | ZNS research | SCM emulation | Computational storage research |
| **Latency Model** | Realistic NAND | Realistic NAND | Zone-optimized | Ultra-low (sub-10μs) | Realistic NAND + compute runtime |
| **Guest Support** | Full NVMe | OpenChannel 1.2/2.0 | NVMe ZNS | NVMe basic | Full NVMe + CSD commands |

---

Expand Down Expand Up @@ -367,6 +368,42 @@ Ultra-fast NVMe emulation without storage logic.
- Performance upper-bound testing
- Fast storage prototyping

### Computational Storage Mode (CSD)

Experimental computational storage support derived from CEMU. CSD is selected
with `femu_mode=4` and keeps CSD-specific code under `hw/femu/csd/`.

```bash
./run-csd.sh
```

**Key Parameters:**
```bash
fdm_size=64 # Functional data memory size (MB), required
nr_cu=4 # Number of compute units
nr_thread=4 # Number of functional simulation threads
time_slice=200000 # Scheduler time slice (ns)
context_switch_time=200 # Context switch time (ns)
csf_runtime_scale=3 # Runtime scaling factor
```

**Current Scope:**
- Normal NVMe read/write through the device-side BBSSD FTL path in CSD mode
- Vendor commands for AFDM allocation, read/write, NVM-to-AFDM copy
- Phantom and shared-library CSF load/execute path using the original CEMU
lifecycle, `path\0symbol\0` program descriptor format, and program execute
fields (`pind`, `numr`, `dlen`, `cparam1`, `cparam2`, `group`, `runtime`)
- CEMU-style admin commands for CSF load/unload and activate/deactivate
- Optional uBPF CSF support via `./femu-compile.sh --enable-csd-ubpf`
or `./femu-compile.sh --enable-csd-ubpf=/path/to/ubpf-cemu`
- Group/QoS command metadata
- Guest-side passthrough tests in `tests/femu-csd/`

The initial CSD path does not require a CEMU-specific Linux kernel, FDMFS, or a
fixed VM image. Advanced CEMU features such as VM freezing, virtual clock
changes, and FDMFS are intentionally kept out of the default path while the base
mode is upstreamed.

---

## Configuration
Expand Down Expand Up @@ -451,6 +488,9 @@ hw/femu/ # Main FEMU implementation
│ └── zftl.c # Zone-based FTL
├── nossd/ # NoSSD mode
│ └── nop.c # Minimal processing
├── csd/ # Computational Storage mode
│ ├── csd.c # CSD command handling
│ └── csd.h # CSD private command definitions
├── timing-model/ # Performance modeling
├── backend/ # Storage backends
└── lib/ # Utility libraries
Expand Down
20 changes: 19 additions & 1 deletion femu-scripts/femu-compile.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
#!/bin/bash

NRCPUS="$(cat /proc/cpuinfo | grep "vendor_id" | wc -l)"
FEMU_CONFIGURE_OPTS=""

for arg in "$@"; do
case "$arg" in
--enable-csd-ubpf)
FEMU_CONFIGURE_OPTS="${FEMU_CONFIGURE_OPTS} --enable-femu-csd-ubpf"
;;
--enable-csd-ubpf=*)
UBPF_PATH="${arg#*=}"
FEMU_CONFIGURE_OPTS="${FEMU_CONFIGURE_OPTS} --enable-femu-csd-ubpf -Dfemu_csd_ubpf_path=${UBPF_PATH}"
;;
Comment on lines +11 to +14
*)
echo "Unknown option: $arg"
echo "Usage: $0 [--enable-csd-ubpf[=/path/to/ubpf-cemu]]"
exit 1
;;
esac
done

make clean
# --disable-werror --extra-cflags=-w --disable-git-update
../configure --enable-kvm --target-list=x86_64-softmmu --enable-slirp
../configure --enable-kvm --target-list=x86_64-softmmu --enable-slirp ${FEMU_CONFIGURE_OPTS}
make -j $NRCPUS

echo ""
Expand Down
3 changes: 1 addition & 2 deletions femu-scripts/femu-copy-scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

FSD="../femu-scripts"

CPL=(pkgdep.sh femu-compile.sh run-whitebox.sh run-blackbox.sh run-blackbox-fdp.sh run-nossd.sh run-zns.sh pin.sh ftk)
CPL=(pkgdep.sh femu-compile.sh run-whitebox.sh run-blackbox.sh run-blackbox-fdp.sh run-nossd.sh run-zns.sh run-csd.sh pin.sh ftk)

echo ""
echo "==> Copying following FEMU script to current directory:"
Expand All @@ -18,4 +18,3 @@ do
done
echo "Done!"
echo ""

88 changes: 88 additions & 0 deletions femu-scripts/run-csd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/bin/bash
# Run FEMU as a Computational Storage Drive (CSD)

# Image directory
IMGDIR=$HOME/images
# Virtual machine disk image
OSIMGF=$IMGDIR/u20s.qcow2

# Configurable SSD Controller layout parameters (must be power of 2)
secsz=512 # sector size in bytes
secs_per_pg=8 # number of sectors in a flash page
pgs_per_blk=256 # number of pages per flash block
blks_per_pl=256 # number of blocks per plane
pls_per_lun=1 # keep it at one, no multiplanes support
luns_per_ch=8 # number of chips per channel
nchs=8 # number of channels
ssd_size=4096 # in megabytes

# Latency in nanoseconds
pg_rd_lat=40000 # page read latency
pg_wr_lat=200000 # page write latency
blk_er_lat=2000000 # block erase latency
ch_xfer_lat=0 # channel transfer time, ignored for now

# GC Threshold (1-100)
gc_thres_pcent=75
gc_thres_pcent_high=95

# FEMU CSD parameters
fdm_size=64
nr_cu=4
nr_thread=4
time_slice=200000
context_switch_time=200
csf_runtime_scale=3

#-----------------------------------------------------------------------

# Compose the entire FEMU CSD command line options
FEMU_OPTIONS="-device femu"
FEMU_OPTIONS=${FEMU_OPTIONS}",devsz_mb=${ssd_size}"
FEMU_OPTIONS=${FEMU_OPTIONS}",namespaces=1"
FEMU_OPTIONS=${FEMU_OPTIONS}",femu_mode=4"
FEMU_OPTIONS=${FEMU_OPTIONS}",secsz=${secsz}"
FEMU_OPTIONS=${FEMU_OPTIONS}",secs_per_pg=${secs_per_pg}"
FEMU_OPTIONS=${FEMU_OPTIONS}",pgs_per_blk=${pgs_per_blk}"
FEMU_OPTIONS=${FEMU_OPTIONS}",blks_per_pl=${blks_per_pl}"
FEMU_OPTIONS=${FEMU_OPTIONS}",pls_per_lun=${pls_per_lun}"
FEMU_OPTIONS=${FEMU_OPTIONS}",luns_per_ch=${luns_per_ch}"
FEMU_OPTIONS=${FEMU_OPTIONS}",nchs=${nchs}"
FEMU_OPTIONS=${FEMU_OPTIONS}",pg_rd_lat=${pg_rd_lat}"
FEMU_OPTIONS=${FEMU_OPTIONS}",pg_wr_lat=${pg_wr_lat}"
FEMU_OPTIONS=${FEMU_OPTIONS}",blk_er_lat=${blk_er_lat}"
FEMU_OPTIONS=${FEMU_OPTIONS}",ch_xfer_lat=${ch_xfer_lat}"
FEMU_OPTIONS=${FEMU_OPTIONS}",gc_thres_pcent=${gc_thres_pcent}"
FEMU_OPTIONS=${FEMU_OPTIONS}",gc_thres_pcent_high=${gc_thres_pcent_high}"
FEMU_OPTIONS=${FEMU_OPTIONS}",fdm_size=${fdm_size}"
FEMU_OPTIONS=${FEMU_OPTIONS}",nr_cu=${nr_cu}"
FEMU_OPTIONS=${FEMU_OPTIONS}",nr_thread=${nr_thread}"
FEMU_OPTIONS=${FEMU_OPTIONS}",time_slice=${time_slice}"
FEMU_OPTIONS=${FEMU_OPTIONS}",context_switch_time=${context_switch_time}"
FEMU_OPTIONS=${FEMU_OPTIONS}",csf_runtime_scale=${csf_runtime_scale}"

echo ${FEMU_OPTIONS}

if [[ ! -e "$OSIMGF" ]]; then
echo ""
echo "VM disk image couldn't be found ..."
echo "Please prepare a usable VM image and place it as $OSIMGF"
echo "Once VM disk image is ready, please rerun this script again"
echo ""
exit
fi

sudo ./qemu-system-x86_64 \
-name "FEMU-CSD-VM" \
-enable-kvm \
-cpu host \
-smp 4 \
-m 4G \
-device virtio-scsi-pci,id=scsi0 \
-device scsi-hd,drive=hd0 \
-drive file=$OSIMGF,if=none,aio=native,cache=none,format=qcow2,id=hd0 \
${FEMU_OPTIONS} \
-net user,hostfwd=tcp::8080-:22 \
-net nic,model=virtio \
-nographic \
-qmp unix:./qmp-sock,server,nowait 2>&1 | tee log
3 changes: 2 additions & 1 deletion hw/femu/backend/dram.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ int backend_rw(SsdDramBackend *b, QEMUSGList *qsg, uint64_t *lbal, bool is_write
mb_oft = lbal[sg_cur_index];
} else if (b->femu_mode == FEMU_BBSSD_MODE ||
b->femu_mode == FEMU_NOSSD_MODE ||
b->femu_mode == FEMU_ZNSSD_MODE) {
b->femu_mode == FEMU_ZNSSD_MODE ||
b->femu_mode == FEMU_CSD_MODE) {
mb_oft += cur_len;
} else {
assert(0);
Expand Down
Loading
Loading